001 package net.minecraft.item;
002
003 import net.minecraft.block.Block;
004 import net.minecraft.entity.Entity;
005 import net.minecraft.entity.player.EntityPlayer;
006 import net.minecraft.world.World;
007
008 public class ItemReed extends Item
009 {
010 /** The ID of the block the reed will spawn when used from inventory bar. */
011 private int spawnID;
012
013 public ItemReed(int par1, Block par2Block)
014 {
015 super(par1);
016 this.spawnID = par2Block.blockID;
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 int var11 = par3World.getBlockId(par4, par5, par6);
026
027 if (var11 == Block.snow.blockID)
028 {
029 par7 = 1;
030 }
031 else if (var11 != Block.vine.blockID && var11 != Block.tallGrass.blockID && var11 != Block.deadBush.blockID)
032 {
033 if (par7 == 0)
034 {
035 --par5;
036 }
037
038 if (par7 == 1)
039 {
040 ++par5;
041 }
042
043 if (par7 == 2)
044 {
045 --par6;
046 }
047
048 if (par7 == 3)
049 {
050 ++par6;
051 }
052
053 if (par7 == 4)
054 {
055 --par4;
056 }
057
058 if (par7 == 5)
059 {
060 ++par4;
061 }
062 }
063
064 if (!par2EntityPlayer.canPlayerEdit(par4, par5, par6, par7, par1ItemStack))
065 {
066 return false;
067 }
068 else if (par1ItemStack.stackSize == 0)
069 {
070 return false;
071 }
072 else
073 {
074 if (par3World.canPlaceEntityOnSide(this.spawnID, par4, par5, par6, false, par7, (Entity)null))
075 {
076 Block var12 = Block.blocksList[this.spawnID];
077 int var13 = var12.onBlockPlaced(par3World, par4, par5, par6, par7, par8, par9, par10, 0);
078
079 if (par3World.setBlockAndMetadataWithNotify(par4, par5, par6, this.spawnID, var13))
080 {
081 if (par3World.getBlockId(par4, par5, par6) == this.spawnID)
082 {
083 Block.blocksList[this.spawnID].onBlockPlacedBy(par3World, par4, par5, par6, par2EntityPlayer);
084 Block.blocksList[this.spawnID].onPostBlockPlaced(par3World, par4, par5, par6, var13);
085 }
086
087 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);
088 --par1ItemStack.stackSize;
089 }
090 }
091
092 return true;
093 }
094 }
095 }