Overview
Voxy World Gen V2 uses Mixin to modify Minecraft’s chunk generation and server management systems. The mod applies strategic hooks to:- Track block updates for LOD synchronization
- Intercept chunk saves to prevent unnecessary disk writes
- Access internal Minecraft APIs
- Integrate with chunk loading systems
Core Mixins
BlockUpdateMixin
Target:ServerLevelPurpose: Track block updates to detect when chunks need LOD re-synchronization This mixin intercepts
sendBlockUpdated to mark chunks as dirty when blocks change:
- Hooks into Minecraft’s block update system
- Marks the containing chunk as dirty via
ChunkUpdateTracker - Ensures LOD clients receive updates when terrain changes
ChunkSaveMixin
Target:ChunkMapPurpose: Suppress saves for LOD-only chunks when
saveNormalChunks is disabled
This is one of the most critical mixins for performance optimization:
- Checks if the chunk was marked as “LOD-only” (generated for distant viewing)
- If a player is within view distance, allows the save to proceed normally
- Otherwise, clears the dirty flag and suppresses the save operation
- Returns
falseto indicate the chunk was not saved
ChunkAccessUnsavedMixin
Target:ChunkAccessType: Accessor interface
Purpose: Directly manipulate chunk dirty state
- Provides write access to the internal
unsavedfield - Used by
ChunkSaveMixinto clear dirty flags on LOD-only chunks - Prevents C2ME and vanilla systems from repeatedly attempting to save suppressed chunks
ChunkMapMixin
Target:ChunkMapType: Invoker interface
Purpose: Access internal ChunkMap methods
- Exposes
tick()for manual chunk system updates (legacy, not currently used) - Exposes
readChunk()for asynchronously reading chunk NBT data from disk
MinecraftServerAccess
Target:MinecraftServerType: Accessor interface
Purpose: Prevent server shutdown during chunk generation
- Provides write access to
emptyTickscounter - Reset to
0after each chunk completes to prevent “server stopping due to inactivity” - Ensures servers with
stop-when-empty=truedon’t shut down during background generation
ChunkGenerationManager.cleanupTask() /workspace/source/src/main/java/com/ethan/voxyworldgenv2/core/ChunkGenerationManager.java:526
MinecraftServerMixin
Target:MinecraftServerPurpose: Extension interface implementation (legacy)
- Implements the
MinecraftServerExtensioninterface - Methods are no-ops to maintain compatibility
- Previously used for manual chunk system ticking, now handled differently
ServerChunkCacheMixin
Target:ServerChunkCacheType: Invoker interface
Purpose: Access chunk loading and distance manager APIs
getChunkFutureMainThread: Initiates asynchronous chunk generation to a specific statusrunDistanceManagerUpdates: Flushes pending ticket operations (load/unload tickets)
- Chunk generation:
ChunkGenerationManager.workerLoop()/workspace/source/src/main/java/com/ethan/voxyworldgenv2/core/ChunkGenerationManager.java:318 - Ticket processing:
ChunkGenerationManager.processPendingTickets()/workspace/source/src/main/java/com/ethan/voxyworldgenv2/core/ChunkGenerationManager.java:512
ServerLevelMixin
Target:ServerLevelType: Accessor interface
Purpose: Access entity management system
- Provides read access to the internal entity manager
- Used for advanced entity processing in LOD chunks (if needed)
- Currently available but not actively used in core functionality
Mixin Categories
Accessor Mixins
Provide direct field access to private Minecraft internals:ChunkAccessUnsavedMixin- chunk dirty stateMinecraftServerAccess- empty tick counterServerLevelMixin- entity manager
Invoker Mixins
Expose private methods for controlled invocation:ChunkMapMixin- chunk reading and tickingServerChunkCacheMixin- chunk loading and distance updates
Injection Mixins
Hook into method execution to add custom behavior:BlockUpdateMixin- block update trackingChunkSaveMixin- save interceptionMinecraftServerMixin- extension interface
Thread Safety Considerations
Thread-Safe Mixins
ChunkSaveMixin- reads from concurrent maps only- All accessor/invoker mixins - safe when called from appropriate threads
Main-Thread-Only Mixins
BlockUpdateMixin- always runs on server thread
Debugging Mixin Issues
If you encounter mixin-related crashes:- Check Mixin Logs: Look for mixin application errors in
logs/latest.log - Verify Fabric Loader Version: Ensure you’re using a recent Fabric Loader (0.15.0+)
- Check for Conflicts: Other mods targeting the same methods can cause conflicts
- Review Mixin JSON: The
voxyworldgenv2.mixins.jsondefines all mixin targets
Related Documentation
- Events - How events integrate with the mixin system
- Distance Graph - The chunk prioritization system that benefits from these mixins
- Configuration - Settings that control mixin behavior (saveNormalChunks)