mojira.dev
MC-114019

Mob spawners can create fake entities client-side for certain mobs

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

  1. Place a spawner spawning zombies

    /setblock ~ ~ ~ spawner{SpawnData:{id:"zombie"}}
  2. Place a repeating command block modifying the NBT data of the spawner

    /data merge block ~ ~-1 ~ {NonExistentTag:1b}
  3. 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

Confirmed for 1.13.1.

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.

I am unable to reproduce this issue in 1.17.1.

[media]

I am also unable to reproduce this in 1.17.1.

Resolving as Cannot Reproduce then.
In 1.17.1 with Mojang names, it appears Mob.finalizeSpawn (which is equivalent to MCP's onInitialSpawn) is only called by the server.

marcono1234

(Unassigned)

Confirmed

(Unassigned)

entity, mob-spawner, rendering, spawning

Minecraft 1.11.2, Minecraft 17w06a, Minecraft 1.12.2, Minecraft 18w11a, Minecraft 1.13.1

Retrieved