Uploaded image for project: 'Spigot'
  1. Spigot
  2. SPIGOT-7405

Reported damage event damage cause does not match one specified when using new /damage command

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Minor Minor
    • None
    • None
    • 3811-Spigot-c62f4bd-85b89c3 (MC: 1.20.1)
    • Yes

      The following was tested on a minimal Spigot 1.20.1 server setup without plugins.

      1.19.4 introduced a new `damage` command. It can be used to simulate damage of a specific type being dealt to entities, and optionally being dealt by a specified entity. An example is as follows:   

      /damage @s 5 minecraft:dragon_breath

      This should damage the player by 5 using dragon breath as the damage type, without an entity as the damager. This works correctly from a damage calculation perspective, but then when listening for the damage event, the damage is reported as `DamageCause.CUSTOM` rather than the expected and existing `DamageCause.DRAGON_BREATH`:

      There are further arguments to specify the damager as follows:

      /damage @s 5 minecraft:dragon_breath by @s

      This simulates the player damaging themselves by 5 using dragon breath.

      This correctly fires an `EntityDamageByEntityEvent`, but this time the damage cause is reported as `DamageCause.ENTITY_ATTACK`, when again I would expect `DamageCause.DRAGON_BREATH`:

      Changing the entity causes a similar issue but with different damage types. For example, if I use the command to make an arrow damage me instead of myself, the damage is `DamageCause.PROJECTILE`.

      I assume the server is doing its own internal logic based on the scenario and entities involved to determine the damage type, but it seems like when the damage is being sourced through the damage command, the damage type should just be mapped to the most similar `DamageCause` available. Alternatively, the vanilla damage type could be exposed on the damage event if possible.

      As-is, we lose most of the usefulness of the command as it relates to content creation.

            Doc Doc
            Mr_Simba Jake Ben-Tovim
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: