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

Calling LivingEntity#damage and setting a player as the source resets that player's attack cooldown

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Minor Minor
    • None
    • None
    • 3844-Spigot-b41c46d-c335a55 (MC: 1.20.1)
    • Yes

      As per the title. Can be tested with the following code and a player on the server.

      Player player = Bukkit.getWorlds().get(0).getPlayers().get(0);
      player.damage(0, player);
      Bukkit.getServer().broadcastMessage("" + player.getAttackCooldown());

      Note that commenting out the second line should result in an output of 1.0 assuming that the player's attack meter is fully charged. Otherwise, the result will be less than 1.

      I don't think this is the intended behaviour as the client will still display the player's attack cooldow meter as fully charged.

      Another thing that may be related is that when the damage function is called without a source, the damage cause of the EntityDamageEvent gets set to CUSTOM, however if a source is provided, then the cause gets set to ENTITY_ATTACK.

            Unassigned Unassigned
            DarkStar634 Dark Star
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: