SILENCESILENCE
Products/Lucent
Lucent

Lucent

A high-performance visual toolkit and annotation-driven configuration library. Provides various utilities, event systems, and more.

ModsFabric

Lucent Developer Guide & Architecture Reference

Lucent is an advanced graphical UI and runtime event framework engineered for modern Minecraft Fabric environments. It delivers native-grade vector rendering (via NanoVG and Skija) and eliminates configuration boilerplate through declarative Java annotations and high-throughput bytecode event dispatching.

1. Architectural Philosophy & Core Tenets

Traditional Minecraft interface development requires manual OpenGL state management, tedious pixel coordinate calculations, and fragile JSON serialization loops spread across dozens of disparate files.

Lucent resolves these architectural bottlenecks via three pillars:

1. Declarative Annotation Engine: Declaring field-level annotations such as @ConfigProperty and @Slider automatically produces robust JSON serialization, schema validations, and reactive in-game GUI screens without bespoke boilerplate.
2. Unified Vector Render Pipeline: Binds hardware-accelerated NanoVG vector contexts to the main Minecraft framebuffer, achieving anti-aliased geometry and crisp typography at high refresh rates with negligible frame time overhead.
3. High-Throughput Event Dispatcher: Avoids reflective invocation overhead by deploying runtime-generated MethodHandle calls, achieving a $4\times$ throughput improvement over conventional event buses.

2. Annotation-Driven Configuration (Code Example)

Defining modular in-game configuration menus requires only a few lines of idiomatic Java:
package net.silencehub.samplemod.config;

import net.silence.lucent.api.config.annotation.*;
import net.silence.lucent.api.config.type.ColorRGBA;

@Config(id = "sample_mod", name = "Sample Mod Configuration", category = "HUD & Diagnostics")
public class SampleModConfig {

	@ConfigProperty(
		name = "Master Enable",
		description = "Enables the unified Silence vector HUD overlay.",
		order = 1
	)
	public static boolean enabled = true;

	@Slider(
		name = "HUD Panel Opacity",
		description = "Controls background surface alpha transparency (0.0 to 1.0).",
		min = 0.0f,
		max = 1.0f,
		step = 0.05f,
		order = 2
	)
	public static float hudOpacity = 0.85f;

	@ColorPicker(
		name = "Accent Color",
		description = "Hex/RGBA highlight tone applied to telemetry indicators.",
		allowAlpha = true,
		order = 3
	)
	public static ColorRGBA primaryColor = new ColorRGBA(30, 107, 255, 255);

	@Dropdown(
		name = "Anti-Aliasing Preset",
		options = {"Fast", "Subpixel Vector", "Ultra MSAA"},
		order = 4
	)
	public static String antiAliasingMode = "Subpixel Vector";
}

Runtime Initialization

import net.silence.lucent.api.LucentRegistry;

public class SampleModClient implements ClientModInitializer {
	@Override
	public void onInitializeClient() {
		// Registers the config schema with automated AppData synchronization.
		LucentRegistry.registerConfig(SampleModConfig.class);
	}
}

3. Event Subsystem Pipeline Diagram

Lucent intercepts key rendering ticks through non-destructive, prioritized Mixin hooks:
[ Minecraft Render Tick ]
           │
           ▼
[ Lucent Core Hook (Mixin) ]
           │
           ├─► EventStage.PRE_RENDER (Surface and frame buffer prep)
           │
           ├─► NanoVG Context Setup (Vector stencil & canvas bounds)
           │          │
           │          ├─► Custom HUD Elements (LucentClient)
           │          ├─► Registered Mod Widgets
           │          └─► Floating Tooltip Layer
           │
           ├─► EventStage.POST_RENDER (GL state restoration)
           │
           ▼
[ Minecraft Framebuffer Swap ]

Custom Rendering Implementation

import net.silence.lucent.api.event.LucentRenderEvent;
import net.silence.lucent.api.graphics.NanoContext;

public class CustomWidgetRenderer {

	public static void onRender(LucentRenderEvent event) {
		NanoContext vg = event.getContext();

		// Draw hardware-accelerated rounded card with neon glow
		vg.beginPath();
		vg.roundedRect(100, 100, 240, 60, 12);
		vg.fillColor(SampleModConfig.primaryColor);
		vg.fill();

		// Crisp typography using embedded vector font engine
		vg.fontSize(16.0f);
		vg.fontFace("Inter-Bold");
		vg.text(120, 135, "Silence Hub Connected");
	}
}

4. API Reference Summary

Package / ClassMethod / AnnotationPurpose
net.silence.lucent.api.config@Config(id, name)Declares configuration namespace and display title.
net.silence.lucent.api.config@Slider(min, max, step)Binds numeric properties to interactive range sliders.
net.silence.lucent.api.config@ColorPicker(allowAlpha)Binds RGBA color pickers with hex code input.
net.silence.lucent.api.graphicsNanoContext.roundedRect()Draws hardware-accelerated vector geometries.
net.silence.lucent.api.eventEventBus.subscribe()Subscribes high-throughput event callback handlers.

5. Troubleshooting & FAQ

Q1: The game crashes with UnsatisfiedLinkError (lwjgl_nanovg.dll).

Resolution: Ensure your instance uses a 64-bit Java 21+ runtime. 32-bit runtimes lack modern LWJGL native bindings for vector acceleration.

Q2: Font glyphs appear blurry on high-resolution displays.

Resolution: Under high-DPI monitors, set 'Vector Scaling Mode' to Physical Pixel in configuration to synchronize OpenGL viewport coordinates with native display density.

Q3: How are Lucent and LucentClient linked?

Resolution: LucentClient embeds the Lucent core library as a shadow jar. End users require only LucentClient.jar, while external developers should reference Lucent via Gradle: compileOnly "net.silence:lucent:2.4.0".