Page 8 · Presentation

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.

3 Reaction Typesdefault, override, and cancel.
3 Event Phasespre, during, and post.
Layered PresentationSprites, sheets, tint, alpha, z-order, and click actions.
DAI 1.8: This system now participates in the client/server architecture. Client-facing definitions can load locally; actions that mutate authoritative server state should use the server action layer.

Reaction Files

data/<namespace>/reactions/**/*.json
Basic reaction
{
  "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.

POST is observation-only. A post reaction must use type: "default" because the underlying event has already returned.

Built-In Reaction Events

EventPhasesCancelOverrideContext
player_attack_inputpre, during, postyesyesphysical LMB before hit resolution
player_input_tickpre, during, postnonocurrent physical input state
player_attack_entitypre, during, postyesyesentity
player_use_blockpre, during, postyesyesblock + item
player_use_itempre, during, postyesyesitem
player_interact_entitypre, during, postyesyesentity + item
player_start_break_blockpre, during, postyesyesblock + 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

Universal left-click override
{
  "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
Only react to living attack targets
{
  "type": "reaction_entity_living",
  "operator": "is_true"
}

Static Screen Sprites

overlay_sprite
{
  "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.

overlay_sprite_sheet
{
  "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

  • alpha is authored from 0.1 through 1.0.
  • color multiplies/tints the texture and accepts #RRGGBB or #AARRGGBB.
  • Higher z renders above lower z.
  • Equal-z layers use insertion order, newest on top.
  • Hit testing runs from visually highest layer downward.
  • interactable defaults to false.
  • consume_click defaults 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

Remove one
{
  "type": "overlay_remove",
  "action": "combat_pow"
}
Clear all
{
  "type": "overlay_clear"
}

Example: Comic Effect After an Attack

Reaction
{
  "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
      }
    }
  ]
}
Execution stays queue-safe. Reaction conditions/control decisions happen synchronously at the event phase, while reaction sequences are queued into DAI's normal one-semantic-action-per-tick runtime.

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.