Overview
Modifiers are the core building blocks of Lithostitched’s worldgen customization system. They provide a powerful interface for programmatically modifying Minecraft’s world generation at runtime, allowing you to add, remove, or modify worldgen features, structures, surface rules, and more.Modifiers are loaded from data packs and applied when the server starts, before world generation begins.
The Modifier Interface
At its core, every modifier implements theModifier interface:
/home/daytona/workspace/source/src/common/main/java/dev/worldgen/lithostitched/worldgen/modifier/Modifier.java:17-42
Key Methods
applyModifier()- The main method that executes your worldgen modificationspriority()- Determines the order in which modifiers are applied (lower = earlier)codec()- Returns the MapCodec used for JSON serialization/deserialization
Priority System
Modifiers are applied in order based on their priority value. This is crucial for ensuring modifications happen in the correct sequence.Priority Presets
PRIORITY_DEFAULT- 1000 (standard modifications)PRIORITY_REMOVE- 2000 (removal operations should happen last)
How Modifiers Are Loaded
Modifiers are loaded through Minecraft’s data pack system and applied by theModifierManager:
/home/daytona/workspace/source/src/common/main/java/dev/worldgen/lithostitched/worldgen/modifier/ModifierManager.java:21-44
Loading Process
Server Startup
Modifiers are loaded when the Minecraft server starts, triggered by mixins into the server initialization
Registry Lookup
The
ModifierManager queries the WORLDGEN_MODIFIER registry for all registered modifiersBuilt-in Modifier Types
Lithostitched provides many built-in modifier types for common operations:add_surface_rule
Adds surface rules to dimension noise routers
add_template_pool_elements
Adds new structure pieces to template pools
add_structure_set_entries
Adds structures to structure sets
remove_structure_set_entries
Removes structures from structure sets
wrap_density_function
Wraps or modifies density functions
wrap_noise_router
Modifies noise router configuration
set_pool_aliases
Creates aliases for template pools
stack_feature
Stacks multiple features together
Example: Creating a Custom Modifier
Here’s a complete example of a custom modifier that removes structures:/home/daytona/workspace/source/src/common/main/java/dev/worldgen/lithostitched/worldgen/modifier/RemoveStructureSetEntriesModifier.java:23-45
This modifier uses
PRIORITY_REMOVE (2000) to ensure it runs after other modifiers that might add structures.Best Practices
Choose appropriate priorities
Choose appropriate priorities
- Use lower priorities (500-900) for foundational changes
- Use default priority (1000) for standard modifications
- Use higher priorities (1500-2000) for removals and overrides
Test modifier order
Test modifier order
If modifiers depend on each other, test different priority values to ensure they apply in the correct sequence.
Use debug logging
Use debug logging
Enable
log_debug_messages in the Lithostitched config to see the order in which modifiers are applied.Handle registry access carefully
Handle registry access carefully
When using
applyModifier(RegistryAccess registryAccess), ensure the registries you need are available at modification time.Related Resources
Registry System
Learn how modifiers are registered
Data-Driven Config
Create modifier JSON files
