Skip to content

Event Layer

Maksym Uimanov edited this page Jan 30, 2026 · 2 revisions

Event Layer

Overview

The Event Layer is responsible for activating event handling logic defined by the mod.

While previous layers:

  • prepare objects (Initialization),
  • register content (Registry),
  • interpret metadata (Metadata),
  • expose configuration (Config),

the Event Layer answers:

“What runtime behavior should react to events?”

This layer is where event subscriptions actually become live.


Core Responsibility

The Event Layer:

  • Collects all registered EventHandler instances
  • Executes their handle() method
  • Allows handlers to subscribe to NeoForge and mod event buses

EventLayer

Step-by-step:

  • Obtain the global HandlerPool
  • Iterate over all registered EventHandler instances
  • Call handle() on each handler
  • EventHandlers are passive until this layer runs.

EventLayerBuilder

Purpose

public class EventLayerBuilder

The builder:

  • Adds the EventLayer to the engine
  • Immediately processes it when .and() is called
this.engineBuilder.processLayer(eventLayer);

This guarantees that all event handlers are activated during engine startup.

EventHandler

Definition

public interface EventHandler

Role

An EventHandler is a self-contained event wiring unit.

Its responsibility is to:

  • Subscribe to events
  • Define reactions
  • Decide priorities
  • All logic is executed inside handle().

Adapter-based subscriptions

subscribeEvent(Class<T> event, EventAdapter<T, ?> adapter)

This allows:

  • Separation of event and logic mapping
  • Reusable adapters
  • Cleaner handlers

Obtaining Mod EventBus instance

InjectionPool.getFromInstance(IEventBus.class)

HandlerPool Dependency

The Event Layer depends on:

SimpleHandlerPool.getInstance()

This implies:

  • Handlers are discovered and registered earlier
  • Likely during Initialization or Metadata processing
  • Event Layer only executes, never discovers

Summary

The Event Layer:

  • Activates all registered EventHandler instances
  • Executes event wiring logic
  • Connects Temporal API to NeoForge’s event system
  • Marks the transition from setup to runtime behavior

Clone this wiki locally