mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-08 09:17:36 +01:00
Added get/setLastDamageCause. Thanks sunkid!
By: EvilSeph <evilseph@unaligned.org>
This commit is contained in:
parent
940c9f9974
commit
12a93a05ff
@ -3,6 +3,7 @@ package org.bukkit.entity;
|
|||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Server;
|
import org.bukkit.Server;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
|
import org.bukkit.event.entity.EntityDamageEvent;
|
||||||
import org.bukkit.util.Vector;
|
import org.bukkit.util.Vector;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -169,4 +170,16 @@ public interface Entity {
|
|||||||
*/
|
*/
|
||||||
public void setFallDistance(float distance);
|
public void setFallDistance(float distance);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Record the last {@link EntityDamageEvent} inflicted on this entity
|
||||||
|
* @param event a {@link EntityDamageEvent}
|
||||||
|
*/
|
||||||
|
public void setLastDamageCause(EntityDamageEvent event);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieve the last {@link EntityDamageEvent} inflicted on this entity. This event may have been cancelled.
|
||||||
|
* @return the last known {@link EntityDamageEvent} or null if hitherto unharmed
|
||||||
|
*/
|
||||||
|
public EntityDamageEvent getLastDamageCause();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -14,15 +14,15 @@ public class EntityDamageEvent extends EntityEvent implements Cancellable {
|
|||||||
private DamageCause cause;
|
private DamageCause cause;
|
||||||
|
|
||||||
public EntityDamageEvent(Entity damagee, DamageCause cause, int damage) {
|
public EntityDamageEvent(Entity damagee, DamageCause cause, int damage) {
|
||||||
super(Event.Type.ENTITY_DAMAGE, damagee);
|
this(Event.Type.ENTITY_DAMAGE, damagee, cause, damage);
|
||||||
this.cause = cause;
|
|
||||||
this.damage = damage;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected EntityDamageEvent(Event.Type type, Entity damagee, DamageCause cause, int damage) {
|
protected EntityDamageEvent(Event.Type type, Entity damagee, DamageCause cause, int damage) {
|
||||||
super(type, damagee);
|
super(type, damagee);
|
||||||
this.cause = cause;
|
this.cause = cause;
|
||||||
this.damage = damage;
|
this.damage = damage;
|
||||||
|
|
||||||
|
damagee.setLastDamageCause(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user