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