Jaxon Akers

make a blue and purple pickaxe that digs 10 x 10 holes

Kodari AI
KodariOct 14 at 5:37 pm 7
VoidExcavator
A Fabric mod that adds a unique blue and purple pickaxe capable of mining a 10x10 area in a single swing. The tool features custom textures, enchantment compatibility, and configurable mining radius. Players can craft the pickaxe using rare materials, and it efficiently clears large areas while maintaining vanilla block-breaking mechanics. Includes durability management, particle effects on use, and proper integration with Fabric's tool system for seamless multiplayer support.
  1. Register a blue-and-purple pickaxe with a survival recipe and repair material.

  2. Hook block breaking so it clears a 10×10 area in the block’s face plane, with recursion and tool/drop checks.

Added the Astral Pickaxe with a blue-and-purple custom texture. It clears a 10×10 area perpendicular to the direction you’re facing, preserves drops, and spends durability for each additional block.

Craft it with 1 diamond, 2 amethyst shards, and 2 sticks. It has diamond-tier stats and can be repaired with amethyst shards.

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
gradle.properties
settings.gradle
Code
10 194
src/main/java/com/kodari/riftpick/AstralPickaxeMod.java
package com.kodari.riftpick;

import net.fabricmc.api.ModInitializer;
import net.fabricmc.fabric.api.creativetab.v1.CreativeModeTabEvents;
import net.fabricmc.fabric.api.event.player.PlayerBlockBreakEvents;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.core.Registry;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.core.registries.Registries;
import net.minecraft.resources.Identifier;
import net.minecraft.resources.ResourceKey;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.tags.BlockTags;
import net.minecraft.world.entity.EquipmentSlot;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.CreativeModeTab;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Items;
import net.minecraft.world.item.ToolMaterial;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.state.BlockState;

public final class AstralPickaxeMod implements ModInitializer {
	public static final String MOD_ID = "riftpick";

	private static final ResourceKey<Item> ASTRAL_PICKAXE_KEY = ResourceKey.create(
			Registries.ITEM,
			Identifier.fromNamespaceAndPath(MOD_ID, "astral_pickaxe")
	);
	private static final ResourceKey<CreativeModeTab> TOOLS_TAB_KEY = ResourceKey.create(
			Registries.CREATIVE_MODE_TAB,
			Identifier.fromNamespaceAndPath("minecraft", "tools_and_utilities")
	);

	public static final Item ASTRAL_PICKAXE = Registry.register(
			BuiltInRegistries.ITEM,
			ASTRAL_PICKAXE_KEY,
			new Item(new Item.Properties()
					.pickaxe(ToolMaterial.DIAMOND, 1.0F, -2.8F)
					.repairable(Items.AMETHYST_SHARD)
					.setId(ASTRAL_PICKAXE_KEY))
	);

	@Override
	public void onInitialize() {
		CreativeModeTabEvents.modifyOutputEvent(TOOLS_TAB_KEY).register(output -> output.accept(ASTRAL_PICKAXE));
		PlayerBlockBreakEvents.AFTER.register(AstralPickaxeMod::afterBlockBreak);
	}

	private static void afterBlockBreak(Level level, Player player, BlockPos origin, BlockState brokenState, BlockEntity blockEntity) {
		if (!(level instanceof ServerLevel serverLevel)) {
			return;
		}

		ItemStack tool = player.getMainHandItem();
		if (tool.getItem() != ASTRAL_PICKAXE) {
			return;
		}

		Direction facing = player.getDirection();
		boolean facingEastWest = facing == Direction.EAST || facing == Direction.WEST;

		for (int horizontal = -4; horizontal <= 5; horizontal++) {
			for (int vertical = -4; vertical <= 5; vertical++) {
				if (tool.isEmpty()) {
					return;
				}
				if (horizontal == 0 && vertical == 0) {
					continue;
				}

				BlockPos target = facingEastWest
						? origin.offset(0, vertical, horizontal)
						: origin.offset(horizontal, vertical, 0);
				BlockState state = serverLevel.getBlockState(target);
				if (!state.is(BlockTags.MINEABLE_WITH_PICKAXE)
						|| state.getDestroySpeed(serverLevel, target) <= 0.0F
						|| !player.hasCorrectToolForDrops(state)) {
					continue;
				}

				BlockEntity targetBlockEntity = serverLevel.getBlockEntity(target);
				if (serverLevel.destroyBlock(target, false, player, 512)) {
					Block.dropResources(state, serverLevel, target, targetBlockEntity, player, tool);
					tool.hurtAndBreak(1, player, EquipmentSlot.MAINHAND);
				}
			}
		}
	}
}