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