Zombified piglins spawned from lightning striking a pig do not have a chance to hold a golden spear instead of a golden sword. This may also affect reinforcements and spawning from portals, I’ve yet to test those cases extensively.
To reproduce (lightning)
/gamerule commandBlockOutput falsePlace a repeating command block facing upwards with
execute positioned ~ ~2 ~ summon pig summon minecraft:lightning_bolt as @n[type=minecraft:zombified_piglin] unless entity @s[nbt={equipment:{mainhand:{id:"golden_spear"}}}] run teleport @s ~ -128 ~Place a chain command block on top of it with
execute if entity @e[type=minecraft:zombified_piglin,nbt={equipment:{mainhand:{id:"minecraft:golden_spear"}}},distance=..2] run say He's got a spear!Power the repeating command block
Expected behavior
A message would be printed to indicate that a zombified piglin spawned with a spear (said zombified piglin would be killed by lightning before long).
For some reason the chain command block does not seem to do its job unless I remove the distance check, still figuring out what’s up with that