Guest User

ItemCorn

a guest
Dec 25th, 2014
288
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.01 KB | None | 0 0
  1. package com.chef.mod.crops;
  2.  
  3. import net.minecraft.block.Block;
  4. import net.minecraft.entity.Entity;
  5. import net.minecraft.entity.player.EntityPlayer;
  6. import net.minecraft.init.Blocks;
  7. import net.minecraft.item.Item;
  8. import net.minecraft.item.ItemFood;
  9. import net.minecraft.item.ItemReed;
  10. import net.minecraft.item.ItemStack;
  11. import net.minecraft.world.World;
  12.  
  13. public class ItemCorn extends ItemFood {
  14. private Block field_150935_a;
  15. private static final String __OBFID = "CL_00001773";
  16.  
  17. public ItemCorn(Block cropCornPlant, int i, float float1)
  18. {
  19. super(i, float1, false);
  20. this.field_150935_a = cropCornPlant;
  21. }
  22.  
  23. /**
  24. * Callback for item usage. If the item does something special on right clicking, he will have one of those. Return
  25. * True if something happen and false if it don't. This is for ITEMS, not BLOCKS
  26. */
  27. public boolean onItemUse(ItemStack itemstack, EntityPlayer entityplayer, World world, int x, int y, int z, int i, float hitX, float hitY, float hitZ) {
  28.  
  29. Block block = world.getBlock(x, y, z);
  30.  
  31. if (block == Blocks.snow_layer && (world.getBlockMetadata(x, y, z) & 7) < 1)
  32. {
  33. i = 1;
  34. }
  35. else if (block != Blocks.vine && block != Blocks.tallgrass && block != Blocks.deadbush)
  36. {
  37. if (i == 0)
  38. {
  39. --y;
  40. }
  41.  
  42. if (i == 1)
  43. {
  44. ++y;
  45. }
  46.  
  47. if (i == 2)
  48. {
  49. --z;
  50. }
  51.  
  52. if (i == 3)
  53. {
  54. ++z;
  55. }
  56.  
  57. if (i == 4)
  58. {
  59. --x;
  60. }
  61.  
  62. if (i == 5)
  63. {
  64. ++x;
  65. }
  66. }
  67.  
  68. if (!entityplayer.canPlayerEdit(x, y, z, i, itemstack))
  69. {
  70. return false;
  71. }
  72. else if (itemstack.stackSize == 0)
  73. {
  74. return false;
  75. }
  76. else
  77. {
  78. if (world.canPlaceEntityOnSide(this.field_150935_a, x, y, z, false, i, (Entity)null, itemstack))
  79. {
  80. int i1 = this.field_150935_a.onBlockPlaced(world, x, y, z, i, hitX, hitY, hitZ, 0);
  81.  
  82. if (world.setBlock(x, y, z, this.field_150935_a, i1, 3))
  83. {
  84. if (world.getBlock(x, y, z) == this.field_150935_a)
  85. {
  86. this.field_150935_a.onBlockPlacedBy(world, x, y, z, entityplayer, itemstack);
  87. this.field_150935_a.onPostBlockPlaced(world, x, y, z, i1);
  88. }
  89.  
  90. world.playSoundEffect((double)((float)x + 0.5F), (double)((float)y + 0.5F), (double)((float)z + 0.5F), this.field_150935_a.stepSound.func_150496_b(), (this.field_150935_a.stepSound.getVolume() + 1.0F) / 2.0F, this.field_150935_a.stepSound.getPitch() * 0.8F);
  91. --itemstack.stackSize;
  92. }
  93. }
  94.  
  95. return true;
  96. }
  97. }
  98. }
Advertisement
Add Comment
Please, Sign In to add comment