[SPIGOT-5553] Ability to get the velocity added to the entity in EntityDamageEvent Created: 29/Jan/20 Updated: 27/Jan/24 Resolved: 27/Jan/24 |
|
Status: | Resolved |
Project: | Spigot |
Component/s: | None |
Affects Version/s: | None |
Fix Version/s: | None |
Type: | New Feature | Priority: | Minor |
Reporter: | Perzan | Assignee: | Unassigned |
Resolution: | Fixed | Votes: | 1 |
Labels: | EntityDamageEvent, Feature, Method, velocity | ||
Environment: |
Processor: Intel(R) Core(TM) i9-9900KS CPU @ 4.00GHz 4.01 GHz |
Version: | git-Spigot-037559e-5c6b0dc (MC: 1.15.1) (Implementing API version 1.15.1-R0.1-SNAPSHOT) |
Guidelines Read: | Yes |
Description |
A suggested method for EntityDamageEvent: This represents the velocity that was added to the victim's velocity when they were damaged. I suggest this method since I am working on a plugin that involves consistently multiplying the knock-back that one player does to another. I want to multiply the knock-back because:
If John acquires a Knockback-2 sword and his "power level" multiplies his abilities by 10, his power level will enhance the knock-back energy delivered by the sword by ten-times. It will not add. This is why it can sometimes be important to know how much velocity is added to the entity when it is damaged. I am unsure as to how this can apply to EntityDamageEvent aside from EntityDamageByEntityEvent. I have tried to think about cases where anything that isn't an entity can knock an entity back by damaging it, but I don't seem to recall any. Damage sources such as lava, magma blocks, sweet berry bushes, etc will just return 0 for this method? Maybe in the future these causes might contribute knockback for some reason. |
Comments |
Comment by md_5 [ 27/Jan/24 ] |
Addressed by EntityKnockbackEvent |
Comment by Perzan [ 29/Jan/20 ] |
I see that PlayerVelocityEvent exists, but not EntityVelocityEvent. If EntityVelocityEvent existed, PlayerVelocityEvent might not be able to extend it because it is based on PlayerEvent which has "getPlayer()" rather than "getEntity()". I'm sure a refactoring of this system is the last thing anyone wants, but perhaps maybe have EntityVelocityEvent as a separate event? Nothing will get extended here, but it might have a method like "getCause()" which returns a constant from an enum called "VelocityCause". VelocityCause might have some of these:
I will put more thought into what these enum names should be tomorrow since it's late for me. |
Comment by md_5 [ 29/Jan/20 ] |
Extremely unlikely to go in the damage event, that event is impossible to maintain. Could be a separate event. |