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.Built-In Reaction Events
| Event | Phases | Cancel | Override | Context |
|---|---|---|---|---|
player_attack_input | pre, during, post | yes | yes | physical LMB before hit resolution |
player_input_tick | pre, during, post | no | no | current physical input state |
player_attack_entity | pre, during, post | yes | yes | entity |
player_use_block | pre, during, post | yes | yes | block + item |
player_use_item | pre, during, post | yes | yes | item |
player_interact_entity | pre, during, post | yes | yes | entity + item |
player_start_break_block | pre, during, post | yes | yes | block + item |
DAI 4.1 adds player_attack_input before hit resolution and player_input_tick for continuous held/combo logic. DAI 4.1's block use, item use, entity interaction and start-break hooks remain available. A post event means the wrapped client call completed; it is not a server acknowledgement that the authoritative world accepted the action.
4.1 Physical Input Reactions
{
"type": "override",
"event": "player_attack_input",
"phase": "pre",
"conditions": [
{
"type": "held_content",
"string_value": "my_pack:ability_item",
"operator": "equals"
}
],
"sequence": [
{
"type": "run_function",
"action": "my_pack:ability/left_click"
}
]
}player_attack_input fires before Minecraft distinguishes entity attack, block break or empty-air swing, so an override can fully replace vanilla LMB behavior for a selected item. player_input_tick is intended for held-button combinations, charging and datapack-owned timing; combine it with the 4.1 keybind conditions.
Reaction Context Conditions
reaction_active reaction_event reaction_phase reaction_has_entity reaction_entity_type reaction_entity_living reaction_entity_health reaction_has_block reaction_block_id reaction_block_x / reaction_block_y / reaction_block_z reaction_has_item reaction_item_id
{
"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
}
}
]
}4.1 live overlay geometry
Text/button layers now join sprite/sprite-sheet overlays. Runtime actions can move, resize, re-z, lock, clamp and toggle interaction; conditions can test the mouse against live bounds.