mojira.dev
MC-2573

Potions and Food are consumed on death

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

Comments 14

Is this in SMP or SSP?

Confirmed in both gamemodes.

Confirmed in 1.4.6.

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.

4 more comments

Reopened and changed reporter to @unknown as @unknown is no longer active.

Confirmed for 1.10.2.

This also happens with food.

This is fixed in 16w35a and I'm pretty sure it also was in the previous version. I think it was also on mojang.com.

Jared Jones

reuben searson

(Unassigned)

Confirmed

food, keepinventory, potion

Minecraft 1.4.4, Minecraft 1.4.6, Minecraft 1.4.7, Minecraft 1.5, Minecraft 1.6.4, ..., Minecraft 1.10.2, Minecraft 16w32a, Minecraft 16w32b, Minecraft 16w33a, Minecraft 16w39c

Minecraft 16w33a, Minecraft 1.11

Retrieved