X

make it work for the players X for the toggle remove the flight feature Z For increased hitbox Y for decrease make it visible on the hitbox feature Minecraft

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
Code
8 302
src/client/java/com/hitboxexpander/HitboxModClient.java
package com.hitboxexpander;

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.hud.HudElementRegistry;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.option.KeyBinding;
import net.minecraft.text.Text;
import net.minecraft.util.Identifier;
import org.lwjgl.glfw.GLFW;

public class HitboxModClient implements ClientModInitializer {

    public static final KeyBinding.Category CATEGORY = KeyBinding.Category.create(
            Identifier.of("hitboxexpander", "main")
    );

    public static final KeyBinding INCREMENT_KEY = KeyBindingHelper.registerKeyBinding(
            new KeyBinding("key.hitboxexpander.increment", GLFW.GLFW_KEY_0, CATEGORY)
    );
    public static final KeyBinding DECREMENT_KEY = KeyBindingHelper.registerKeyBinding(
            new KeyBinding("key.hitboxexpander.decrement", GLFW.GLFW_KEY_9, CATEGORY)
    );
    public static final KeyBinding RESET_KEY = KeyBindingHelper.registerKeyBinding(
            new KeyBinding("key.hitboxexpander.reset", GLFW.GLFW_KEY_8, CATEGORY)
    );

    private static int counter = 0;

    @Override
    public void onInitializeClient() {
        ClientTickEvents.END_CLIENT_TICK.register(client -> {
            while (INCREMENT_KEY.wasPressed()) counter++;
            while (DECREMENT_KEY.wasPressed()) counter--;
            while (RESET_KEY.wasPressed()) counter = 0;

            if (client.player != null) {
                boolean shouldFly = HitboxConfig.isFlightEnabled();
                client.player.getAbilities().allowFlying = shouldFly;
                if (!shouldFly && client.player.getAbilities().flying) {
                    client.player.getAbilities().flying = false;
                }
                client.player.sendAbilitiesUpdate();
            }
        });

        HudElementRegistry.addLast(
            Identifier.of("hitboxexpander", "counter"),
            (context, tickCounter) -> {
                MinecraftClient client = MinecraftClient.getInstance();
                if (client.player == null || client.options.hudHidden) return;
                String text = "Counter: " + counter;
                int x = context.getScaledWindowWidth() / 2 - client.textRenderer.getWidth(text) / 2;
                int y = context.getScaledWindowHeight() - 59;
                context.drawTextWithShadow(client.textRenderer, text, x, y, 0xFFFFFF);
            }
        );
    }
}