When using keepinventory = true. If the player is killed in the process of drinking a potion or eating food then the potion or food item will be consumed while on the death screen. This allows potions and food to be wasted when trying to keep from dying in combat.
The drinking process should stop on death and the potion or food should not be consumed until the end of the drinking animation.
The following is based on a decompiled version of Minecraft 1.10 using MCP 9.30.
To fix this, add an if statement to check if the player is alive in onItemUseFinish
before depleting the item.
ItemFood.java
public ItemStack onItemUseFinish(ItemStack stack, World worldIn, EntityLivingBase entityLiving)
{
if (entityLiving.isEntityAlive())
{
}
return stack;
}
ItemPotion.java
public ItemStack onItemUseFinish(ItemStack stack, World worldIn, EntityLivingBase entityLiving)
{
EntityPlayer entityplayer = entityLiving instanceof EntityPlayer ? (EntityPlayer) entityLiving : null;
if (entityplayer.isEntityAlive())
{
}
return stack;
}
Linked issues
is cloned by 1
is duplicated by 1
Comments 14
Is this still a concern in the current Minecraft version 1.6.4 / Launcher version 1.2.5 ? If so, please update the affected versions in order to best aid Mojang ensuring bugs are still valid in the latest releases/pre-releases.
Is this in SMP or SSP?