    001    package net.minecraft.item;
    002
    003    import net.minecraft.block.material.Material;
    004    import net.minecraft.creativetab.CreativeTabs;
    005    import net.minecraft.entity.player.EntityPlayer;
    006    import net.minecraft.util.EnumMovingObjectType;
    007    import net.minecraft.util.MovingObjectPosition;
    008    import net.minecraft.world.World;
    009
    010    public class ItemGlassBottle extends Item
    011    {
    012        public ItemGlassBottle(int par1)
    013        {
    014            super(par1);
    015            this.setCreativeTab(CreativeTabs.tabBrewing);
    016        }
    017
    018        /**
    019         * Called whenever this item is equipped and the right mouse button is pressed. Args: itemStack, world, entityPlayer
    020         */
    021        public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer)
    022        {
    023            MovingObjectPosition var4 = this.getMovingObjectPositionFromPlayer(par2World, par3EntityPlayer, true);
    024
    025            if (var4 == null)
    026            {
    027                return par1ItemStack;
    028            }
    029            else
    030            {
    031                if (var4.typeOfHit == EnumMovingObjectType.TILE)
    032                {
    033                    int var5 = var4.blockX;
    034                    int var6 = var4.blockY;
    035                    int var7 = var4.blockZ;
    036
    037                    if (!par2World.canMineBlock(par3EntityPlayer, var5, var6, var7))
    038                    {
    039                        return par1ItemStack;
    040                    }
    041
    042                    if (!par3EntityPlayer.canPlayerEdit(var5, var6, var7, var4.sideHit, par1ItemStack))
    043                    {
    044                        return par1ItemStack;
    045                    }
    046
    047                    if (par2World.getBlockMaterial(var5, var6, var7) == Material.water)
    048                    {
    049                        --par1ItemStack.stackSize;
    050
    051                        if (par1ItemStack.stackSize <= 0)
    052                        {
    053                            return new ItemStack(Item.potion);
    054                        }
    055
    056                        if (!par3EntityPlayer.inventory.addItemStackToInventory(new ItemStack(Item.potion)))
    057                        {
    058                            par3EntityPlayer.dropPlayerItem(new ItemStack(Item.potion.shiftedIndex, 1, 0));
    059                        }
    060                    }
    061                }
    062
    063                return par1ItemStack;
    064            }
    065        }
    066    }