Uploaded image for project: 'Minecraft (Bedrock codebase)'
  1. Minecraft (Bedrock codebase)
  2. MCPE-157652

damage_sensor component can't run events on "damager" target

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • None
    • 1.19.0, 1.20.40.22 Preview, 1.20.30
    • None
    • Confirmed
    • Windows
    • 853467

      The bug

      Damage sensors have access to three relevant entities:

      • self: the entity taking damage
      • damager: the entity dealing damage
      • other: the entity responsible for the damage
        For melee attacks, damager and other are identical. For ranged attacks, damager is the projectile, and other is the shooter.

      filters can access all three of these, to check for various conditions. However, target (for events) only works with self and other – when using damager, nothing happens.
      This makes it impossible to run events on a damaging projectile!

      Example

      "minecraft:damage_sensor": {
         "triggers": {
            "cause": "entity_attack",
            "on_damage": {
               "target": "damager", // this doesn't work
               "event": "explode"
            },
            "deals_damage": false
         }
      }
      

      How to reproduce

      1. Download and open the attached world
      2. Punch the pig and the sheep

      Expected behavior
      The player says "HELLO" when punching either entity. The damage sensors are entirely identical, except one tries to run the event on other and one on damager. Both events use a filter that references damager, proving that damager successfully exists and works correctly in one context but not the other.

      Actual behavior
      Only the pig works

            tryashtar [Mod] tryashtar
            Votes:
            2 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              CHK: