React to Events & Draw Custom UI
Reactions connect registered runtime events to JSON behavior. Overlay actions let those behaviors—or any objective—draw static or animated resource-pack textures directly onto the player's screen.
Reaction Files
data/<namespace>/reactions/**/*.json
{
"type": "default",
"event": "player_attack_entity",
"phase": "post",
"priority": 100,
"conditions": [],
"sequence": []
}Higher numeric priority is evaluated first within the same event and phase. All qualifying default reactions may react. Only the first qualifying control reaction claims cancellation or override control.
Reaction Types
default
Observe the event and queue the JSON sequence without changing the underlying event.
override
In pre/during phases, suppress the normal event implementation and use the reaction sequence as replacement behavior.
cancel
In pre/during phases, cancel the actual event when the registered runtime hook is cancellable.
type: "default" because the underlying event has already returned.Current Registered Event
| Event | Phases | Cancel | Override | Context |
|---|---|---|---|---|
player_attack_entity | pre, during, post | yes | yes | attacked entity |
The hook wraps the normal client entity-attack call, so it observes both human attacks and DAI attacks that use the same vanilla path. A post event means the client attack call completed; it is not a server acknowledgement that damage was accepted.
Reaction Context Conditions
reaction_active reaction_event reaction_phase reaction_has_entity reaction_entity_type reaction_entity_living reaction_entity_health
{
"type": "reaction_entity_living",
"operator": "is_true"
}Static Screen Sprites
{
"type": "overlay_sprite",
"sprite": {
"id": "combat_pow",
"texture": "my_pack:gui/combat/pow",
"anchor": "center",
"x": 70,
"y": -35,
"width": 96,
"height": 64,
"alpha": 0.8,
"color": "#FFFFFF",
"z": 20,
"ticks": 14,
"interactable": true,
"click_action": "my_pack:pow_clicked",
"consume_click": false
}
}Texture my_pack:gui/combat/pow resolves to assets/my_pack/textures/gui/combat/pow.png in an enabled resource pack.
Animated Sprite Sheets
Sprite sheets are a separate action type from static sprites. DAI reads a tightly packed frame grid and advances it using explicit frame timing.
{
"type": "overlay_sprite_sheet",
"sprite_sheet": {
"id": "animated_pow",
"texture": "my_pack:gui/combat/pow_sheet",
"anchor": "center",
"x": 0,
"y": -40,
"width": 96,
"height": 96,
"alpha": 0.75,
"color": "#FFF2A8",
"z": 30,
"ticks": 80,
"interactable": true,
"click_action": "my_pack:animated_pow_clicked",
"consume_click": false,
"animation": {
"frame_width": 64,
"frame_height": 64,
"frame_count": 8,
"columns": 4,
"frame_ticks": 2,
"loop": true
}
}
}Layering, Transparency & Interaction
alphais authored from 0.1 through 1.0.colormultiplies/tints the texture and accepts#RRGGBBor#AARRGGBB.- Higher
zrenders above lowerz. - Equal-z layers use insertion order, newest on top.
- Hit testing runs from visually highest layer downward.
interactabledefaults to false.consume_clickdefaults to false. When false, lower overlays and underlying UI may still receive the click.
z = 10 base aura alpha 1.0 z = 11 blue tint alpha 0.4 z = 12 animated spark alpha 0.7
Removing Layers
{
"type": "overlay_remove",
"action": "combat_pow"
}{
"type": "overlay_clear"
}Example: Comic Effect After an Attack
{
"type": "default",
"event": "player_attack_entity",
"phase": "post",
"priority": 100,
"conditions": [
{
"type": "reaction_entity_living",
"operator": "is_true"
}
],
"sequence": [
{
"type": "overlay_sprite",
"sprite": {
"id": "pow",
"texture": "dai_comic_fx:gui/combat/static/pow",
"anchor": "center",
"x": 50,
"y": -30,
"width": 128,
"height": 80,
"alpha": 1.0,
"color": "#FFFFFF",
"z": 20,
"ticks": 12,
"interactable": false,
"consume_click": false
}
}
]
}