Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Tranzistor54

Members
  • Joined

  • Last visited

  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?

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.