package net.minecraft.item; import net.minecraft.advancements.CriteriaTriggers; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.init.Items; import net.minecraft.stats.StatList; import net.minecraft.util.ActionResult; import net.minecraft.util.EnumActionResult; import net.minecraft.util.EnumHand; import net.minecraft.world.World; public class ItemBucketMilk extends Item { public ItemBucketMilk() { this.setMaxStackSize(1); this.setCreativeTab(CreativeTabs.MISC); } /** * Called when the player finishes using this Item (E.g. finishes eating.). Not called when the player stops using * the Item before the action is complete. */ public ItemStack onItemUseFinish(ItemStack stack, World worldIn, EntityLivingBase entityLiving) { if (!worldIn.isRemote) entityLiving.curePotionEffects(stack); // FORGE - move up so stack.shrink does not turn stack into air if (entityLiving instanceof EntityPlayerMP) { EntityPlayerMP entityplayermp = (EntityPlayerMP)entityLiving; CriteriaTriggers.CONSUME_ITEM.trigger(entityplayermp, stack); entityplayermp.addStat(StatList.getObjectUseStats(this)); } if (entityLiving instanceof EntityPlayer && !((EntityPlayer)entityLiving).capabilities.isCreativeMode) { stack.shrink(1); } return stack.isEmpty() ? new ItemStack(Items.BUCKET) : stack; } /** * How long it takes to use or consume an item */ public int getMaxItemUseDuration(ItemStack stack) { return 32; } /** * returns the action that specifies what animation to play when the items is being used */ public EnumAction getItemUseAction(ItemStack stack) { return EnumAction.DRINK; } @Override public net.minecraftforge.common.capabilities.ICapabilityProvider initCapabilities(ItemStack stack, net.minecraft.nbt.NBTTagCompound nbt) { return new net.minecraftforge.fluids.capability.wrappers.FluidBucketWrapper(stack); } /** * Called when the equipped item is right clicked. */ public ActionResult onItemRightClick(World worldIn, EntityPlayer playerIn, EnumHand handIn) { playerIn.setActiveHand(handIn); return new ActionResult(EnumActionResult.SUCCESS, playerIn.getHeldItem(handIn)); } }