4X KAGE
📎 1 file 1,201 chars
📄
pasted-code-1789126639092.txt
txt 15 lines
▶
Create a Minecraft Mod specifically targeting Minecraft 26.2 using the Fabric Mod Loader and Fabric API (version fabric-api-0.159.0+26.2).

Core Concept:
Modify standard mouse button inputs so that mouse clicks (Left-Click for Attack/Break, Right-Click for Place/Use) behave exactly like keyboard keypresses in terms of input handling.

Key Features & Requirements:
1. Input Mechanics: Override default Minecraft mouse click logic so mouse button actions trigger using the same direct, responsive key registration as keyboard keybinds.
2. Zero Input Delay / CPS Throttling Bypass: Eliminate or minimize built-in mouse click delays or CPS cooldowns for placing and attacking, matching the behavior of holding down/pressing keyboard keys.
3. Compatibility Target:
   - Minecraft Version: 26.2 (Java Edition)
   - Mod Loader: Fabric
   - Dependencies: Fabric API (fabric-api-0.159.0+26.2)
4. GUI Safety & Configuration: Ensure standard inventory/GUI clicking remains unaffected and provide a basic config toggle to enable/disable the feature in-game.

Please generate clean, functional Java code using Mixins or Fabric API input hooks compatible with standard Fabric 26.2 development setup.
Kodari AI
KodariSep 11 at 11:43 am 2
MouseKeyInput
MouseKeyInput is a Fabric mod for Minecraft 26.2 that transforms mouse button clicks into direct keyboard-style input handling. It overrides default mouse click logic to eliminate built-in click delays and CPS throttling for attacking and block placement, making mouse actions as responsive as keypresses. The mod uses Mixins to intercept input processing while preserving standard inventory and GUI click behavior. A configurable in-game toggle allows players to enable or disable the enhanced input system at any time. Compatible with Fabric API 0.159.0+26.2, this mod provides a seamless, zero-delay combat and building experience without affecting normal interface interactions.
  1. Set up the Fabric 26.2/Java 25 project and metadata.

  2. Add a client-only input mixin that routes eligible mouse actions through key-state handling without affecting GUI screens.

  3. Add a persisted in-game toggle and keybind, then wire resources and configuration defaults.

Created the Fabric 26.2 client mod project.

  • Uses Fabric Loader 0.19.3, Fabric API 0.159.0+26.2, Loom 1.17, and Java 25.

  • Routes world left/right mouse input through Minecraft’s KeyMapping path.

  • Preserves normal inventory and GUI mouse behavior.

  • Removes attack/use cooldown delays while the feature is enabled.

  • Adds a persisted JSON config at config/keyboard_click_input.json.

  • Adds an in-game toggle keybind on J.

  • Includes client-only mixins and localization resources.

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
gradle.properties
settings.gradle
Code
10 331
src/client/java/com/kodari/keyboardclick/KeyboardClickInputClient.java
package com.kodari.keyboardclick;

import com.mojang.blaze3d.platform.InputConstants;
import net.fabricmc.api.ClientModInitializer;
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents;
import net.fabricmc.fabric.api.client.keymapping.v1.KeyMappingHelper;
import net.minecraft.client.KeyMapping;
import net.minecraft.client.Minecraft;
import net.minecraft.network.chat.Component;
import net.minecraft.resources.Identifier;

public final class KeyboardClickInputClient implements ClientModInitializer {
    public static final String MOD_ID = "keyboard_click_input";
    private static final KeyMapping.Category CATEGORY = KeyMapping.Category.register(
        Identifier.fromNamespaceAndPath(MOD_ID, "category")
    );
    private static final KeyMapping TOGGLE_KEY = KeyMappingHelper.registerKeyMapping(new KeyMapping(
        "key." + MOD_ID + ".toggle",
        InputConstants.Type.KEYSYM,
        InputConstants.KEY_J,
        CATEGORY
    ));

    private static boolean mouseAttackDown;
    private static boolean mouseUseDown;

    @Override
    public void onInitializeClient() {
        ConfigManager.load();

        ClientTickEvents.END_CLIENT_TICK.register(client -> {
            while (TOGGLE_KEY.consumeClick()) {
                ConfigManager.setEnabled(!ConfigManager.isEnabled());
                if (!ConfigManager.isEnabled()) {
                    setMouseButtonsDown(false, false);
                }

                if (client.player != null) {
                    client.player.displayClientMessage(
                        Component.translatable(ConfigManager.isEnabled()
                            ? "message." + MOD_ID + ".enabled"
                            : "message." + MOD_ID + ".disabled"),
                        true
                    );
                }
            }
        });
    }

    public static boolean handleMouseButton(Minecraft minecraft, long window, int button, int action) {
        if (!ConfigManager.isEnabled()
            || window != minecraft.getWindow().getWindow()
            || minecraft.gui.screen() != null) {
            return false;
        }

        KeyMapping mapping = switch (button) {
            case 0 -> minecraft.options.keyAttack;
            case 1 -> minecraft.options.keyUse;
            default -> null;
        };
        if (mapping == null) {
            return false;
        }

        boolean pressed = action != 0;
        KeyMapping.set(mapping.getKey(), pressed);
        if (action == 1) {
            KeyMapping.click(mapping.getKey());
        }
        setMouseButtonsDown(button == 0 && pressed, button == 1 && pressed);
        return true;
    }

    public static boolean isMouseAttackDown() {
        return mouseAttackDown;
    }

    public static boolean isMouseUseDown() {
        return mouseUseDown;
    }

    private static void setMouseButtonsDown(boolean attackDown, boolean useDown) {
        mouseAttackDown = attackDown;
        mouseUseDown = useDown;
    }
}