giako0151_78234

Create a plugin With pickaxe but with the ability to dig a 3x3 area and It has to be like an amethyst pickaxe and It has to be crafted like normale pickaxe but With amethyst

Kodari AI
KodariJun 24 at 11:44 pm 6
AmethystPickaxe
Adds a custom Amethyst Pickaxe that mines a 3×3 area. Crafted in the same shape as a standard pickaxe using Amethyst Shards and Sticks. The pickaxe is identified by a persistent data tag and visually styled with a purple amethyst theme. When breaking any non-air block, it automatically breaks all 8 surrounding blocks in the same plane relative to the player's facing direction, dropping all items naturally.

Planning classes before writing:

  • AmethystPickaxePlugin — registers recipe, listener, manager

  • PickaxeManager — creates item with PDC tag, checks if item is the custom pickaxe

  • MiningListener — 3×3 block break logic using player face orientation

  • plugin.yml


What was built:

File
Purpose
AmethystPickaxePlugin
Registers the shaped recipe and the mining listener on enable
PickaxeManager
Creates the custom
DIAMOND_PICKAXE
base item with a PDC tag for reliable identification, pre-enchanted with Efficiency III + Unbreaking II
MiningListener
On
BlockBreakEvent
, determines the face the player is mining toward (using pitch + yaw), then breaks all 8 surrounding blocks in that plane naturally so drops appear

Crafting recipe (Amethyst Shards + Sticks):

Plain Text
◈ ◈ ◈
  |  
  |  

How the 3×3 works: the listener reads the player’s pitch to detect vertical mining (ceiling/floor → XZ plane) and yaw for horizontal mining (wall → XY or ZY plane), so the 3×3 always aligns to the surface being mined regardless of direction.

Kodari can make mistakes. Review important code before using.
Files
src
Code
4 221
src/main/java/com/kodari/amethystpickaxe/AmethystPickaxePlugin.java
package com.kodari.amethystpickaxe;

import com.kodari.amethystpickaxe.listener.MiningListener;
import com.kodari.amethystpickaxe.manager.PickaxeManager;
import com.cryptomorin.xseries.XMaterial;
import org.bukkit.NamespacedKey;
import org.bukkit.inventory.ShapedRecipe;
import org.bukkit.plugin.java.JavaPlugin;

public class AmethystPickaxePlugin extends JavaPlugin {

    private PickaxeManager pickaxeManager;

    @Override
    public void onEnable() {
        pickaxeManager = new PickaxeManager(this);

        registerRecipe();
        getServer().getPluginManager().registerEvents(new MiningListener(pickaxeManager), this);

        getLogger().info("AmethystPickaxe enabled.");
    }

    @Override
    public void onDisable() {
        getLogger().info("AmethystPickaxe disabled.");
    }

    private void registerRecipe() {
        NamespacedKey key = new NamespacedKey(this, "amethyst_pickaxe");
        ShapedRecipe recipe = new ShapedRecipe(key, pickaxeManager.createPickaxe());
        recipe.shape("AAA", " S ", " S ");

        XMaterial.matchXMaterial("AMETHYST_SHARD").map(XMaterial::parseMaterial).ifPresent(shard ->
                recipe.setIngredient('A', shard));
        XMaterial.matchXMaterial("STICK").map(XMaterial::parseMaterial).ifPresent(stick ->
                recipe.setIngredient('S', stick));

        getServer().addRecipe(recipe);
    }

    public PickaxeManager getPickaxeManager() {
        return pickaxeManager;
    }
}