Stripping Down EntityDamageEvent - DamageModifier

Discussion in 'API Discussion' started by md_5, Nov 19, 2016.


Remove DamageModifier API?

  1. Yes

  2. No

Results are only viewable after voting.
  1. MiniDigger


    That's not right. My current project is over 26k LOC (I think that would qualify as complex, lol) and I only use like 5 lines of nms: to send the player a json string as message without parsing it into spigots chat api.
    You can avoid nms quite easily if you know what you are doing.
  2. I suggest adding the ability to deal any damage type (potion damage, projectile damage, regular hit damage, etc.) and allow us to disable or enable individual damage modifiers in the damage event (a.k.a. disable or enable the effect of armor, potion effects, and armor enchants on damage). So you don't really need to rewrite a lot of code and it's just a yes/no flag.
    • Agree Agree x 2
  3. We should agree that this heavily depends on the task that you perform. Also you can "avoid" using NMS code by using libraries instead (hi ProtocolLib), but in the end it still counts.
  4. MiniDigger


    The goal is less maintenance. Relying on protocol lib (which is written in a way it requires basically zero maintenance) will force you do to less maintenace on your own code.
    Really like this quote

    But yeah, if depends on what you want to do. You still need nms for stuff like Pathfinders rn (but if the continue to poke @2008Choco about it that might change soonish <3)
    • Friendly Friendly x 1
  5. Hi.

    I see that EntityDamageByEntityEvent not taking the DamageModifiers arguments (only taking the double damage) has been deprecated.

    I also see that DamageModifier have been deprecated as well.

    How are we supposed to create new entity damage by hand ? I see in one of the last messages that there are no API planned for that right now. Is the best way to deal with all custom damage really to completely rewrite the Bukkit one ? (that is, if we don't want to use deprecated methods)
    #105 Weby, Jul 29, 2018
    Last edited: Jul 29, 2018
  6. md_5

    Administrator Developer

    What are you asking exactly? There are non deprecated APIs to damage entities.
  7. upload_2018-7-29_10-32-31.png

    For example, the first line is what I've been using until 1.12.

    Now, EntityDamageByEntityEvent (as well as the EntityDamageEvent) with only the damage value is deprecated, so I've been trying to use the NON deprecated one (that is overly complicated thanks to all those damagemodifiers things), and, as you can see, the EntityDamageEvent.DamageModifier enum is also deprecated.

    How am I supposed to create that event now, or to achieve the same result ?

    I am aware that using deprecated methods doesn't "break" anything, but I am also an advocate of forwards compatibility and "don't do it twice" concept, which is almost impossible with the bukkit/spigot API for some things :)

    With that method, we are trying to create our own hit queue (to compensate for connection latency and add a few extra features). It works fairly well if the latency stays under ~300ms, so it'd be a shame to have to remove this, which would be a major step back for our player base.
  8. md_5

    Administrator Developer

    I’ll look into removing deprecation on the first one
  9. Do not call Events by yourself. It won’t do anything.
  10. MiniDigger


    That's not true. It will call all registered listeners. It will not damage the entity if non of the listeners do that but since he already used the code before I am sure he is well aware of that ;)
  11. Thank you very much :)

    At least some people seem to know what they're talking about here ;)
    Using the Bukkit API's damage events also gives the opportunity for other plugins (ie: not coded by me) to cancel said events for whatever reason. Easiest example I have in mind is WorldGuard. It's one of the three options that I had, the other two being writing a wrapper around those methods (which essentially results in calling them anyway) or not using any 3rd party plugin at all.

    Goodbye Houston. Thanks for trying.
  12. Is there another options to change whole damage mechanics? What I mean of "damage mechanics", that for example, changes to behaviour of protection enchantment allowing absorbtion more than 80% of damage to give significance for enchantments higher than "Protection IV".

    P.S. I mean, that my changes should not be break other mechanics like absorption hearts or resistance potion effect.
    #112 CraftCoder, Dec 7, 2019
    Last edited: Dec 7, 2019