Advertisement
Guest User

Untitled

a guest
Apr 21st, 2014
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.19 KB | None | 0 0
  1. package wwrp.Items;
  2.  
  3. import wwrp.Common.Modwwrp;
  4. import net.minecraft.block.Block;
  5. import net.minecraft.entity.player.EntityPlayer;
  6. import net.minecraft.item.ItemBlock;
  7. import net.minecraft.item.ItemStack;
  8. import net.minecraft.util.IIcon;
  9. import net.minecraft.world.World;
  10. import cpw.mods.fml.relauncher.Side;
  11. import cpw.mods.fml.relauncher.SideOnly;
  12.  
  13. public class ItemBlocklightOldPlanksSlab extends ItemBlock
  14. {
  15. private final boolean isFullBlock;
  16. private final Block theHalfSlab;
  17. private final Block doubleSlab;
  18.  
  19. public ItemBlocklightOldPlanksSlab(Block block)
  20. {
  21. super(block);
  22. this.theHalfSlab = Modwwrp.singleSlaboldPlanks;
  23. this.doubleSlab = Modwwrp.doubleSlaboldPlanks;
  24. if(block == Modwwrp.doubleSlaboldPlanks)
  25. {
  26. this.isFullBlock = true;
  27. }
  28. else
  29. {
  30. this.isFullBlock = false;
  31. }
  32. this.setMaxDamage(0);
  33. this.setHasSubtypes(true);
  34. }
  35.  
  36. @SideOnly(Side.CLIENT)
  37. public IIcon getIconFromDamage(int metadata)
  38. {
  39. return this.field_150939_a.getIcon(2, metadata);
  40. }
  41.  
  42. public int getMetadata(int metadata)
  43. {
  44. return metadata;
  45. }
  46.  
  47. public String getUnlocalizedName(ItemStack stack)
  48. {
  49. return ((wwrp.Blocks.Slab.BlocklightOldPlanksSlab)theHalfSlab).func_150002_b(stack.getItemDamage());
  50. }
  51.  
  52. public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float par8, float par9, float par10)
  53. {
  54. if(this.isFullBlock)
  55. {
  56. return super.onItemUse(stack, player, world, x, y, z, side, par8, par9, par10);
  57. }
  58. else if(stack.stackSize == 0)
  59. {
  60. return false;
  61. }
  62. else if(!player.canPlayerEdit(x, y, z, side, stack))
  63. {
  64. return false;
  65. }
  66. else
  67. {
  68. Block i1 = world.getBlock(x, y, z);
  69. int j1 = world.getBlockMetadata(x, y, z);
  70. int k1 = j1 & 7;
  71. boolean flag = (j1 & 8) != 0;
  72.  
  73. if((side == 1 && !flag || side == 0 && flag) && i1 == this.theHalfSlab && k1 == stack.getItemDamage())
  74. {
  75. if(world.checkNoEntityCollision(this.doubleSlab.getCollisionBoundingBoxFromPool(world, x, y, z)) && world.setBlock(x, y, z, this.doubleSlab, k1, 3))
  76. {
  77. world.playSoundEffect((double)((float)x + 0.5F), (double)((float)y + 0.5F), (double)((float)z + 0.5F), this.doubleSlab.stepSound.getStepResourcePath(), (this.doubleSlab.stepSound.getVolume() + 1.0F) / 2.0F, this.doubleSlab.stepSound.getPitch() * 0.8F);
  78. --stack.stackSize;
  79. }
  80. return true;
  81. }
  82. else
  83. {
  84. return this.placeDoubleSlabFromTop(stack, player, world, x, y, z, side) ? true : super.onItemUse(stack, player, world, x, y, z, side, par8, par9, par10);
  85. }
  86. }
  87. }
  88.  
  89. @SideOnly(Side.CLIENT)
  90. public boolean func_150936_a(World world, int x, int y, int z, int side, EntityPlayer player, ItemStack stack)
  91. {
  92. int i1 = x;
  93. int j1 = y;
  94. int k1 = z;
  95. Block id = world.getBlock(x, y, z);
  96. int meta = world.getBlockMetadata(x, y, z);
  97. int j2 = meta & 7;
  98. boolean flag = (meta & 8) != 0;
  99.  
  100. if((side == 1 && !flag || side == 0 && flag) && id == this.theHalfSlab && j2 == stack.getItemDamage())
  101. {
  102. return true;
  103. }
  104. else
  105. {
  106. if(side == 0)
  107. {
  108. --y;
  109. }
  110.  
  111. if(side == 1)
  112. {
  113. ++y;
  114. }
  115.  
  116. if(side == 2)
  117. {
  118. --z;
  119. }
  120.  
  121. if(side == 3)
  122. {
  123. ++z;
  124. }
  125.  
  126. if(side == 4)
  127. {
  128. --x;
  129. }
  130.  
  131. if(side == 5)
  132. {
  133. ++x;
  134. }
  135.  
  136. id = world.getBlock(x, y, z);
  137. meta = world.getBlockMetadata(x, y, z);
  138. j2 = meta & 7;
  139. flag = (meta & 8) != 0;
  140. return id == this.theHalfSlab && j2 == stack.getItemDamage() ? true : super.func_150936_a(world, i1, j1, k1, side, player, stack);
  141. }
  142. }
  143.  
  144. private boolean placeDoubleSlabFromTop(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side)
  145. {
  146. if(side == 0)
  147. {
  148. --y;
  149. }
  150.  
  151. if(side == 1)
  152. {
  153. ++y;
  154. }
  155.  
  156. if(side == 2)
  157. {
  158. --z;
  159. }
  160.  
  161. if(side == 3)
  162. {
  163. ++z;
  164. }
  165.  
  166. if(side == 4)
  167. {
  168. --x;
  169. }
  170.  
  171. if(side == 5)
  172. {
  173. ++x;
  174. }
  175.  
  176. Block i1 = world.getBlock(x, y, z);
  177. int j1 = world.getBlockMetadata(x, y, z);
  178. int k1 = j1 & 7;
  179.  
  180. if(i1 == this.theHalfSlab && k1 == stack.getItemDamage())
  181. {
  182. if(world.checkNoEntityCollision(this.doubleSlab.getCollisionBoundingBoxFromPool(world, x, y, z)) && world.setBlock(x, y, z, this.doubleSlab, k1, 3))
  183. {
  184. world.playSoundEffect((double)((float)x + 0.5F), (double)((float)y + 0.5F), (double)((float)z + 0.5F), this.doubleSlab.stepSound.getStepResourcePath(), (this.doubleSlab.stepSound.getVolume() + 1.0F) / 2.0F, this.doubleSlab.stepSound.getPitch() * 0.8F);
  185. --stack.stackSize;
  186. }
  187.  
  188. return true;
  189. }
  190. else
  191. {
  192. return false;
  193. }
  194. }
  195. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement