-
Notifications
You must be signed in to change notification settings - Fork 0
Registry Layer
The Registry Layer is the phase where Temporal API connects your object model to NeoForge’s registry and event system.
If the Initialization Layer answers the question:
“What exists in the mod?”
then the Registry Layer answers:
“What gets registered into Minecraft and how?”
This layer is responsible for:
- Binding factories to the NeoForge
IEventBus - Registering DeferredRegisters
- Creating and wiring custom registries
- Ensuring all registrations happen exactly once and at the correct lifecycle phase
NeoForge registration is:
- Event-driven
- Order-sensitive
- Easy to break with static init mistakes
The Registry Layer exists to:
- Centralize all registration logic
- Decouple mod code from raw NeoForge APIs
- Guarantee lifecycle correctness
- Allow registration logic to be extended dynamically
This avoids:
- Static init side effects
- Double registration
- Registering too late / too early
- Tight coupling to Forge internals
public class RegistryLayer implements EngineLayerThis layer:
- Pulls the global ObjectPool
- Resolves the NeoForge EventBus
- Executes FactoryRegistrars
@Override
public void processAllTasks() {
ObjectPool objectPool = InjectionPool.getInstance();
IEventBus eventBus = objectPool.get(IEventBus.class);
factoryRegistrars.forEach(factoryRegistrar -> {
factoryRegistrar.registerFactories(eventBus);
});
}What happens:
- Retrieves
IEventBusfrom the injection pool - Iterates over all
FactoryRegistrars - Each registrar attaches its factories to the event bus
No registration happens immediately - only event listeners are attached.
private static final List<FactoryRegistrar> DEFAULT_FACTORY_REGISTRARS = List.of(new FieldTypeFactoryRegistrar());By default, Temporal API:
- Enables field-based factory discovery
- Requires zero manual registration for common cases
new RegistryLayerBuilder(engineBuilder)
.factoryRegistrars(customRegistrars)
.and();This:
- Finalizes configuration
- Executes the Registry Layer immediately
- Locks in factory registration before runtime events fire
A FactoryRegistrar is a bridge between:
- Temporal abstractions
- NeoForge’s
IEventBus
Their only responsibility:
void registerFactories(IEventBus eventBus);They do not register objects directly. They register listeners that will do so later.
The framework changes the way objects are subscribed to EventBus by introducing TemporalRegister, a child class of DeferredRegister
protected void loadFields(Class<?>... containers)TemporalRegister:
- Forces class loading
- Triggers static field initialization
- Ensures all entries are registered before events fire
Purpose:
- Lazy access to registries
- Works for both built-in and custom registries
- Safe to inject and reuse
These automatically:
- Use the current mod ID
- Bind to correct vanilla registries
- Create correct
DeferredHoldertypes
TemporalRegister tracks:
seenRegisterEventseenNewRegistryEventregisteredEventBus
Every mutating operation checks these flags.
If violated exception, not undefined behavior
Their role:
- Define default object creation or extend default factory behavior
- Support new registration patterns
- Enable framework-level extensibility
They integrate via:
FactoryRegistrar- ObjectPool discovery
- EventBus listeners
This allows third-party extensions without modifying core code.
The Registry Layer is where:
- Objects become Minecraft content
- Factories attach to lifecycle events
- Registries are created safely
🚀 Getting Started
🧩 Core Concepts
⚙️ Data Generation
- ⚙️ Advancement
- ⚙️ Damage Type
- ⚙️ Chest Loot Modifier
- ⚙️ Recipe
- ⚙️ Sound
- ⚙️ Jukebox Song
- ⚙️ Enchantment
- ⚙️ Trim Material
- ⚙️ Trim Pattern
- ⚙️ Banner Pattern
- ⚙️ Painting Variant
- ⚙️ Particle Sprite Set
- ⚙️ Wolf Variant
- ⚙️ Item Model
- ⚙️ Block Model
- ⚙️ Block Loot Table
- ⚙️ Tag
- ⚙️ Language Translation
- ⚙️ World Feature
- ⚙️ Custom Properties
🚨 Events
🛠 Engine Layers
🧪 Resources
- 🧪 Examples