    001package net.minecraft.item;
    002
    003import net.minecraft.block.Block;
    004import net.minecraft.creativetab.CreativeTabs;
    005import net.minecraft.entity.player.EntityPlayer;
    006import net.minecraft.tileentity.TileEntitySign;
    007import net.minecraft.util.MathHelper;
    008import net.minecraft.world.World;
    009
    010public class ItemSign extends Item
    011{
    012    public ItemSign(int par1)
    013    {
    014        super(par1);
    015        this.maxStackSize = 16;
    016        this.setCreativeTab(CreativeTabs.tabDecorations);
    017    }
    018
    019    /**
    020     * Callback for item usage. If the item does something special on right clicking, he will have one of those. Return
    021     * True if something happen and false if it don't. This is for ITEMS, not BLOCKS
    022     */
    023    public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int par4, int par5, int par6, int par7, float par8, float par9, float par10)
    024    {
    025        if (par7 == 0)
    026        {
    027            return false;
    028        }
    029        else if (!par3World.getBlockMaterial(par4, par5, par6).isSolid())
    030        {
    031            return false;
    032        }
    033        else
    034        {
    035            if (par7 == 1)
    036            {
    037                ++par5;
    038            }
    039
    040            if (par7 == 2)
    041            {
    042                --par6;
    043            }
    044
    045            if (par7 == 3)
    046            {
    047                ++par6;
    048            }
    049
    050            if (par7 == 4)
    051            {
    052                --par4;
    053            }
    054
    055            if (par7 == 5)
    056            {
    057                ++par4;
    058            }
    059
    060            if (!par2EntityPlayer.canPlayerEdit(par4, par5, par6, par7, par1ItemStack))
    061            {
    062                return false;
    063            }
    064            else if (!Block.signPost.canPlaceBlockAt(par3World, par4, par5, par6))
    065            {
    066                return false;
    067            }
    068            else
    069            {
    070                if (par7 == 1)
    071                {
    072                    int var11 = MathHelper.floor_double((double)((par2EntityPlayer.rotationYaw + 180.0F) * 16.0F / 360.0F) + 0.5D) & 15;
    073                    par3World.setBlockAndMetadataWithNotify(par4, par5, par6, Block.signPost.blockID, var11);
    074                }
    075                else
    076                {
    077                    par3World.setBlockAndMetadataWithNotify(par4, par5, par6, Block.signWall.blockID, par7);
    078                }
    079
    080                --par1ItemStack.stackSize;
    081                TileEntitySign var12 = (TileEntitySign)par3World.getBlockTileEntity(par4, par5, par6);
    082
    083                if (var12 != null)
    084                {
    085                    par2EntityPlayer.displayGUIEditSign(var12);
    086                }
    087
    088                return true;
    089            }
    090        }
    091    }
    092}