Miki

Create KacperClient for Minecraft Java 1.21.4 using Fabric. Build a working client-side mod with a dark blue GUI opened by Right Shift, FPS and coordinates HUD, sprint toggle, module toggles, and customizable keybinds. Build and test the JAR.

Kodari AI
KodariOct 9 at 3:38 pm 3
KacperClient
Client-side Fabric mod for Minecraft 1.21.4 featuring a dark blue GUI toggled by Right Shift, displaying FPS and coordinates HUD, sprint toggle, module toggles, and customizable keybinds. Includes mixin-based rendering, keybinding registration, and configurable settings for an enhanced gameplay experience.
  1. Register the client entrypoint and keybinds.

  2. Add a Right Shift screen with module toggles and key rebinding.

  3. Render FPS/coordinates and apply sprint toggle on client ticks.

  4. Add Fabric metadata, then use Kodari’s Compile flow to build and download the JAR.

Created KacperClient as a client-only Fabric 1.21.4 mod. Right Shift opens its dark-blue menu; the FPS/coordinates HUD starts enabled, and H and J toggle the HUD and sprint module. Click the key rows in the menu to rebind them. Sprint engages while you’re moving forward.

To build and download the JAR in Kodari:

  1. Click Compile in the desktop top bar, or on phone tap ⋮ → Compile Project.

  2. Click Compile in the build window.

  3. When it succeeds, click Download on the build or Download kacperclient.jar in the chat.

I haven’t run an in-game test here.

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
gradle.properties
settings.gradle
Code
6 263
src/main/java/com/kacperclient/KacperClient.java
package com.kacperclient;

import java.util.Locale;

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.client.rendering.v1.HudRenderCallback;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.font.TextRenderer;
import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.option.KeyBinding;
import net.minecraft.client.util.InputUtil;
import net.minecraft.text.Text;

public final class KacperClient implements ClientModInitializer {
    private static final String KEY_CATEGORY = "category.kacperclient";
    private static final KeyBinding OPEN_GUI_KEY = KeyBindingHelper.registerKeyBinding(new KeyBinding(
            "key.kacperclient.open_gui", InputUtil.Type.KEYSYM, 344, KEY_CATEGORY));
    private static final KeyBinding TOGGLE_HUD_KEY = KeyBindingHelper.registerKeyBinding(new KeyBinding(
            "key.kacperclient.toggle_hud", InputUtil.Type.KEYSYM, 72, KEY_CATEGORY));
    private static final KeyBinding TOGGLE_SPRINT_KEY = KeyBindingHelper.registerKeyBinding(new KeyBinding(
            "key.kacperclient.toggle_sprint", InputUtil.Type.KEYSYM, 74, KEY_CATEGORY));

    private static boolean hudEnabled = true;
    private static boolean sprintEnabled;

    @Override
    public void onInitializeClient() {
        ClientTickEvents.END_CLIENT_TICK.register(client -> {
            while (OPEN_GUI_KEY.wasPressed()) {
                if (client.currentScreen == null) {
                    client.setScreen(new ConfigScreen());
                } else if (client.currentScreen instanceof ConfigScreen) {
                    client.setScreen(null);
                }
            }

            while (TOGGLE_HUD_KEY.wasPressed()) {
                if (client.currentScreen == null) {
                    hudEnabled = !hudEnabled;
                }
            }
            while (TOGGLE_SPRINT_KEY.wasPressed()) {
                if (client.currentScreen == null) {
                    sprintEnabled = !sprintEnabled;
                }
            }

            if (client.player != null && client.currentScreen == null && sprintEnabled
                    && client.options.forwardKey.isPressed()) {
                client.player.setSprinting(true);
            }
        });

        HudRenderCallback.EVENT.register((context, tickCounter) -> {
            MinecraftClient client = MinecraftClient.getInstance();
            if (!hudEnabled || client.player == null) {
                return;
            }

            TextRenderer textRenderer = client.textRenderer;
            context.drawTextWithShadow(textRenderer, Text.literal("FPS: " + client.getCurrentFps()), 8, 8, 0xFFFFFF);
            context.drawTextWithShadow(textRenderer, Text.literal(String.format(Locale.ROOT,
                    "XYZ: %.1f / %.1f / %.1f", client.player.getX(), client.player.getY(), client.player.getZ())),
                    8, 20, 0xFFFFFF);
        });
    }

    private static final class ConfigScreen extends Screen {
        private static final int PANEL_WIDTH = 300;
        private static final int PANEL_HEIGHT = 230;
        private static final int BUTTON_LEFT_INSET = 12;
        private static final int BUTTON_RIGHT_INSET = 288;

