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.
    • Agree Agree x 2
  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 3
  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.
    • Funny Funny x 2
  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
  13. blah blah blah "necroposting" ... I know I know.

    I am replying to this thread, because it was listed in the Spigot API.

    I started reading it, and holy shit, the attitude and self righteousness of you @md_5 is just mind blowing.

    I read a good chunk of this thread, and decided to stop, because every response from you is like a slap in everyones face:

    People we're reading and responding. Maybe not to YOUR satisfaction. IF you want a specific reply, I recommend writing a new wiki, titled
    "How md_5 prefers you to reply to him"
    just a few messages into that thread, and geeze ... tone it down bud.

    I see this as "you can help us by contributing to the project" ... but then:
    "don't bother, you all do such a shitty job"
    the way you speak to people.... who the hell do you think you are?
    Do you think you are some kind of lord and saviour who saved Minecraft after the DMCA takedown because you single handedly keep Bukkit/CB alive? (Spoiler alert, you didn't .. for years several people helped you!)

    On that note I can't even count all of your snarky responses to PRs I have made. I did that one for RegionalDifficulty (because I wanted to use it in 2 plugins)... even with a giant paragraph and a link to McWiki, you still told me to add a better description to the method I was adding, because it didn't meet Bukkit's YOUR expectations.
    I did another PR for the owner/thrower of an Item entity, and you had a few messages being super condescending "well how does one use this? what is it used for?" ... can you step back for a second and look at the less than adequate crap you have written in the API.
    I deal with people day in and day out who don't know what methods do, because you have written next to nothing for them ... "this method returns something" gee thanks.

    I have had several people in many communities mention how they don't want to do PRs because of your bitchy attitude.
    I have even had people ask ME to do said PR, because they don't want to deal with your snarky responses on their PRs, belittling them, making them feel subpar

    Why do people feel this way?
    3) When people try to add API they often do a terrible job
    Get over yourself.

    If its so hard to maintain... then why in gods name did you make this thread?
    "Should I delete this API? Im going to cause I can't fix it... but should I?"
    What exactly is your question?

    If you can't figure it out, then just remove it. The people who CAN do PRs don't want to deal with YOU!!!

    This is no longer the Bukkit/Spigot project, its the md_5 project.

    Its no longer an open source project, because people feel like utter shit when attempting to do a PR and having you belittle them with your condescending bullshit.
    As soon as snapshot season rolls around, you close off the source on your private computer/repo and start working on it. And you give us a million lame excuses as to why its not public... most of these excuses just sound whiny "oh I don't want people crying that their servers don't work"
    Sounds more like you do this so when its rolled out, you can get all the praises you need for validation, and you can keep acting like you single handedly keep this alive.

    But then you have threads like this saying people should contribute to YOUR project?!?!!
    Maybe start acting like its an open source project again, and maybe people will contribute ... but when we see:
    3) When people try to add API they often do a terrible job
    We don't want to contribute to YOUR project.

    "This code is so stupidly unmaintainable," <-- ^ .... so then remove it!

    So remove it!?!?! why this thread? What is your question?
    You're asking people if you should remove it or not, but I feel like your poll is
    a) Yes, Remove it
    b) Yes, Remove it (but in blue)

    Probably not going to happen, because (see above) no one wants to PR to your project, because of your attitude. You are by far the most self rightous, stuck up person on this entire forum, and no one wants to have you belittling them, feeling like an incompentend dev, because you for some unknown reason, seem to think you're some godly, top notch lord dev who saved Minecraft.

    ^ ^ ^ ^ ^^ ^^^ ^ ^^ ^ ^. ^

    ok, that's all I read, couldn't take your responses anymore.

    I know some may be thinking "Woahhhh Shane... that was intense"
    Was it?
    Cause I think everyone is afraid to speak there mind here on SpigotMC because anytime someone speaks the truth .... thread magically disappears, and/or gets locked by a mod!
    No one wants to call md_5 out on his bs because they don't want the wrath raining down on them.
    #113 ShaneBee, Jan 22, 2021
    Last edited: Jan 22, 2021
    • Winner x 6
    • Like x 2
    • Agree x 1
    • Informative x 1
    • Friendly x 1
  14. It really is just a programmer thing I think. On all forums, but mostly ones with programmers, they often just talk down to each other and don't always remember we're all human. We all fall into that pit sometimes. I've been seeing it so much now, but at least here it isn't as bad as StackOverflow (that place is so toxic)

    I personally have never seen anything where mods have deleted threads because of bad feedback, so I can't really comment on it but a lot of the interactions I've had with mods have been positive.

    And to finish it off, yes, I do agree that sometimes md_5 can be... "intense" at points.
    • Agree Agree x 1
  15. I'm also posting because it was listed on the api page.

    Basically all I'm wanting to do with my plugin is have a minimum final damage no matter the damage type, Ive made several tries but its turned out a bit more complicated than I realized. I poked around on Google and found this thread from 2015

    which explains to use setDamage(DamageModifier, double) to remove all modifiers and then set the base damage to what you want. This is a bit sad because if this is being removed, and as a developer I understand the situation of maintaining problematic code. Then I don't really know what to do as an alternative.

    From what I'm understanding I just have to delete the plugin for my server because I'm guessing there isn't any alternative. You can't set the finalDamage and if you want to do it manually that's being removed from you.

    idk I guess I'm just trying to contribute to this discussion with a use case of mine but I understand it's going to be removed anyways. I'm hoping others may shed light on alternative non-deprecated ways of setting the final damage if this is def going to be removed.
  16. Ah, you have awoken the sacred thread.

    Why don't you cancel the event and set the players health manually? Or check if the final damage is less than your minimum and if so, set the players health manually?
    • Like Like x 1
  17. Well I did try that in one of my iterations but for some reason it lead to not only the lack of damage animation and sound but also the lack of damage. Also this is for any Damageable entity, not just players. I'd post the code that I did but I've already re-written it several times since then with other attempts.

    What I'll just do is use the deprecated API because it works beautifully and I've been at that for about 2 hours so I'm tired of rewriting the event with different attempts. Once the api is removed I'll either visit other fixes or just delete the plugin as it's not the end of the world if I do.

    Yes, I have revived the sacred thread lol. Apologies. I wasn't really asking for help specifically, I was more contributing to the reasons why I enjoy that piece of the api and hopefully trying to get more alternatives answered here for other people and probably myself in the future to come across after it is removed.