Repository navigation
API ‐ Extensible Animations Events
The Animation Event system is fully extensible.
Third-party mods may register custom animation events, allowing animations to execute arbitrary logic at specific moments during playback.
Every animation event consists of three parts:
- An event parameter record.
- An event type.
- A registry entry.
ExtendedDatapacksRegistry
│
▼
IAnimationEventType
│
▼
paramsCodec()
│
▼
IAnimationEventParams
│
▼
execute(...)
│
▼
Animation Timeline
The registry serializes event types using DFU (
Codec), while event parameters are decoded through theMapCodecsupplied by each registered type.
Every event is represented by a parameter record.
The record contains both:
- The serialized configuration.
- The execution logic.
Third-party events must implement:
IAnimationExternalEventParamswhich is the non-sealed extension point of:
IAnimationEventParamspublic record ExampleEvent(Float radius, String joint)
implements IAnimationExternalEventParams {
public static final MapCodec<ExampleEvent> CODEC =
RecordCodecBuilder.mapCodec(instance ->
instance.group(
Codec.FLOAT.fieldOf("radius")
.forGetter(ExampleEvent::radius),
Codec.STRING.fieldOf("joint")
.forGetter(ExampleEvent::joint)
).apply(instance, ExampleEvent::new)
);
@Override
public <T extends StaticAnimation> void execute(
AssetAccessor<T> accessor,
LivingEntityPatch<?> patch) {
// Custom event logic
}
}The execute() method is invoked automatically whenever the animation reaches the configured event time.
Every event type exposes the codec responsible for decoding its parameter object.
Implement:
IAnimationEventTypepublic enum ExampleAnimationEvents
implements IAnimationEventType {
EXAMPLE(ExampleEvent.CODEC);
private final MapCodec<? extends IAnimationEventParams> codec;
ExampleAnimationEvents(
MapCodec<? extends IAnimationEventParams> codec) {
this.codec = codec;
}
@Override
public MapCodec<? extends IAnimationEventParams> paramsCodec() {
return codec;
}
}Each enum constant represents one animation event.
Animation event types are registered through the centralized:
ExtendedDatapacksRegistryUse the ANIMATIONS_EVENTS registry entry:
ExtendedDatapacksRegistry.ANIMATIONS_EVENTS.register(
MOD_ID,
ExampleAnimationEvents.class
);Multiple event enums can also be registered in a single call:
ExtendedDatapacksRegistry.ANIMATIONS_EVENTS.register(
MOD_ID,
CombatAnimationEvents.class,
SoundAnimationEvents.class,
ExampleAnimationEvents.class
);The registry automatically verifies that each supplied enum implements:
IAnimationEventTypeInvalid classes are rejected and a warning is emitted to the log.
Every enum constant becomes an available animation event.
The generated identifier follows the format:
<modid>:<enum_name>
For example:
example_mod:example
Once registered, the event can immediately be used inside animation JSON.
{
"in_time_events": [
{
"type": "example_mod:example",
"side": "server",
"start": 0.75,
"params": {
"radius": 4.0,
"joint": "Tool_R"
}
}
]
}The params object is automatically decoded using the MapCodec supplied by the registered event type.
Animation events must be registered before Extended Datapacks initializes and consumes its animation registries.
Attempting to register additional events after the registry has been consumed will throw:
RegistryObjectException
This restriction exists because the available animation event types are resolved while the animation codecs are being initialized.
For example, registration should occur during mod initialization:
private static void registerAnimationEvents() {
ExtendedDatapacksRegistry.ANIMATIONS_EVENTS.register(
MOD_ID,
ExampleAnimationEvents.class
);
}The animation event registry internally uses DFU:
Codec<IAnimationEventType>Every registered event provides its own:
MapCodec<? extends IAnimationEventParams>allowing each event to define its own JSON structure independently.
The centralized ExtendedDatapacksRegistry handles routing the registration to the underlying animation event registry.
A minimal external animation event therefore consists of:
public record ExampleEvent(Float radius, String joint)
implements IAnimationExternalEventParams {
public static final MapCodec<ExampleEvent> CODEC =
RecordCodecBuilder.mapCodec(instance ->
instance.group(
Codec.FLOAT.fieldOf("radius")
.forGetter(ExampleEvent::radius),
Codec.STRING.fieldOf("joint")
.forGetter(ExampleEvent::joint)
).apply(instance, ExampleEvent::new)
);
@Override
public <T extends StaticAnimation> void execute(
AssetAccessor<T> accessor,
LivingEntityPatch<?> patch) {
// Custom event logic
}
}public enum ExampleAnimationEvents
implements IAnimationEventType {
EXAMPLE(ExampleEvent.CODEC);
private final MapCodec<? extends IAnimationEventParams> codec;
ExampleAnimationEvents(
MapCodec<? extends IAnimationEventParams> codec) {
this.codec = codec;
}
@Override
public MapCodec<? extends IAnimationEventParams> paramsCodec() {
return codec;
}
}ExtendedDatapacksRegistry.ANIMATIONS_EVENTS.register(
MOD_ID,
ExampleAnimationEvents.class
);{
"in_time_events": [
{
"type": "example_mod:example",
"side": "server",
"start": 0.75,
"params": {
"radius": 4.0,
"joint": "Tool_R"
}
}
]
}- Custom events should implement
IAnimationExternalEventParamsrather than directly implementingIAnimationEventParams. - Animation event types must implement
IAnimationEventType. - Register event enums through
ExtendedDatapacksRegistry.ANIMATIONS_EVENTS. - Multiple event enum classes can be registered in a single call.
- The registry automatically validates that supplied classes implement the appropriate registry interface.
- Registration must occur before Extended Datapacks initializes and consumes its animation registries.
- The generated event identifier is based on the mod ID and enum constant name.
- The
paramsobject is decoded using theMapCodecsupplied by the registered event type. - Every event implementation is responsible for validating its own execution context (client/server side, entity state, world access, etc.) inside its
execute()method. - The centralized
ExtendedDatapacksRegistryis the recommended registration API; the underlyingAnimationEventTypeRegistryremains an implementation detail.
EF: Extended Datapacks
📦 Data
🧰 Core
👁️ Visuals
- Zoom Types
- Weapon Models per Style
- Advanced Swing Trails
- Weapons Passive Particles
- Shader Effects I
- Shader Effects II
- Shader Effects III
⚔️ Combat
🗝️ Skill Builder
🛠️ Innate Builder
- Simple Innate Skills
- Holdable Innate Skills
- Conditional Innate Skills
- Conditional Data Innate Skills
- Conditional Holdable Innate Skills
- Sequential Innate Skills
- Per Combo Innate Skills
- Combo Innate Skills
🗡️ Animation Operations
- Animation Operations
- Animation Properties
⚙️ Third-Party