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        public boolean tryPlaceIntoWorld(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int par4, int par5, int par6, int par7, float par8, float par9, float par10)
015        {
016            int var11 = par3World.getBlockId(par4, par5, par6);
017    
018            if (var11 == Block.snow.blockID)
019            {
020                par7 = 1;
021            }
022            else if (var11 != Block.vine.blockID && var11 != Block.tallGrass.blockID && var11 != Block.deadBush.blockID)
023            {
024                if (par7 == 0)
025                {
026                    --par5;
027                }
028    
029                if (par7 == 1)
030                {
031                    ++par5;
032                }
033    
034                if (par7 == 2)
035                {
036                    --par6;
037                }
038    
039                if (par7 == 3)
040                {
041                    ++par6;
042                }
043    
044                if (par7 == 4)
045                {
046                    --par4;
047                }
048    
049                if (par7 == 5)
050                {
051                    ++par4;
052                }
053            }
054    
055            if (!par2EntityPlayer.canPlayerEdit(par4, par5, par6))
056            {
057                return false;
058            }
059            else if (par1ItemStack.stackSize == 0)
060            {
061                return false;
062            }
063            else
064            {
065                if (par3World.canPlaceEntityOnSide(this.spawnID, par4, par5, par6, false, par7, (Entity)null))
066                {
067                    Block var12 = Block.blocksList[this.spawnID];
068    
069                    if (par3World.setBlockWithNotify(par4, par5, par6, this.spawnID))
070                    {
071                        if (par3World.getBlockId(par4, par5, par6) == this.spawnID)
072                        {
073                            Block.blocksList[this.spawnID].updateBlockMetadata(par3World, par4, par5, par6, par7, par8, par9, par10);
074                            Block.blocksList[this.spawnID].onBlockPlacedBy(par3World, par4, par5, par6, par2EntityPlayer);
075                        }
076    
077                        par3World.playSoundEffect((double)((float)par4 + 0.5F), (double)((float)par5 + 0.5F), (double)((float)par6 + 0.5F), var12.stepSound.getStepSound(), (var12.stepSound.getVolume() + 1.0F) / 2.0F, var12.stepSound.getPitch() * 0.8F);
078                        --par1ItemStack.stackSize;
079                    }
080                }
081    
082                return true;
083            }
084        }
085    }