    001    package net.minecraft.src;
    002
    003    public class ItemReed extends Item
    004    {
    005        /** The ID of the block the reed will spawn when used from inventory bar. */
    006        private int spawnID;
    007
    008        public ItemReed(int par1, Block par2Block)
    009        {
    010            super(par1);
    011            this.spawnID = par2Block.blockID;
    012        }
    013
    014        /**
    015         * Callback for item usage. If the item does something special on right clicking, he will have one of those. Return
    016         * True if something happen and false if it don't. This is for ITEMS, not BLOCKS
    017         */
    018        public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int par4, int par5, int par6, int par7, float par8, float par9, float par10)
    019        {
    020            int var11 = par3World.getBlockId(par4, par5, par6);
    021
    022            if (var11 == Block.snow.blockID)
    023            {
    024                par7 = 1;
    025            }
    026            else if (var11 != Block.vine.blockID && var11 != Block.tallGrass.blockID && var11 != Block.deadBush.blockID)
    027            {
    028                if (par7 == 0)
    029                {
    030                    --par5;
    031                }
    032
    033                if (par7 == 1)
    034                {
    035                    ++par5;
    036                }
    037
    038                if (par7 == 2)
    039                {
    040                    --par6;
    041                }
    042
    043                if (par7 == 3)
    044                {
    045                    ++par6;
    046                }
    047
    048                if (par7 == 4)
    049                {
    050                    --par4;
    051                }
    052
    053                if (par7 == 5)
    054                {
    055                    ++par4;
    056                }
    057            }
    058
    059            if (!par2EntityPlayer.func_82247_a(par4, par5, par6, par7, par1ItemStack))
    060            {
    061                return false;
    062            }
    063            else if (par1ItemStack.stackSize == 0)
    064            {
    065                return false;
    066            }
    067            else
    068            {
    069                if (par3World.canPlaceEntityOnSide(this.spawnID, par4, par5, par6, false, par7, (Entity)null))
    070                {
    071                    Block var12 = Block.blocksList[this.spawnID];
    072                    int var13 = var12.func_85104_a(par3World, par4, par5, par6, par7, par8, par9, par10, 0);
    073
    074                    if (par3World.setBlockAndMetadataWithNotify(par4, par5, par6, this.spawnID, var13))
    075                    {
    076                        if (par3World.getBlockId(par4, par5, par6) == this.spawnID)
    077                        {
    078                            Block.blocksList[this.spawnID].onBlockPlacedBy(par3World, par4, par5, par6, par2EntityPlayer);
    079                            Block.blocksList[this.spawnID].func_85105_g(par3World, par4, par5, par6, var13);
    080                        }
    081
    082                        par3World.playSoundEffect((double)((float)par4 + 0.5F), (double)((float)par5 + 0.5F), (double)((float)par6 + 0.5F), var12.stepSound.getPlaceSound(), (var12.stepSound.getVolume() + 1.0F) / 2.0F, var12.stepSound.getPitch() * 0.8F);
    083                        --par1ItemStack.stackSize;
    084                    }
    085                }
    086
    087                return true;
    088            }
    089        }
    090    }