Jump to content

Tranzistor54

Members
  • Posts

    2
  • Joined

  • Last visited

Tranzistor54's Achievements

Tree Puncher

Tree Puncher (2/8)

0

Reputation

  1. how did you fix it?
  2. Hi. I am creating a hammer that will dig across the area. I was able to set up digging vertically, but I can't implement digging up or down. I know everyone uses RayTraceResult() but I don't understand how to use it. Here is what I have ready at the moment: public class Destroyer extends Item { public Destroyer(Properties properties) { super(properties); } @Override public boolean mineBlock(ItemStack stack, World world, BlockState state, BlockPos pos, LivingEntity entity) { Direction direction = entity.getDirection(); int xPos = pos.getX(), yPos = pos.getY(), zPos = pos.getZ(); if((direction == Direction.NORTH || direction == Direction.SOUTH) && state.getHarvestTool() == ToolType.PICKAXE && state.getHarvestLevel() <= 2) { for(int i = xPos - 1; i < xPos + 2; i++) { for(int j = yPos - 1; j < yPos + 2; j++) { BlockPos pos2 = new BlockPos(i, j, zPos); BlockState newState = world.getBlockState(pos2); if(newState.getHarvestTool() == ToolType.PICKAXE && newState.getHarvestLevel() <= 2) { world.destroyBlock(pos2, true); } } } if (!world.isClientSide && state.getDestroySpeed(world, pos) != 0.0F) { stack.hurtAndBreak(1, entity, (p_220038_0_) -> { p_220038_0_.broadcastBreakEvent(EquipmentSlotType.MAINHAND); }); } } if((direction == Direction.EAST || direction == Direction.WEST) && state.getHarvestTool() == ToolType.PICKAXE && state.getHarvestLevel() <= 2) { for(int i = zPos - 1; i < zPos + 2; i++) { for(int j = yPos - 1; j < yPos + 2; j++) { BlockPos pos2 = new BlockPos(xPos, j, i); BlockState newState = world.getBlockState(pos2); if(newState.getHarvestTool() == ToolType.PICKAXE && newState.getHarvestLevel() <= 2) { world.destroyBlock(pos2, true); } } } if (!world.isClientSide && state.getDestroySpeed(world, pos) != 0.0F) { stack.hurtAndBreak(1, entity, (p_220038_0_) -> { p_220038_0_.broadcastBreakEvent(EquipmentSlotType.MAINHAND); }); } } if(direction == Direction.UP || direction == Direction.DOWN && state.getHarvestTool() == ToolType.PICKAXE && state.getHarvestLevel() <= 2) { for(int i = xPos - 1; i < xPos + 2; i++) { for(int j = zPos -1; j < zPos + 2; j++) { BlockPos pos2 = new BlockPos(xPos, j, i); BlockState newState = world.getBlockState(pos2); if(newState.getHarvestTool() == ToolType.PICKAXE && newState.getHarvestLevel() <= 2) { world.destroyBlock(pos2, true); } } } if (!world.isClientSide && state.getDestroySpeed(world, pos) != 0.0F) { stack.hurtAndBreak(1, entity, (p_220038_0_) -> { p_220038_0_.broadcastBreakEvent(EquipmentSlotType.MAINHAND); }); } } return true; } @Override public float getDestroySpeed(ItemStack stack, BlockState state) { return state.getHarvestTool() == ToolType.PICKAXE && state.getHarvestLevel() <= 2 ? 12f : 1f; } @Override public boolean isDamageable(ItemStack stack) { return true; } @Override public boolean isCorrectToolForDrops(BlockState state) { return state.getHarvestTool() == ToolType.PICKAXE && state.getHarvestLevel() <= 2; } } At least I understood the problem. As it turns out, the player does not have an UP or DOWN direction, but what should I do then?
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.