Advertisement
Guest User

ItemTomato.java

a guest
May 25th, 2013
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.16 KB | None | 0 0
  1. package mod.pyrhatt.moplants;
  2.  
  3. import net.minecraft.block.Block;
  4. import net.minecraft.entity.Entity;
  5. import net.minecraft.entity.player.EntityPlayer;
  6. import net.minecraft.item.Item;
  7. import net.minecraft.item.ItemStack;
  8. import net.minecraft.world.World;
  9.  
  10. public class ItemTomato extends Item
  11. {
  12. /** The ID of the block the reed will spawn when used from inventory bar. */
  13. private int spawnID;
  14.  
  15. public ItemTomato(int par1, Block par2Block)
  16. {
  17. super(par1);
  18. this.spawnID = par2Block.blockID;
  19. }
  20.  
  21. /**
  22. * Callback for item usage. If the item does something special on right clicking, he will have one of those. Return
  23. * True if something happen and false if it don't. This is for ITEMS, not BLOCKS
  24. */
  25. public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int par4, int par5, int par6, int par7, float par8, float par9, float par10)
  26. {
  27. int i1 = par3World.getBlockId(par4, par5, par6);
  28.  
  29. if (i1 == Block.snow.blockID && (par3World.getBlockMetadata(par4, par5, par6) & 7) < 1)
  30. {
  31. par7 = 1;
  32. }
  33. else if (i1 != Block.vine.blockID && i1 != Block.tallGrass.blockID && i1 != Block.deadBush.blockID)
  34. {
  35. if (par7 == 0)
  36. {
  37. --par5;
  38. }
  39.  
  40. if (par7 == 1)
  41. {
  42. ++par5;
  43. }
  44.  
  45. if (par7 == 2)
  46. {
  47. --par6;
  48. }
  49.  
  50. if (par7 == 3)
  51. {
  52. ++par6;
  53. }
  54.  
  55. if (par7 == 4)
  56. {
  57. --par4;
  58. }
  59.  
  60. if (par7 == 5)
  61. {
  62. ++par4;
  63. }
  64. }
  65.  
  66. if (!par2EntityPlayer.canPlayerEdit(par4, par5, par6, par7, par1ItemStack))
  67. {
  68. return false;
  69. }
  70. else if (par1ItemStack.stackSize == 0)
  71. {
  72. return false;
  73. }
  74. else
  75. {
  76. if (par3World.canPlaceEntityOnSide(this.spawnID, par4, par5, par6, false, par7, (Entity)null, par1ItemStack))
  77. {
  78. Block block = Block.blocksList[this.spawnID];
  79. int j1 = block.onBlockPlaced(par3World, par4, par5, par6, par7, par8, par9, par10, 0);
  80.  
  81. if (par3World.setBlock(par4, par5, par6, this.spawnID, j1, 3))
  82. {
  83. if (par3World.getBlockId(par4, par5, par6) == this.spawnID)
  84. {
  85. Block.blocksList[this.spawnID].onBlockPlacedBy(par3World, par4, par5, par6, par2EntityPlayer, par1ItemStack);
  86. Block.blocksList[this.spawnID].onPostBlockPlaced(par3World, par4, par5, par6, j1);
  87. }
  88.  
  89. par3World.playSoundEffect((double)((float)par4 + 0.5F), (double)((float)par5 + 0.5F), (double)((float)par6 + 0.5F), block.stepSound.getPlaceSound(), (block.stepSound.getVolume() + 1.0F) / 2.0F, block.stepSound.getPitch() * 0.8F);
  90. --par1ItemStack.stackSize;
  91. }
  92. }
  93.  
  94. return true;
  95. }
  96. }
  97. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement