mirror of
https://github.com/Minestom/Minestom.git
synced 2024-12-28 12:07:42 +01:00
Allow custom EntityCreature death animation time
This commit is contained in:
parent
3f487f4f4f
commit
d5e5412309
@ -28,6 +28,8 @@ import java.util.function.Supplier;
|
|||||||
|
|
||||||
public abstract class EntityCreature extends LivingEntity implements NavigableEntity {
|
public abstract class EntityCreature extends LivingEntity implements NavigableEntity {
|
||||||
|
|
||||||
|
private int removalAnimationDelay = 1000;
|
||||||
|
|
||||||
// TODO all pathfinding requests should be process in another thread
|
// TODO all pathfinding requests should be process in another thread
|
||||||
private final Object pathLock = new Object();
|
private final Object pathLock = new Object();
|
||||||
|
|
||||||
@ -149,8 +151,13 @@ public abstract class EntityCreature extends LivingEntity implements NavigableEn
|
|||||||
public void kill() {
|
public void kill() {
|
||||||
super.kill();
|
super.kill();
|
||||||
|
|
||||||
// Needed for proper death animation (wait for it to finish before destroying the entity)
|
if (removalAnimationDelay > 0) {
|
||||||
scheduleRemove(1000, TimeUnit.MILLISECOND);
|
// Needed for proper death animation (wait for it to finish before destroying the entity)
|
||||||
|
scheduleRemove(removalAnimationDelay, TimeUnit.MILLISECOND);
|
||||||
|
} else {
|
||||||
|
// Instant removal without animation playback
|
||||||
|
remove();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -214,6 +221,27 @@ public abstract class EntityCreature extends LivingEntity implements NavigableEn
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the kill animation delay before vanishing the entity.
|
||||||
|
*
|
||||||
|
* @return the removal animation delay in milliseconds, 0 if not any
|
||||||
|
*/
|
||||||
|
public int getRemovalAnimationDelay() {
|
||||||
|
return removalAnimationDelay;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Changes the removal animation delay of the entity.
|
||||||
|
* <p>
|
||||||
|
* Testing shows that 1000 is the minimum value to display the death particles.
|
||||||
|
*
|
||||||
|
* @param removalAnimationDelay the new removal animation delay in milliseconds, 0 to remove it
|
||||||
|
*/
|
||||||
|
public void setRemovalAnimationDelay(int removalAnimationDelay) {
|
||||||
|
this.removalAnimationDelay = removalAnimationDelay;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the goal selectors of this entity.
|
* Gets the goal selectors of this entity.
|
||||||
*
|
*
|
||||||
|
Loading…
Reference in New Issue
Block a user