mirror of
https://github.com/Minestom/Minestom.git
synced 2025-01-04 23:47:59 +01:00
Added #setFireForDuration(Duration)
This commit is contained in:
parent
cda5860440
commit
3e0486cfd3
@ -328,10 +328,20 @@ public class LivingEntity extends Entity implements EquipmentHandler {
|
||||
* @see #setOnFire(boolean) if you want it to be permanent without any event callback
|
||||
*/
|
||||
public void setFireForDuration(int duration, TemporalUnit temporalUnit) {
|
||||
EntityFireEvent entityFireEvent = new EntityFireEvent(this, temporalUnit.getDuration().multipliedBy(duration));
|
||||
setFireForDuration(Duration.of(duration, temporalUnit));
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets fire to this entity for a given duration.
|
||||
*
|
||||
* @param duration duration of the effect
|
||||
* @see #setOnFire(boolean) if you want it to be permanent without any event callback
|
||||
*/
|
||||
public void setFireForDuration(Duration duration) {
|
||||
EntityFireEvent entityFireEvent = new EntityFireEvent(this, duration);
|
||||
|
||||
// Do not start fire event if the fire needs to be removed (< 0 duration)
|
||||
if (duration > 0) {
|
||||
if (duration.toMillis() > 0) {
|
||||
EventDispatcher.callCancellable(entityFireEvent, () -> {
|
||||
final long fireTime = entityFireEvent.getFireTime(TimeUnit.MILLISECOND);
|
||||
setOnFire(true);
|
||||
|
Loading…
Reference in New Issue
Block a user