Solved Get when a player/entity is actually damaged

Discussion in 'Plugin Development' started by Hedgehogs4Me, Sep 1, 2014.

Thread Status:
Not open for further replies.
  1. Offline


    This is going to seem unbelievably basic, but I've been having problems with it, and I can't even find a thread for it. It could be that I'm using the event wrong or something, I don't really know.

    It seems that EntityDamageEvent and EntityDamageByEntityEvent event both fire regardless of whether the player actually takes damage - that is, EntityDamageByEntityEvent fires whenever you click a player, even if they're in that red cooldown state where they can temporarily not be damaged.

    Is there any way I could check when they're actually taking damage, or at the very least check if they're in that cooldown state? I've tried using event.getDamage() and checking if it's 0, but it seems that doesn't work either - it still thinks the damage is non-0 until it actually tries applying the damage to the player (i.e. after the event fires).

    What should I be using, ProtocolLib and packets to check when the client is being sent an indication that damage has been dealt (PacketType.Play.Server.NAMED_SOUND_EFFECT or something)? Surely there must be an easier solution, right?
  2. Offline


  3. Offline


  4. Offline


    xTigerRebornx How late are we talking? We're running a 1.7.9 version of Spigot, so unless they really just fixed it now, we should be golden, right?
    Thanks for the workaround from McMMO, though, that looks pretty much like what I'm looking for! Any idea why this is there, though?:
    1. eventDamage <= entity.getLastDamage()

    GreySwordz We already use that in our code - it basically just detects whether the attacker is punching with weakness, nothing else! See the original post:
  5. Offline


  6. Offline


    Third party forks are not supported on these forums. Please find support where ever you downloaded it :3.
  7. Offline


    fireblast709 Sorry 'bout that, didn't realize how strict the rule was. I understand, though. :)

    In other news, wow, I cannot read comments. If another person searches this thread up or something and can't understand the McMMO code, it literally says exactly what I was wondering 3 lines up from the linked line:

    TIL. I wonder if that's been changed in Vanilla Minecraft since that was written, it seems like a very odd mechanic.
    Anyway, marking this as solved. Thanks guys!
  8. Offline


Thread Status:
Not open for further replies.

Share This Page