MinecraftScripterAI
Discord ↗
Link Copied to Clipboard
×
"how do i make a pickaxe that destroys 3x3 area"
To make a pickaxe that destroys a 3x3 area, you can override the `mineBlock` method in your custom pickaxe class. In this method, you can get the player's facing direction and mine the blocks in a 3x3 area based on that direction. Here's an example: ```java public class CustomPickaxe extends PickaxeItem { public CustomPickaxe(ToolMaterial material, int attackDamage, float attackSpeed, Item.Settings settings) { super(material, attackDamage, attackSpeed, settings); } @Override public boolean mineBlock(ItemStack stack, Level world, BlockState state, BlockPos pos, LivingEntity miner) { if (!world.isClientSide && state.getDestroySpeed(world, pos) != 0.0F) { stack.hurtAndBreak(1, miner, (player) -> player.broadcastBreakEvent(EquipmentSlot.MAINHAND)); Direction facing = miner.getDirection(); int startX = -1; int startY = facing == Direction.UP || facing == Direction.DOWN ? 0 : -1; int startZ = -1; int endX = 1; int endY = facing == Direction.UP || facing == Direction.DOWN ? 0 : 1; int endZ = 1; for (int x = startX; x <= endX; x++) { for (int y = startY; y <= endY; y++) { for (int z = startZ; z <= endZ; z++) { if (x == 0 && y == 0 && z == 0) continue; // Skip the center block as it's already mined BlockPos newPos = pos.offset(x, y, z); BlockState newState = world.getBlockState(newPos); if (newState.isDestroyable(world, newPos)) { world.destroyBlock(newPos, true, miner); } } } } } return true; } } ``` This code will create a custom pickaxe that mines a 3x3 area based on the player's facing direction. You can register this custom pickaxe in your mod just like any other item.