    001    package net.minecraft.item;
    002
    003    import cpw.mods.fml.common.Side;
    004    import cpw.mods.fml.common.asm.SideOnly;
    005    import net.minecraft.block.Block;
    006    import net.minecraft.block.material.Material;
    007    import net.minecraft.entity.player.EntityPlayer;
    008    import net.minecraft.util.EnumMovingObjectType;
    009    import net.minecraft.util.MovingObjectPosition;
    010    import net.minecraft.world.World;
    011
    012    public class ItemLilyPad extends ItemColored
    013    {
    014        public ItemLilyPad(int par1)
    015        {
    016            super(par1, false);
    017        }
    018
    019        /**
    020         * Called whenever this item is equipped and the right mouse button is pressed. Args: itemStack, world, entityPlayer
    021         */
    022        public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer)
    023        {
    024            MovingObjectPosition var4 = this.getMovingObjectPositionFromPlayer(par2World, par3EntityPlayer, true);
    025
    026            if (var4 == null)
    027            {
    028                return par1ItemStack;
    029            }
    030            else
    031            {
    032                if (var4.typeOfHit == EnumMovingObjectType.TILE)
    033                {
    034                    int var5 = var4.blockX;
    035                    int var6 = var4.blockY;
    036                    int var7 = var4.blockZ;
    037
    038                    if (!par2World.canMineBlock(par3EntityPlayer, var5, var6, var7))
    039                    {
    040                        return par1ItemStack;
    041                    }
    042
    043                    if (!par3EntityPlayer.canPlayerEdit(var5, var6, var7, var4.sideHit, par1ItemStack))
    044                    {
    045                        return par1ItemStack;
    046                    }
    047
    048                    if (par2World.getBlockMaterial(var5, var6, var7) == Material.water && par2World.getBlockMetadata(var5, var6, var7) == 0 && par2World.isAirBlock(var5, var6 + 1, var7))
    049                    {
    050                        par2World.setBlockWithNotify(var5, var6 + 1, var7, Block.waterlily.blockID);
    051
    052                        if (!par3EntityPlayer.capabilities.isCreativeMode)
    053                        {
    054                            --par1ItemStack.stackSize;
    055                        }
    056                    }
    057                }
    058
    059                return par1ItemStack;
    060            }
    061        }
    062
    063        @SideOnly(Side.CLIENT)
    064        public int getColorFromItemStack(ItemStack par1ItemStack, int par2)
    065        {
    066            return Block.waterlily.getRenderColor(par1ItemStack.getItemDamage());
    067        }
    068    }