Skip to content

Adaptive Trigger API

Resource packs should be used for adaptive trigger effects based on item identities, tags, or serialized data-component values. The Java API is available when an effect needs custom code or cannot be expressed with resource-pack matching.

Register effects during Controlify pre-initialization:

java
public final class MyControlifyEntrypoint implements ControlifyEntrypoint {
    @Override
    public void onControlifyPreInit(PreInitContext context) {
        TriggerEffectApi.registerUseItemEffect(
            DataComponents.CHARGED_PROJECTILES,
            projectiles -> new DualsenseTriggerEffect.Feedback(
                (byte) 3,
                (byte) Math.min(8, projectiles.items().size() + 1)
            )
        );
    }
}

TriggerEffectApi has use-item and swing-item overloads for:

  • A DataComponentType<T> and a Function<? super T, DualsenseTriggerEffect>, for effects computed from the component value.
  • A DataComponentType<?> and a constant DualsenseTriggerEffect.
  • An Item and a constant DualsenseTriggerEffect.

Use registerUseItemEffect for the input bound to Use Item and registerSwingItemEffect for the input bound to Attack.

Priority

Resource-pack rules are always evaluated before Java registrations, allowing users and pack authors to override mod-provided effects. Among Java registrations, component functions are checked in registration order before the exact-item fallback. Registering the same component or item again replaces its previous effect.

Use a resource-pack off rule when an effect should be explicitly disabled. An off result returned from Java also disables the trigger, but is only reached when no resource rule matched.

Controlify is an open-source Minecraft mod.