jfyivan

can you creat a mod that spots large amythest clusters and puts a purple glowing box i can see from thousands of blocks away. make it so when I press u a menu opens up alowing me to toggle or deactivate it

Kodari AI
KodariOct 12 at 2:58 am 4
AmethystClusterLocator
A Minecraft Fabric mod that detects large amethyst clusters within a configurable radius and displays a purple glowing beacon box visible from thousands of blocks away. Pressing the U key opens a menu allowing players to toggle the feature on/off, adjust detection radius, and customize beacon visibility settings for optimal long-distance spotting.
  1. Detect amethyst geodes as chunks load and retain their locations.

  2. Render purple bounding boxes for detected geodes.

  3. Add a U-key owo menu to enable or deactivate highlighting.

Created Amethyst Finder for Fabric 1.21.11. Press U to open its owo-ui menu, toggle markers, or deactivate them.

It scans chunks as they load for budding amethyst, draws purple outlines around detected geodes, and shows a glowing HUD marker pointing to the nearest one—even when it’s thousands of blocks away. Markers are remembered only for the current world session.

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
gradle.properties
manifest.kod
settings.gradle
Code
9 377
src/client/java/com/kodari/amethystfinder/client/AmethystFinderClient.java
package com.kodari.amethystfinder.client;

import net.fabricmc.api.ClientModInitializer;
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientChunkEvents;
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents;
import net.fabricmc.fabric.api.client.keybinding.v1.KeyBindingHelper;
import net.fabricmc.fabric.api.client.rendering.v1.hud.HudElementRegistry;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.option.KeyBinding;
import net.minecraft.text.Text;
import net.minecraft.util.Identifier;
import net.minecraft.util.math.Box;
import org.lwjgl.glfw.GLFW;

public final class AmethystFinderClient implements ClientModInitializer {

    private static final String MOD_ID = "amethystfinder";
    private static final KeyBinding OPEN_MENU = KeyBindingHelper.registerKeyBinding(
            new KeyBinding(
                    "key.amethystfinder.menu",
                    GLFW.GLFW_KEY_U,
                    KeyBinding.Category.create(Identifier.of(MOD_ID, "main"))
            )
    );

    private static boolean enabled = true;

    @Override
    public void onInitializeClient() {
        ClientChunkEvents.CHUNK_LOAD.register(GeodeTracker::scan);
        ClientTickEvents.END_CLIENT_TICK.register(client -> {
            GeodeTracker.useWorld(client.world);
            while (OPEN_MENU.wasPressed()) {
                client.setScreen(new GeodeMarkerScreen());
            }
        });
        HudElementRegistry.addLast(Identifier.of(MOD_ID, "geode_direction"), AmethystFinderClient::renderHudMarker);
    }

    public static boolean isEnabled() {
        return enabled;
    }

    public static void setEnabled(boolean value) {
        enabled = value;
    }

    private static void renderHudMarker(DrawContext context, net.minecraft.client.render.RenderTickCounter tickCounter) {
        MinecraftClient client = MinecraftClient.getInstance();
        if (!enabled || client.world == null || client.player == null || GeodeTracker.markers().isEmpty()) {
            return;
        }

        Box nearest = null;
        double nearestDistanceSquared = Double.MAX_VALUE;
        for (Box marker : GeodeTracker.markers()) {
            double dx = (marker.minX + marker.maxX) * 0.5 - client.player.getX();
            double dy = (marker.minY + marker.maxY) * 0.5 - client.player.getY();
            double dz = (marker.minZ + marker.maxZ) * 0.5 - client.player.getZ();
            double distanceSquared = dx * dx + dy * dy + dz * dz;
            if (distanceSquared < nearestDistanceSquared) {
                nearestDistanceSquared = distanceSquared;
                nearest = marker;
            }
        }

        if (nearest == null) {
            return;
        }

        double targetX = (nearest.minX + nearest.maxX) * 0.5;
        double targetZ = (nearest.minZ + nearest.maxZ) * 0.5;
        double dx = targetX - client.player.getX();
        double dz = targetZ - client.player.getZ();
        double targetYaw = Math.toDegrees(Math.atan2(dx, dz));
        double relativeYaw = ((targetYaw - client.player.getYaw() + 540) % 360) - 180;
        double maxOffset = Math.min(context.getScaledWindowWidth() * 0.38, 220);
        double horizontalOffset;
        if (Math.abs(relativeYaw) <= 90) {
            horizontalOffset = Math.sin(Math.toRadians(relativeYaw)) * maxOffset;
        } else {
            horizontalOffset = Math.copySign(maxOffset, relativeYaw);
        }

        int centerX = context.getScaledWindowWidth() / 2 + (int) Math.round(horizontalOffset);
        int x = Math.clamp(centerX - 7, 8, context.getScaledWindowWidth() - 22);
        int y = 34;
        context.fill(x - 5, y - 5, x + 19, y + 19, 0x553900FF);
        context.fill(x - 2, y - 2, x + 16, y + 16, 0xAA9E35FF);
        context.fill(x, y, x + 14, y + 14, 0xFFFF78FF);
        context.fill(x + 4, y + 4, x + 10, y + 10, 0xFFFFFFFF);

        int distance = (int) Math.round(Math.sqrt(nearestDistanceSquared));
        context.drawTextWithShadow(
                client.textRenderer,
                Text.literal("Amethyst geode · " + distance + " blocks"),
                Math.max(4, x - 48),
                y + 20,
                0xFFFFD8FF
        );
    }
}