Skip to content

FML Setup Event

Maksym Uimanov edited this page Feb 12, 2026 · 2 revisions

FML Setup Event

The FML Setup annotations provide a declarative way to register items and wood types that require special client-side setup during the FML client setup phase. These annotations automatically handle the registration of bow, crossbow, shield, instrument, and wood type objects for proper client-side initialization.

Responsibilities / Purpose

The FML Setup annotations are responsible for:

  • Automatically registering items that require special client-side rendering setup
  • Managing wood types that need client-side registration
  • Eliminating manual event handler registration for common setup tasks
  • Ensuring proper timing of client-side setup during the FML lifecycle

How it works

The FML Setup system operates through the following process:

  1. Annotation Processing: Each setup annotation is processed by its corresponding strategy implementation during the field scanning phase
  2. Field Extraction: The annotated field value is extracted using reflection and added to the appropriate static list in FMLClientSetupEventHandler
  3. Event Registration: All registered items are processed during the FMLClientSetupEvent using dedicated client setup strategies
  4. Client Setup: Each item type receives its specific client-side configuration (rendering properties, models, etc.)

The annotations are processed within the FMLClientSetupEventHandlerAnnotationProcessorAdapter scope, ensuring they execute at the correct time in the mod initialization lifecycle.

How to use / Configure

Basic Usage

Apply the appropriate setup annotation to any static field that holds the item or wood type you want to register:

public final class ExampleItems {
    @SetupBow
    public static final DeferredItem<?> EXAMPLE_BOW = ITEM_FACTORY.createBow("example_bow");
    
    @SetupCrossbow
    public static final DeferredItem<?> EXAMPLE_CROSSBOW = ITEM_FACTORY.createCrossbow("example_crossbow");
    
    @SetupShield
    public static final DeferredItem<?> EXAMPLE_SHIELD = ITEM_FACTORY.createShield("example_shield");
    
    @SetupInstrument
    public static final DeferredItem<?> EXAMPLE_INSTRUMENT = ITEM_FACTORY.createInstrument("example_instrument", ExampleInstrumentTags.EXAMPLE);
}

public final class ExampleWoodTypes {
    @SetupWoodType
    public static final WoodType EXAMPLE_WOOD_TYPE = WoodTypeFactory.create("example", ExampleBlockSetTypes.EXAMPLE);
}

Available Annotations

  • @SetupBow: Registers bow items for client-side setup and FOV modification handling
  • @SetupCrossbow: Registers crossbow items for client-side setup
  • @SetupShield: Registers shield items for client-side setup
  • @SetupInstrument: Registers instrument items for client-side setup
  • @SetupWoodType: Registers wood types for client-side setup

Extension / Customization Points

The FML Setup system can be extended by:

  1. Creating New Annotations: Define new field-level annotations following the same pattern
  2. Implementing Strategies: Create new FieldAnnotationStrategy implementations that extend the system
  3. Adding Client Setup Strategies: Implement new ClientSetupStrategy classes for custom client-side logic
  4. Modifying Event Handlers: Extend FMLClientSetupEventHandler to support additional item types

When to use

Use FML Setup annotations when:

  • Creating items that require special client-side rendering setup (bows, crossbows, shields, instruments)
  • Defining custom wood types that need client-side registration
  • You want to avoid manual event handler registration for common setup tasks
  • You need to ensure proper timing of client-side initialization

Clone this wiki locally