    001package net.minecraft.item;
    002
    003import cpw.mods.fml.relauncher.Side;
    004import cpw.mods.fml.relauncher.SideOnly;
    005import net.minecraft.block.Block;
    006import net.minecraft.block.material.Material;
    007import net.minecraft.entity.player.EntityPlayer;
    008import net.minecraft.util.EnumMovingObjectType;
    009import net.minecraft.util.MovingObjectPosition;
    010import net.minecraft.world.World;
    011
    012public 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 movingobjectposition = this.getMovingObjectPositionFromPlayer(par2World, par3EntityPlayer, true);
    025
    026        if (movingobjectposition == null)
    027        {
    028            return par1ItemStack;
    029        }
    030        else
    031        {
    032            if (movingobjectposition.typeOfHit == EnumMovingObjectType.TILE)
    033            {
    034                int i = movingobjectposition.blockX;
    035                int j = movingobjectposition.blockY;
    036                int k = movingobjectposition.blockZ;
    037
    038                if (!par2World.canMineBlock(par3EntityPlayer, i, j, k))
    039                {
    040                    return par1ItemStack;
    041                }
    042
    043                if (!par3EntityPlayer.canPlayerEdit(i, j, k, movingobjectposition.sideHit, par1ItemStack))
    044                {
    045                    return par1ItemStack;
    046                }
    047
    048                if (par2World.getBlockMaterial(i, j, k) == Material.water && par2World.getBlockMetadata(i, j, k) == 0 && par2World.isAirBlock(i, j + 1, k))
    049                {
    050                    par2World.setBlock(i, j + 1, k, 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}