Based on 1.11.2 decompiled using MCP 9.35 rc1
The bug
Mobs spawner create fake entities client-side if the mob to spawn overrides the method net.minecraft.entity.EntityLiving.onInitialSpawn(DifficultyInstance, IEntityLivingData)
to spawn additional entites.
How to reproduce
Place a spawner spawning zombies
/setblock ~ ~ ~ spawner{SpawnData:{id:"zombie"}}
Place a repeating command block modifying the NBT data of the spawner
/data merge block ~ ~-1 ~ {NonExistentTag:1b}
Go to 0, 0, 0
/tp 0 0 0
→ You will see multiple chicken jockeys
Code analysis
Based on 1.11.2 decompiled using MCP 9.35 rc1
The method net.minecraft.tileentity.MobSpawnerBaseLogic.getCachedEntity()
calls the method net.minecraft.entity.EntityLiving.onInitialSpawn(DifficultyInstance, IEntityLivingData)
when it creates the cached entity which is supposed to be rendered. The problem is that the onInitialSpawn
method might spawn additional entities. Additionally this method displays variations of the mob which are not actually spawned because the call happens independently from the server and therefor the server might spawn other variations or multiple variations during one spawning cycle if the SpawnCount
is higher than 1.
The expected behavior would be that the client does not call this method.
Attachments
Comments 5
I actually don't concur with this analysis. onInitialSpawn() is also necessary for entities that are not backed server-side because it sets parameters that are needed for rendering, e.g. weapons, the child flag, head gear etc. The bug here is that the zombie jockey code runs before the entity is added to the world. Minecraft needs to shift that code into a new callback from world.onEntityAdded() instead.
Confirmed for 1.13.1.