Mahyar Khan

Develop a high-performance client-side FPS optimization mod for Minecraft 1.21.11 Fabric using Java 21. The mod should include automatic FPS optimization, dynamic performance adjustments, and a configurable FPS target, while ensuring safe rendering optimizations for vanilla and Sodium compatibility. Additionally, implement an in-game FPS/performance monitor and provide a complete Gradle/Fabric project structure with all necessary Java files, Mixins, fabric.mod.json, Gradle configuration, and detailed build instructions, adhering strictly to verified Minecraft 1.21.11 APIs and mappings without using pseudocode.

Kodari AI
KodariOct 3 at 8:54 pm 1
FpsOptimizerPro
Client-side Minecraft Fabric mod for 1.21.11 that automatically optimizes FPS through dynamic rendering adjustments, configurable FPS targets, and safe performance tweaks compatible with vanilla and Sodium. Features an in-game performance monitor displaying real-time FPS, frame time, and optimization status via HUD overlay. Includes adaptive quality scaling that reduces rendering load when FPS drops below target and restores quality when performance improves. Provides comprehensive configuration through a settings interface for target FPS, optimization aggressiveness, and monitor display options. Built with Java 21, Mixins for safe rendering hooks, and full Gradle build setup.
  1. Set up the Fabric 1.21.11/Java 21 Gradle project and client entrypoint.

  2. Implement adaptive render-distance control with a user-editable FPS target and safe restoration.

  3. Add an in-game performance HUD; avoid invasive render mixins for vanilla/Sodium compatibility.

Created the Adaptive FPS Fabric project for Minecraft 1.21.11 and Java 21.

It reads FPS every 40 ticks and adjusts vanilla render distance toward the configured target, with gradual recovery and a HUD showing FPS, target, render distance, and status. Settings are in config/adaptivefps.properties; defaults are a 120 FPS target, 4-chunk minimum, adaptive mode enabled, and HUD enabled.

No render mixin is registered intentionally: the mod uses Fabric tick/HUD APIs and the vanilla view-distance option rather than renderer hooks, helping avoid conflicts with Sodium. The project includes Gradle configuration, the Fabric descriptor, client Java sources, and Kodari build/download steps in README.md.

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
gradle.properties
README.md
settings.gradle
Code
8 332
src/client/java/com/kodari/adaptivefps/AdaptiveFpsClient.java
package com.kodari.adaptivefps;

import net.fabricmc.api.ClientModInitializer;
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents;
import net.fabricmc.fabric.api.client.rendering.v1.hud.HudElementRegistry;
import net.minecraft.client.MinecraftClient;
import net.minecraft.util.Identifier;

public final class AdaptiveFpsClient implements ClientModInitializer {
    private static final Identifier HUD_ID = Identifier.of("adaptivefps", "performance_hud");

    @Override
    public void onInitializeClient() {
        MinecraftClient client = MinecraftClient.getInstance();
        AdaptiveFpsConfig config = AdaptiveFpsConfig.load(client.runDirectory.toPath().resolve("config"));
        AdaptiveFpsController controller = new AdaptiveFpsController(config);

        ClientTickEvents.END_CLIENT_TICK.register(controller::tick);
        HudElementRegistry.addLast(HUD_ID, (context, tickCounter) -> {
            if (!config.hudEnabled()) {
                return;
            }

            MinecraftClient hudClient = MinecraftClient.getInstance();
            int fps = hudClient.getCurrentFps();
            int viewDistance = hudClient.options.getViewDistance().getValue();
            context.drawTextWithShadow(hudClient.textRenderer,
                    "Adaptive FPS: " + fps + " / " + config.targetFps(), 6, 6, 0xFFFFFF);
            context.drawTextWithShadow(hudClient.textRenderer,
                    "Render distance: " + viewDistance + " chunks | " + controller.status(), 6, 16, 0xB8D8FF);
        });
    }
}