Page 7 · Overlays & Reactions

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.

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.

Current Registered Event

EventPhasesCancelOverrideContext
player_attack_entitypre, during, postyesyesattacked 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
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.