-
-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Labels
Description
Is your feature request related to a problem?
below is the setHealth method
public void setHealth(double health) {
health = (float) health;
// Paper start - Be more informative
Preconditions.checkArgument(health >= 0 && health <= this.getMaxHealth(),
"Health value (%s) must be between 0 and %s. (attribute base value: %s%s)",
health, this.getMaxHealth(), this.getHandle().getAttribute(Attributes.MAX_HEALTH).getBaseValue(), this instanceof CraftPlayer ? ", player: " + this.getName() : ""
);
// Paper end
// during world generation, we don't want to run logic for dropping items and xp
if (this.getHandle().generation && health == 0) {
this.getHandle().discard(null); // Add Bukkit remove cause
return;
}
this.getHandle().setHealth((float) health);
if (health == 0) {
this.getHandle().die(this.getHandle().damageSources().generic());
}
}When I need to set an entity's health to 0 and provide a valid damage source, I have to reinvent the method myself with nms codes or the death will be sourceless, and many plugins tracking it will miss the "killer".
There are many rpg servers have the same problem with me, they probably have the "true damage" mechanic that do damage which ignores entity's defenses. Then they'll use sethealth but they can't set damagesource in the death event.
Describe the solution you'd like.
expose the damage source parameter in die method so you can do things like setHealth(0, source)
Describe alternatives you've considered.
use nms codes
Other
No response
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
Type
Fields
Give feedbackNo fields configured for Feature.