mojira.dev
MC-88096

When using spawn eggs on fences the mobs fall through

I recently saw that there is a part of code intended to make spawn eggs work on fences so that the mob stands on top of the fence.
It looks like that:

ItemSpawnEgg.java (ItemMonsterPlacer.java in MCP)

...
	public boolean onItemUse(ItemStack stack, EntityPlayer playerIn, World worldIn, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ) {
		...
		IBlockState var9 = worldIn.getBlockState(pos);
		...
		// It's supposed to check if the block it was placed one is a fence. How ever it's checking the BlockState, not the block.
		// What was meant to be done is var9.getBlock() instead of just var9.
		if(side == EnumFacing.UP && var9 instanceof BlockFence) {
			// Offset for the spawn
			var13 = 0.5D;
		}
		...
	}
	...

Better fix

As seen in the code snippet there is just a .getBlock() missing.

However when fixing this you could also make the offset (here var13) depended on the collision box of the block.
Then it would work for fence gates, cobble walls and also for slabs and so on too.

Video: https://youtu.be/ZkI3uU7hoBA?t=1m09s

This post might be seen as related: MC-65951

Related issues

Attachments

Comments

migrated
[media]
Sonicwave

MC-64953 (which describes the same issue but with much less info) shows that the problem has been occurring since at least 14w31a.

[Mod]Les3awe

Confirmed for 15w46a

  • Screenshot

[Mod]Les3awe

Confirmed for 15w47b

migrated

Confirmed for 15w51b.

Sonicwave

Confirmed for 16w05b.

migrated

Confirmed for 1.9.3-pre3.

migrated

Confirmed for 1.9.4.

migrated

Confirmed for 16w20a.

migrated

Confirmed for 16w21a.

migrated

Confirmed for 16w21b.

migrated

Confirmed for 1.10-pre1.

migrated

Confirmed for 1.10-pre2.

migrated

Confirmed for 1.10.

migrated

Confirmed for 1.10.1.

Panda4994

Agnes Larsson

Community Consensus

Minecraft 1.8.8, Minecraft 15w36b, Minecraft 15w36c, Minecraft 15w36d, Minecraft 15w37a, ..., Minecraft 1.10 Pre-Release 1, Minecraft 1.10 Pre-Release 2, Minecraft 1.10, Minecraft 1.10.1, Minecraft 1.10.2

Minecraft 16w32a

Retrieved