Damaging an Entity without calling an Event

Discussion in 'Plugin Development' started by WEEEEEE, Jul 23, 2014.

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

    WEEEEEE

    livingEnttiy.damage method calls edby event, which i dont want to. i've searching trough nms and i found the method which is called: http://pastie.org/9414424 its in net.minecraft.server...EntityLiving
    I guess ill have to rewrite this method. i know i can simpy set entity health but what should i do if i need to keep default armor damage reduction?
     
  2. Offline

    JuicyDev

    Why do you want to damage the entity without calling the event? It will reduce compatibility with mechanics altering plugins.
     
  3. Offline

    WEEEEEE

    thats exactly what i want.... just dont ask why i'm trying to do this...
     
  4. Offline

    Dragonphase

    WEEEEEE

    Whatever your reason for doing this, it's still a bad idea to disable events from being called. Try canceling the event after the event is called.
     
  5. Offline

    WEEEEEE

    1) how am i supposed to do that?
    - replace method body with hotspwap? and how will hotswap work with bukkit, it will morelike breaks everything... i dont want to inherit from from EntityLiving class and rewrite almost everything only because of one method. wrapper class wont help in this case.
    - if i cancell the event (as you can see at line 25) no damage will be dealt, which is fine but then again it wont help me.

    Seems like i have to change my question: where should i look at if i want to get math formula/nms class/... for damage reduction from armor.
     
  6. Offline

    EcMiner

    What you could also do is listen for the entitydamage(byentity)event and set it's priority to monitor and then do setCancelled(false) this will make sure that the damage will still be dealt even though another plugin is blocking it, like worldguard, you might want to add some kind of check if you want this damage to be dealt even if the event is cancelled
     
  7. Offline

    JuicyDev

    Do the damage calculations get done before the damage event? If so you could damage the player, then cancel the event and set the player's health to their current health - the damage.
     
  8. Offline

    JuicyDev

    AdamQpzm likes this.
Thread Status:
Not open for further replies.

Share This Page