Trọng nhân

Create a Minecraft mod for version 1.21.11 with a GUI that opens on right shift, stronghold finder(use one eye of ender look at this and this can show u coordinates of stronghold in the chat), true sight( can see invisible and barrierblock), jumpreset(Jump when getting hit by someone at the same time), regen(Regen accelerates the player's natural health regeneration beyond the vanilla rate), FPSboost

Kodari AI
KodariOct 31 at 10:48 am 4
UtilitySuiteMod
A Fabric mod for Minecraft 1.21.11 adding a GUI opened by right-shift. Features a stronghold finder using an eye of ender to display coordinates in chat, true sight revealing invisible entities and barrier blocks, jump reset on hit timing, accelerated natural health regeneration, and FPS optimization tweaks.
  1. Set up the Fabric 1.21.11 client mod and right-Shift owo settings screen.

  2. Implement stronghold triangulation, true sight, jump reset, accelerated regeneration, and FPS options.

  3. Add the required mixin, metadata, and bundled-library manifest.

Created Stronghold Tools for Fabric 1.21.11. Press Right Shift in game to open the settings GUI.

  • Stronghold finder: throw two Eyes of Ender from different positions to estimate the stronghold coordinates in chat.

  • True sight: reveals invisible entities and renders barrier blocks.

  • Jump reset: jumps when you take damage while grounded.

  • Accelerated regeneration: adds a server-side healing tick while you meet vanilla’s food requirement. It works in singleplayer; the toggle is not synchronized to a separate multiplayer server.

  • FPS boost: lowers particles, clouds, biome blending, and render distance; restores those settings when turned off.

No new items were added, so there’s nothing to obtain in survival.

Kodari can make mistakes. Review important code before using.
Files
src
hello
manifest.kod
Code
10 380
src/client/java/dev/kodari/strongholdtools/StrongholdToolsClient.java
package dev.kodari.strongholdtools;

import dev.kodari.strongholdtools.ui.FeatureScreen;
import net.fabricmc.api.ClientModInitializer;
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents;
import net.fabricmc.fabric.api.client.keybinding.v1.KeyBindingHelper;
import net.fabricmc.fabric.api.event.player.UseItemCallback;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.option.CloudRenderMode;
import net.minecraft.client.option.KeyBinding;
import net.minecraft.client.option.SimpleOption;
import net.minecraft.client.util.InputUtil;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EyeOfEnderEntity;
import net.minecraft.item.Items;
import net.minecraft.particle.ParticlesMode;
import net.minecraft.text.Text;
import net.minecraft.util.ActionResult;
import net.minecraft.util.Identifier;
import net.minecraft.util.math.Vec3d;
import net.minecraft.world.World;

import java.util.ArrayDeque;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;

public final class StrongholdToolsClient implements ClientModInitializer {
    private static final KeyBinding OPEN_MENU = KeyBindingHelper.registerKeyBinding(new KeyBinding(
            "key.strongholdtools.open_menu",
            InputUtil.GLFW_KEY_RIGHT_SHIFT,
            KeyBinding.Category.create(Identifier.of("strongholdtools", "main"))
    ));

    private static final ArrayDeque<EyeOrigin> pendingEyeUses = new ArrayDeque<>();
    private static final Set<Integer> seenEyeIds = new HashSet<>();
    private static final Map<Integer, PendingEye> eyesAwaitingDirection = new HashMap<>();

    private static World observedWorld;
    private static EyeRay firstRay;
    private static int pendingEyeTicks;
    private static int previousHurtTime;
    private static ParticlesMode previousParticles;
    private static CloudRenderMode previousClouds;
    private static Integer previousBiomeBlend;
    private static Integer previousViewDistance;
    private static Integer previousMaxFps;

    @Override
    public void onInitializeClient() {
        ClientTickEvents.END_CLIENT_TICK.register(StrongholdToolsClient::onEndTick);
        UseItemCallback.EVENT.register((player, world, hand) -> {
            if (world.isClient() && player == MinecraftClient.getInstance().player
                    && player.getStackInHand(hand).isOf(Items.ENDER_EYE)) {
                pendingEyeUses.addLast(new EyeOrigin(player.getX(), player.getZ()));
                pendingEyeTicks = 80;
            }
            return ActionResult.PASS;
        });
    }

    private static void onEndTick(MinecraftClient client) {
        while (OPEN_MENU.wasPressed()) {
            client.setScreen(new FeatureScreen());
        }

        if (client.world != observedWorld) {
            observedWorld = client.world;
            pendingEyeUses.clear();
            seenEyeIds.clear();
            eyesAwaitingDirection.clear();
            firstRay = null;
            pendingEyeTicks = 0;
        }

        if (client.world == null || client.player == null) {
            previousHurtTime = 0;
            return;
        }

        if (pendingEyeTicks > 0 && --pendingEyeTicks == 0) {
            pendingEyeUses.clear();
        }

        for (Entity entity : client.world.getEntities()) {
            if (!(entity instanceof EyeOfEnderEntity eye) || !seenEyeIds.add(eye.getId())) {
                continue;
            }
            if (!pendingEyeUses.isEmpty()) {
                eyesAwaitingDirection.put(eye.getId(), new PendingEye(eye, pendingEyeUses.removeFirst()));
            }
        }

        Iterator<Map.Entry<Integer, PendingEye>> eyes = eyesAwaitingDirection.entrySet().iterator();
        while (eyes.hasNext()) {
            PendingEye pending = eyes.next().getValue();
            Vec3d velocity = pending.eye().getVelocity();
            double horizontalSpeed = Math.hypot(velocity.x, velocity.z);
            if (horizontalSpeed < 0.001) {
                continue;
            }

            EyeOrigin origin = pending.origin();
            EyeRay ray = new EyeRay(origin.x(), origin.z(), velocity.x / horizontalSpeed, velocity.z / horizontalSpeed);
            eyes.remove();
            handleRay(client, ray);
        }

        int hurtTime = client.player.hurtTime;
        if (FeatureState.jumpReset && hurtTime > previousHurtTime && client.player.isOnGround()) {
            client.player.jump();
        }
        previousHurtTime = hurtTime;
    }

    private static void handleRay(MinecraftClient client, EyeRay ray) {
        if (firstRay == null) {
            firstRay = ray;
            chat(client, "Stronghold finder: first eye tracked. Throw another from a different position.");
            return;
        }

        double denominator = cross(firstRay.dx(), firstRay.dz(), ray.dx(), ray.dz());
        if (Math.abs(denominator) < 0.04) {
            firstRay = ray;
            chat(client, "Stronghold finder: bearings were too parallel; use another eye from a new position.");
            return;
        }

        double offsetX = ray.x() - firstRay.x();
        double offsetZ = ray.z() - firstRay.z();
        double distance = cross(offsetX, offsetZ, ray.dx(), ray.dz()) / denominator;
        double otherDistance = cross(offsetX, offsetZ, firstRay.dx(), firstRay.dz()) / denominator;
        if (distance < 0 || otherDistance < 0) {
            firstRay = ray;
            chat(client, "Stronghold finder: the eye paths did not meet ahead; use another eye from a new position.");
            return;
        }

        int x = (int) Math.floor(firstRay.x() + distance * firstRay.dx());
        int z = (int) Math.floor(firstRay.z() + distance * firstRay.dz());
        firstRay = null;
        chat(client, "Stronghold estimate: X " + x + ", Z " + z + " (surface coordinates)");
    }

    private static double cross(double ax, double az, double bx, double bz) {
        return ax * bz - az * bx;
    }

    private static void chat(MinecraftClient client, String message) {
        client.inGameHud.getChatHud().addMessage(Text.literal(message));
    }

    public static void setFpsBoost(MinecraftClient client, boolean enabled) {
        if (FeatureState.fpsBoost == enabled) {
            return;
        }

        if (enabled) {
            previousParticles = client.options.getParticles().getValue();
            previousClouds = client.options.getCloudRenderMode().getValue();
            previousBiomeBlend = client.options.getBiomeBlendRadius().getValue();
            previousViewDistance = client.options.getViewDistance().getValue();
            previousMaxFps = client.options.getMaxFps().getValue();

            client.options.getParticles().setValue(ParticlesMode.MINIMAL);
            client.options.getCloudRenderMode().setValue(CloudRenderMode.OFF);
            client.options.getBiomeBlendRadius().setValue(0);
            client.options.getViewDistance().setValue(Math.min(previousViewDistance, 8));
            client.options.getMaxFps().setValue(260);
        } else {
            client.options.getParticles().setValue(previousParticles);
            client.options.getCloudRenderMode().setValue(previousClouds);
            client.options.getBiomeBlendRadius().setValue(previousBiomeBlend);
            client.options.getViewDistance().setValue(previousViewDistance);
            client.options.getMaxFps().setValue(previousMaxFps);
        }
        FeatureState.fpsBoost = enabled;
    }

    private record EyeOrigin(double x, double z) {
    }

    private record PendingEye(EyeOfEnderEntity eye, EyeOrigin origin) {
    }

    private record EyeRay(double x, double z, double dx, double dz) {
    }
}