The bug
Player can interact with with mob while their dying animation is happening. This can partwise result in mobs in invalid states, entity "duplication" and other unwanted situations.
Affected situations
Situation | Note |
---|---|
shearing sheep | - |
taming wolf | results in alive tamed wolf with dying animation |
taming ocelot | - |
feeding (baby) animal | - |
shearing mushroom | - |
using name tag | - |
using leash | leash is used but instantly dropped at position of mob |
using flint and steel on creeper | creeper is not ignited but flint and steel loses durability |
shearing snowman | - |
saddling pig | - |
using spawn egg on breedable mob | - |
How to reproduce (sheep)
Spawn a Sheep
Punch sheep 7 times with bare hands
Punch and shear the sheep at the same time (left and right click quickly)
You will get 4 blocks of wool
Code analysis
Based on 1.11.2 decompiled using MCP 9.35 rc1
The problem is that the method net.minecraft.entity.player.EntityPlayer.interactOn(Entity, EnumHand)
does not prevent interaction with dying mobs. Or all methods overriding the method net.minecraft.item.Item.itemInteractionForEntity(ItemStack, EntityPlayer, EntityLivingBase, EnumHand)
or net.minecraft.entity.EntityLiving.processInteract(EntityPlayer, EnumHand)
.
Linked issues
is duplicated by 4
relates to 4
Comments 8

Right and left click at the same time (you have to be fast)
Confirmed. The description is slightly misleading, the actual bug is that dead sheep can be sheared. Kill the sheep and then shear the corpse.
Confirmed.

Confirmed for
16w06a

Please link to this comment in the description
The following is based on decompiled version of Minecraft 1.8 using MCP. All method and class names are the names used in the decompiled version.
The reason for this is that the method public final boolean interactFirst(EntityPlayer playerIn)
of the class net.minecraft.entity.EntityLiving
does not test if the entity is already dead. Because an entity is not instantaneously removed once it is dead, the player can still (like it is visible with this bug) interact with the entity even though it is dead. This could be fixed by only allowing interaction if the entity is not dead.
/**
* First layer of player interaction
*/
public final boolean interactFirst(EntityPlayer playerIn)
{
// Added this
if (this.isDead || this.dead) {
return false;
}
else {
// ...
}
}

Confirmed for 1.12.1.
You can also put a saddle on a dead pig, which could lead to the fact that the saddle disappears.
Confirmed for 1.13.1.
How do you shear and punch it at the same time?