Uploaded image for project: 'Minecraft: Java Edition'
  1. Minecraft: Java Edition
  2. MC-2573

Potions and Food are consumed on death

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Minecraft 1.4.4, Minecraft 1.4.6, Minecraft 1.4.7, Minecraft 1.5, Minecraft 1.6.4, Minecraft 13w39b, Minecraft 14w30c, Minecraft 1.8.1-pre3, Minecraft 15w43b, Minecraft 1.9, Minecraft 1.10.2, Minecraft 16w32a, Minecraft 16w32b, Minecraft 16w33a, Minecraft 16w39c
    • Confirmed
    • Survival

      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;
      		
      	}
      

            Unassigned Unassigned
            harrypotter1a2b reuben searson
            Votes:
            6 Vote for this issue
            Watchers:
            8 Start watching this issue

              Created:
              Updated:
              Resolved:
              CHK: