Advertisement
Guest User

Untitled

a guest
Jul 14th, 2016
276
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.66 KB | None | 0 0
  1. public class Hammer extends ItemPickaxe {
  2.  
  3. public Hammer(ToolMaterial toolMaterial, int durabillity) {
  4. super(toolMaterial);
  5. this.setMaxDamage(durabillity);
  6. }
  7.  
  8. @Override
  9. public boolean onBlockDestroyed(ItemStack stack, World worldIn, IBlockState state, BlockPos pos,
  10. EntityLivingBase entityLiving) {
  11. EnumFacing facing = entityLiving.getHorizontalFacing();
  12. Block block = state.getBlock();
  13. float headYaw = entityLiving.getRotationYawHead();
  14. if (facing == facing.NORTH) {
  15. for (int x = (pos.getX() - 1); x < (pos.getX() + 2); x++) {
  16. for (int y = (pos.getY() - 1); y < (pos.getY() + 2); y++) {
  17. if (!worldIn.isAirBlock(new BlockPos(x, y, pos.getZ()))
  18. && ((double) state.getBlockHardness(worldIn, new BlockPos(x, y, pos.getZ())) != 0.0D)) {
  19. if (state.getBlock().isToolEffective("pickaxe", state)) {
  20. stack.damageItem(1, entityLiving);
  21. } else {
  22. stack.damageItem(3, entityLiving);
  23. }
  24. }
  25. System.out.println("block: " + block.getHarvestLevel(state) + " item: " + stack.getItem().getHarvestLevel(stack, "pickaxe"));
  26. if (stack.getItem().getHarvestLevel(stack, "pickaxe") >= state.getBlock().getHarvestLevel(state)) {
  27. worldIn.destroyBlock(new BlockPos(x, y, pos.getZ()), true);
  28. } else {
  29. worldIn.setBlockToAir(new BlockPos(x, y, pos.getZ()));
  30. }
  31. }
  32. }
  33. }
  34. if (facing == facing.SOUTH) {
  35. for (int x = (pos.getX() - 1); x < (pos.getX() + 2); x++) {
  36. for (int y = (pos.getY() - 1); y < (pos.getY() + 2); y++) {
  37. if (!worldIn.isAirBlock(new BlockPos(x, y, pos.getZ()))
  38. && ((double) state.getBlockHardness(worldIn, new BlockPos(x, y, pos.getZ())) != 0.0D)) {
  39. if (state.getBlock().isToolEffective("pickaxe", state)) {
  40. stack.damageItem(1, entityLiving);
  41. } else {
  42. stack.damageItem(3, entityLiving);
  43. }
  44. }
  45. if (stack.getItem().getHarvestLevel(stack, "pickaxe") >= state.getBlock().getHarvestLevel(state)) {
  46. worldIn.destroyBlock(new BlockPos(x, y, pos.getZ()), true);
  47. } else {
  48. worldIn.setBlockToAir(new BlockPos(x, y, pos.getZ()));
  49. }
  50. }
  51. }
  52. }
  53. if (facing == facing.EAST) {
  54. for (int z = (pos.getZ() - 1); z < (pos.getZ() + 2); z++) {
  55. for (int y = (pos.getY() - 1); y < (pos.getY() + 2); y++) {
  56. if (!worldIn.isAirBlock(new BlockPos(pos.getX(), y, z))
  57. && ((double) state.getBlockHardness(worldIn, new BlockPos(pos.getX(), y, z)) != 0.0D)) {
  58. if (state.getBlock().isToolEffective("pickaxe", state)) {
  59. stack.damageItem(1, entityLiving);
  60. } else {
  61. stack.damageItem(3, entityLiving);
  62. }
  63. }
  64. if (stack.getItem().getHarvestLevel(stack, "pickaxe") >= state.getBlock().getHarvestLevel(state)) {
  65. worldIn.destroyBlock(new BlockPos(pos.getX(), y, z), true);
  66. } else {
  67. worldIn.setBlockToAir(new BlockPos(pos.getX(), y, z));
  68. }
  69. }
  70. }
  71. }
  72. if (facing == facing.WEST) {
  73. for (int z = (pos.getZ() - 1); z < (pos.getZ() + 2); z++) {
  74. for (int y = (pos.getY() - 1); y < (pos.getY() + 2); y++) {
  75. if (!worldIn.isAirBlock(new BlockPos(pos.getX(), y, z))
  76. && ((double) state.getBlockHardness(worldIn, new BlockPos(pos.getX(), y, z)) != 0.0D)) {
  77. if (state.getBlock().isToolEffective("pickaxe", state)) {
  78. stack.damageItem(1, entityLiving);
  79. } else {
  80. stack.damageItem(3, entityLiving);
  81. }
  82. }
  83. if (stack.getItem().getHarvestLevel(stack, "pickaxe") >= state.getBlock().getHarvestLevel(state)) {
  84. worldIn.destroyBlock(new BlockPos(pos.getX(), y, z), true);
  85. } else {
  86. worldIn.setBlockToAir(new BlockPos(pos.getX(), y, z));
  87. }
  88. }
  89. }
  90. }
  91. return true;
  92. }
  93.  
  94. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement