SILENCESILENCE

Reducing Mod Development Overhead with Lucent's Architecture

SILENCE

When developing client-side Minecraft mods, developers often spend more time building and maintaining infrastructure than writing actual features.

Starting each mod requires re-implementing JSON serialization and settings menus from scratch. Whenever Minecraft updates its graphics pipeline, existing UI rendering code frequently breaks across versions.

As a mod expands to dozens of modules, runtime overhead adds up. Multiple on-screen HUDs repeat expensive vector calculations every frame, and unused event listeners execute on every tick, degrading performance.

Lucent is a core Fabric library designed to reduce this repetitive work. Here is an overview of how Lucent minimizes rendering overhead and manages configs and profiles.

Do We Need to Redraw Every HUD on Every Frame?

In-game overlays such as FPS counters, player coordinates, and keystroke displays are active throughout gameplay. Most mods recalculate background boxes, borders, shadows, and text strings on every frame refresh.

However, if the player is stationary and the displayed text has not changed, repeating identical vector draws hundreds of times per second is unnecessary.

In version 26.2, Lucent integrates an offscreen compositor built on Skija (Java bindings for Skia) with a two-tier caching pipeline.

Lucent Two-Tier HUD Cache Decision Flow
Rendering Pipeline
Tier 1 · Full Layer Reuse
Direct GPU Texture Blit
When all active HUD cache keys match the previous frame, Lucent skips Skia drawing entirely and blits the existing GPU texture directly to the screen.
Tier 2 · Unchanged HUDs
PictureRecorder Replay
If only certain HUDs update, unchanged HUDs replay their pre-recorded Skia display lists (Picture), avoiding layout re-evaluations.
Tier 3 · Changed Elements
Selective Vector Draw
Only HUDs with modified data are redrawn on the Skia canvas. Offscreen targets idle for more than 5 seconds automatically release VRAM.

Developers only need to return the values affecting visual output in their HUD class:

@Override
public Object getRenderCacheKey() {
	// The HUD is redrawn only when these values change.
	return List.of(mc.getFps(), mc.player.position());
}

The HUD manager combines this key with coordinates, scale, alignment, and screen dimensions. While these values remain static, vector drawing operations do not occur, preventing frame drops even with multiple active HUDs.

Supporting OpenGL and Vulkan with Lightweight Downloads

Minecraft's rendering stack is evolving toward Vulkan while maintaining support for OpenGL environments.

However, bundling native Skia binaries for Windows, macOS, and Linux across CPU architectures inside a mod JAR would inflate its size by tens of megabytes.

Lucent handles this through runtime environment detection and on-demand native provisioning.

Graphics Backend Routing & Native Provisioning
Dual Backend
Runtime Detection
OpenGL & Vulkan Support
Inspects the active rendering device. In OpenGL, state guards (GlStateGuard) prevent render state contamination. In Vulkan, frame barriers ensure thread-safe texture sharing.
Lightweight Distribution
One-Time Background Download
Mod JARs contain no native binaries. On first launch, a background daemon fetches and caches only the Skia binary matching the user's OS and CPU architecture from Maven Central.

Mod file sizes remain minimal, while the appropriate native acceleration libraries are provisioned on first run.

Binding Only the Events You Actually Implement

Client mods handle game ticks, network packets, chat messages, world rendering, and block interactions. Lucent's base Mod class defines over 60 event hooks.

With 50 active modules, iterating through all 50 modules on every tick to invoke empty methods causes unnecessary virtual call overhead.

Lucent uses reflection at module registration to identify only the methods that the subclass actually overrides.

Full Module Loop vs. Selective Event Binding
Event Architecture
Traditional Loop
Iterating Every Module on Every Event
A 60 events × 50 modules setup calls unimplemented empty methods continuously, reducing CPU cache locality.
Lucent Approach
Direct Wiring of Overridden Hooks
Checks getDeclaringClass() != Mod.class once on startup and registers listeners only for implemented callbacks.

Tick hooks are also divided into four cadences for logic that does not require per-tick execution:

  • onTick (1 tick): Real-time updates and input handling
  • onMediumTick (5 ticks): Short-interval state checks
  • onHighTick (10 ticks): Entity scanning
  • onEverySecond (20 ticks): 1-second interval statistics and timers

Moving non-urgent checks to larger intervals substantially reduces the frequency of event executions.

Annotation-Driven Configs and Profile Storage

Building settings UI layouts and writing serialization logic is a repetitive task. In Lucent, annotating fields with @ModConfig builds the settings screen and handles JSON storage automatically:

@ModConfig.CategoryPriority(name = "General", priority = 1000)
public class ExampleMod extends Mod {

	@ModConfig(
		type = ConfigType.SWITCH,
		name = "Enable Highlight",
		description = "Renders an outline around targeted blocks."
	)
	public static boolean useHighlight = false;

	@ModConfig(
		type = ConfigType.COLOR,
		name = "Highlight Color",
		parent = "useHighlight"
	)
	public static Color highlightColor = new Color(85, 255, 85, 255);
}

Using the parent property automatically creates a hierarchical UI where child options appear only when their parent setting is enabled.

Why Store Configs in OS Application Data?

Most mods store settings inside the .minecraft/config folder. When using multi-instance launchers or installing new Minecraft versions, players must reconfigure keybinds and HUD positions from scratch.

Lucent stores configurations in the operating system's application data directory (%APPDATA%/Lucent on Windows).

OS-Level Profile Storage & Cross-Instance Persistence
Storage Design
Global Settings
lucent_global.json
Centrally manages active profiles, 16 themes, UI scale, blur, and localization independently of game instances.
Per-Mod Folders
config/<mod_id>/profiles/
Isolates mod configurations (config.json) and HUD positions (hud.json) per profile to avoid cross-mod conflicts.
Cross-Instance Sync
Instant Profile Retention
Creating a new game instance automatically loads existing profiles and HUD layouts without manual file transfers.

Integrating Lucent in Third-Party Mods

Connecting a mod to Lucent requires only a few lines using the LucentAPI class:

public class MyClientMod implements ClientModInitializer {
	public static final ModManager CONFIG = LucentAPI.createModManager("mymod");

	@Override
	public void onInitializeClient() {
		CONFIG.register(new ExampleMod());
		LucentAPI.registerHUD(CONFIG, new ExampleHUD());
	}
}

Translations placed under assets/<modid>/lucent/lang/ inside dependent mod JARs are discovered and merged automatically on startup. The full source code is available in the Lucent GitHub repository.