        private KeyBinding bindingToChange;

        private ConfigScreen() {
            super(Text.literal("KacperClient"));
        }

        @Override
        public void render(DrawContext context, int mouseX, int mouseY, float delta) {
            context.fill(0, 0, width, height, 0xA0081020);

            int left = panelLeft();
            int top = panelTop();
            context.fill(left, top, left + PANEL_WIDTH, top + PANEL_HEIGHT, 0xFF111B2B);
            context.fill(left, top, left + PANEL_WIDTH, top + 3, 0xFF397CC1);
            context.drawCenteredTextWithShadow(textRenderer, Text.literal("KacperClient"), width / 2, top + 12,
                    0xFFFFFFFF);

            drawButton(context, left, top + 39,
                    Text.literal("FPS / coordinates HUD: " + (hudEnabled ? "ON" : "OFF")), hudEnabled);
            drawButton(context, left, top + 66,
                    Text.literal("Sprint module: " + (sprintEnabled ? "ON" : "OFF")), sprintEnabled);

            drawBindingButton(context, left, top + 103, "Open GUI", OPEN_GUI_KEY);
            drawBindingButton(context, left, top + 132, "Toggle HUD", TOGGLE_HUD_KEY);
            drawBindingButton(context, left, top + 161, "Toggle sprint", TOGGLE_SPRINT_KEY);

            context.drawCenteredTextWithShadow(textRenderer, Text.literal("Click a key row to rebind  |  Esc closes"),
                    width / 2, top + 201, 0xFF9BAFC7);
        }

        @Override
        public boolean mouseClicked(double mouseX, double mouseY, int button) {
            if (button != 0) {
                return super.mouseClicked(mouseX, mouseY, button);
            }

            int left = panelLeft();
            int top = panelTop();
            if (insidePanelButton(mouseX, mouseY, left, top + 39)) {
                hudEnabled = !hudEnabled;
                return true;
            }
            if (insidePanelButton(mouseX, mouseY, left, top + 66)) {
                sprintEnabled = !sprintEnabled;
                return true;
            }
            if (insidePanelButton(mouseX, mouseY, left, top + 103)) {
                bindingToChange = OPEN_GUI_KEY;
                return true;
            }
            if (insidePanelButton(mouseX, mouseY, left, top + 132)) {
                bindingToChange = TOGGLE_HUD_KEY;
                return true;
            }
            if (insidePanelButton(mouseX, mouseY, left, top + 161)) {
                bindingToChange = TOGGLE_SPRINT_KEY;
                return true;
            }
            return super.mouseClicked(mouseX, mouseY, button);
        }

        @Override
        public boolean keyPressed(int keyCode, int scanCode, int modifiers) {
            if (bindingToChange != null) {
                if (keyCode == 256) {
                    bindingToChange = null;
                    return true;
                }
                bindingToChange.setBoundKey(InputUtil.fromKeyCode(keyCode, scanCode));
                KeyBinding.updateKeysByCode();
                bindingToChange = null;
                return true;
            }

            if (keyCode == 256) {
                client.setScreen(null);
                return true;
            }
            return super.keyPressed(keyCode, scanCode, modifiers);
        }

        @Override
        public boolean shouldPause() {
            return false;
        }

        private void drawBindingButton(DrawContext context, int left, int y, String label, KeyBinding keyBinding) {
            boolean selected = bindingToChange == keyBinding;
            Text text = selected
                    ? Text.literal(label + ": press a key (Esc cancels)")
                    : Text.literal(label + ": ").append(keyBinding.getBoundKeyLocalizedText());
            drawButton(context, left, y, text, selected);
        }

        private void drawButton(DrawContext context, int left, int y, Text label, boolean active) {
            int color = active ? 0xFF174B75 : 0xFF26364A;
            context.fill(left + BUTTON_LEFT_INSET, y, left + BUTTON_RIGHT_INSET, y + 23, color);
            context.drawCenteredTextWithShadow(textRenderer, label, width / 2, y + 7, 0xFFFFFFFF);
        }

        private boolean insidePanelButton(double mouseX, double mouseY, int left, int y) {
            return mouseX >= left + BUTTON_LEFT_INSET && mouseX <= left + BUTTON_RIGHT_INSET
                    && mouseY >= y && mouseY <= y + 23;
        }

        private int panelLeft() {
            return Math.max(8, (width - PANEL_WIDTH) / 2);
        }

        private int panelTop() {
            return Math.max(8, (height - PANEL_HEIGHT) / 2);
        }
    }
}