andrewneihsial

make a minecraft mod that adds optimization like sodium and also adds tools that help in building

Kodari AI
KodariApr 26 at 7:48 am 23,059 (v2)
ApexOptimizer
A Fabric 1.21.4 mod combining performance optimizations with builder-focused tools. Optimizations include chunk render distance controls, entity culling, and reduced unnecessary ticking. Builder tools include a block replacer (replace all of one block type in a region), a structure mirror/copy tool, a flight speed toggle, a no-clip builder mode, and a grid-snap overlay HUD. Designed for creative builders who need both smooth performance and efficient building workflows.

Let me read the required docs before writing any code.

ApexOptimizer
A Fabric 1.21.4 mod combining performance optimizations with builder-focused tools. Performance features include mob AI throttling for distant entities (every-other-tick for mobs >48 blocks from any player). Builder tools include a Builder's Wand item that flood-fills and extends connected block faces in one click, an `/apex replace` command to swap all blocks of a type within a radius, and an `/apex fly` command to toggle flight and set fly speed. A minimal HUD overlay displays current fly speed and wand status.

Here’s my plan:

  • Build files — gradle.properties, build.gradle, settings.gradle

  • Main — ApexOptimizer, ModItems, BuildersWandItem, ApexCommands, MobEntityMixin

  • Client — ApexOptimizerClient, ApexHudRenderer

  • Resources — fabric.mod.json, mixin config, lang, item definitions


The mod is fully structured. Here’s a summary of every feature:

Performance

  • MobEntityMixin — injects into MobEntity.tickNewAi() and cancels AI evaluation every other tick for any mob that has no player within 48 blocks, cutting AI overhead roughly in half for background mobs.

Builder Tools

  • Builder’s Wand (BuildersWandItem) — right-click any block face to flood-fill all connected same-type blocks on that plane (up to 64) and place new blocks extending outward in the clicked direction. Consumes blocks from inventory in survival, free in creative.

  • /apex replace <radius> <block> — raycasts to the block you’re looking at, then replaces every block of that type within the given radius with the specified block.

  • /apex fly — toggles flight on/off for yourself (requires op level 2).

  • /apex fly speed <0.01–1.0> — sets your fly speed and enables flight. Default Minecraft fly speed is 0.05 (shown as 1.0x in the HUD).

HUD Overlay

  • ApexHudRenderer — when flying, shows current speed as a multiplier (e.g. ✈ Fly Speed: 2.0x). When the Builder’s Wand is in hand, shows a usage hint in the top-left corner.

Note: Place your wand texture PNG at src/main/resources/assets/apexoptimizer/textures/item/builders_wand.png — without it the item will show a missing-texture purple/black checkerboard but will function correctly.

andrewneihsial

The compilation failed with this error:

code
Compilation failed with 4 error(s):

ERROR in src/main/java/com/apexoptimizer/command/ApexCommands.java at line 92: flySpeed has private access in PlayerAbilities
                                                player.getAbilities().flySpeed = speed;
                                                                     ^

ERROR in src/main/java/client/java/com/apexoptimizer/hud/ApexHudRenderer.java at line 19: flySpeed has private access in PlayerAbilities
                float speed = client.player.getAbilities().flySpeed;
                                                          ^

ERROR in   src/main/java/com/apexoptimizer/command/ApexCommands.java at line 92: flySpeed has private access in PlayerAbilities
                                                  player.getAbilities().flySpeed = speed;
                                                                       ^

ERROR in   src/main/java/client/java/com/apexoptimizer/hud/ApexHudRenderer.java at line 19: flySpeed has private access in PlayerAbilities
                  float speed = client.player.getAbilities().flySpeed;
                                                            ^


=== COMPILATION ERROR ANALYSIS ===

FILES TO INVESTIGATE:
  - src/main/java/com/apexoptimizer/command/ApexCommands.java
  - src/main/java/client/java/com/apexoptimizer/hud/ApexHudRenderer.java
  -   src/main/java/com/apexoptimizer/command/ApexCommands.java
  -   src/main/java/client/java/com/apexoptimizer/hud/ApexHudRenderer.java

Please fix this error by creating a new artifact with the corrected code.

Kodari AI
KodariApr 26 at 7:53 am 4,374 (v2)

PlayerAbilities.flySpeed is a private field in 1.21.4 — the correct accessors are getFlySpeed() and setFlySpeed(float).

Replaced the direct flySpeed field access with setFlySpeed(speed) in ApexCommands.java and getFlySpeed() in ApexHudRenderer.java.

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
gradle.properties
settings.gradle
Code
15 473
src/client/java/com/apexoptimizer/ApexOptimizerClient.java
package com.apexoptimizer;

import com.apexoptimizer.hud.ApexHudRenderer;
import net.fabricmc.api.ClientModInitializer;

public class ApexOptimizerClient implements ClientModInitializer {

    @Override
    public void onInitializeClient() {
        ApexHudRenderer.register();
    }
}