Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Hammer extends ItemPickaxe {
- public Hammer(ToolMaterial toolMaterial, int durabillity) {
- super(toolMaterial);
- this.setMaxDamage(durabillity);
- }
- @Override
- public boolean onBlockDestroyed(ItemStack stack, World worldIn, IBlockState state, BlockPos pos,
- EntityLivingBase entityLiving) {
- EnumFacing facing = entityLiving.getHorizontalFacing();
- Block block = state.getBlock();
- float headYaw = entityLiving.getRotationYawHead();
- if (facing == facing.NORTH) {
- for (int x = (pos.getX() - 1); x < (pos.getX() + 2); x++) {
- for (int y = (pos.getY() - 1); y < (pos.getY() + 2); y++) {
- if (!worldIn.isAirBlock(new BlockPos(x, y, pos.getZ()))
- && ((double) state.getBlockHardness(worldIn, new BlockPos(x, y, pos.getZ())) != 0.0D)) {
- if (state.getBlock().isToolEffective("pickaxe", state)) {
- stack.damageItem(1, entityLiving);
- } else {
- stack.damageItem(3, entityLiving);
- }
- }
- System.out.println("block: " + block.getHarvestLevel(state) + " item: " + stack.getItem().getHarvestLevel(stack, "pickaxe"));
- if (stack.getItem().getHarvestLevel(stack, "pickaxe") >= state.getBlock().getHarvestLevel(state)) {
- worldIn.destroyBlock(new BlockPos(x, y, pos.getZ()), true);
- } else {
- worldIn.setBlockToAir(new BlockPos(x, y, pos.getZ()));
- }
- }
- }
- }
- if (facing == facing.SOUTH) {
- for (int x = (pos.getX() - 1); x < (pos.getX() + 2); x++) {
- for (int y = (pos.getY() - 1); y < (pos.getY() + 2); y++) {
- if (!worldIn.isAirBlock(new BlockPos(x, y, pos.getZ()))
- && ((double) state.getBlockHardness(worldIn, new BlockPos(x, y, pos.getZ())) != 0.0D)) {
- if (state.getBlock().isToolEffective("pickaxe", state)) {
- stack.damageItem(1, entityLiving);
- } else {
- stack.damageItem(3, entityLiving);
- }
- }
- if (stack.getItem().getHarvestLevel(stack, "pickaxe") >= state.getBlock().getHarvestLevel(state)) {
- worldIn.destroyBlock(new BlockPos(x, y, pos.getZ()), true);
- } else {
- worldIn.setBlockToAir(new BlockPos(x, y, pos.getZ()));
- }
- }
- }
- }
- if (facing == facing.EAST) {
- for (int z = (pos.getZ() - 1); z < (pos.getZ() + 2); z++) {
- for (int y = (pos.getY() - 1); y < (pos.getY() + 2); y++) {
- if (!worldIn.isAirBlock(new BlockPos(pos.getX(), y, z))
- && ((double) state.getBlockHardness(worldIn, new BlockPos(pos.getX(), y, z)) != 0.0D)) {
- if (state.getBlock().isToolEffective("pickaxe", state)) {
- stack.damageItem(1, entityLiving);
- } else {
- stack.damageItem(3, entityLiving);
- }
- }
- if (stack.getItem().getHarvestLevel(stack, "pickaxe") >= state.getBlock().getHarvestLevel(state)) {
- worldIn.destroyBlock(new BlockPos(pos.getX(), y, z), true);
- } else {
- worldIn.setBlockToAir(new BlockPos(pos.getX(), y, z));
- }
- }
- }
- }
- if (facing == facing.WEST) {
- for (int z = (pos.getZ() - 1); z < (pos.getZ() + 2); z++) {
- for (int y = (pos.getY() - 1); y < (pos.getY() + 2); y++) {
- if (!worldIn.isAirBlock(new BlockPos(pos.getX(), y, z))
- && ((double) state.getBlockHardness(worldIn, new BlockPos(pos.getX(), y, z)) != 0.0D)) {
- if (state.getBlock().isToolEffective("pickaxe", state)) {
- stack.damageItem(1, entityLiving);
- } else {
- stack.damageItem(3, entityLiving);
- }
- }
- if (stack.getItem().getHarvestLevel(stack, "pickaxe") >= state.getBlock().getHarvestLevel(state)) {
- worldIn.destroyBlock(new BlockPos(pos.getX(), y, z), true);
- } else {
- worldIn.setBlockToAir(new BlockPos(pos.getX(), y, z));
- }
- }
- }
- }
- return true;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement