mirror of
https://github.com/Minestom/Minestom.git
synced 2025-01-04 23:47:59 +01:00
Updated LivingEntity.java
This commit is contained in:
parent
58bae20f10
commit
384c556caf
@ -30,11 +30,14 @@ import net.minestom.server.utils.Position;
|
||||
import net.minestom.server.utils.Vector;
|
||||
import net.minestom.server.utils.block.BlockIterator;
|
||||
import net.minestom.server.utils.time.Cooldown;
|
||||
import net.minestom.server.utils.time.Tick;
|
||||
import net.minestom.server.utils.time.TimeUnit;
|
||||
import net.minestom.server.utils.time.UpdateOption;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.time.Duration;
|
||||
import java.time.temporal.ChronoUnit;
|
||||
import java.time.temporal.TemporalUnit;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
@ -42,7 +45,7 @@ public class LivingEntity extends Entity implements EquipmentHandler {
|
||||
|
||||
// ItemStack pickup
|
||||
protected boolean canPickupItem;
|
||||
protected Cooldown itemPickupCooldown = new Cooldown(new UpdateOption(5, TimeUnit.TICK));
|
||||
protected Cooldown itemPickupCooldown = new Cooldown(Duration.of(5, Tick.SERVER_TICKS));
|
||||
|
||||
protected boolean isDead;
|
||||
|
||||
@ -316,23 +319,23 @@ public class LivingEntity extends Entity implements EquipmentHandler {
|
||||
* @param duration duration in ticks of the effect
|
||||
*/
|
||||
public void setFireForDuration(int duration) {
|
||||
setFireForDuration(duration, TimeUnit.TICK);
|
||||
setFireForDuration(duration, Tick.SERVER_TICKS);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets fire to this entity for a given duration.
|
||||
*
|
||||
* @param duration duration of the effect
|
||||
* @param unit unit used to express the duration
|
||||
* @param temporalUnit unit used to express the duration
|
||||
* @see #setOnFire(boolean) if you want it to be permanent without any event callback
|
||||
*/
|
||||
public void setFireForDuration(int duration, TimeUnit unit) {
|
||||
EntityFireEvent entityFireEvent = new EntityFireEvent(this, duration, unit);
|
||||
public void setFireForDuration(int duration, TemporalUnit temporalUnit) {
|
||||
EntityFireEvent entityFireEvent = new EntityFireEvent(this, temporalUnit.getDuration().multipliedBy(duration));
|
||||
|
||||
// Do not start fire event if the fire needs to be removed (< 0 duration)
|
||||
if (duration > 0) {
|
||||
EventDispatcher.callCancellable(entityFireEvent, () -> {
|
||||
final long fireTime = entityFireEvent.getFireTime(TimeUnit.MILLISECOND);
|
||||
final long fireTime = entityFireEvent.getFireTime(ChronoUnit.MILLIS);
|
||||
setOnFire(true);
|
||||
fireExtinguishTime = System.currentTimeMillis() + fireTime;
|
||||
});
|
||||
@ -659,7 +662,7 @@ public class LivingEntity extends Entity implements EquipmentHandler {
|
||||
* Gets the time in ms between two fire damage applications.
|
||||
*
|
||||
* @return the time in ms
|
||||
* @see #setFireDamagePeriod(long, TimeUnit)
|
||||
* @see #setFireDamagePeriod(long, TemporalUnit)
|
||||
*/
|
||||
public long getFireDamagePeriod() {
|
||||
return fireDamagePeriod;
|
||||
@ -669,10 +672,10 @@ public class LivingEntity extends Entity implements EquipmentHandler {
|
||||
* Changes the delay between two fire damage applications.
|
||||
*
|
||||
* @param fireDamagePeriod the delay
|
||||
* @param timeUnit the time unit
|
||||
* @param temporalUnit the time unit
|
||||
*/
|
||||
public void setFireDamagePeriod(long fireDamagePeriod, @NotNull TimeUnit timeUnit) {
|
||||
fireDamagePeriod = timeUnit.toMilliseconds(fireDamagePeriod);
|
||||
public void setFireDamagePeriod(long fireDamagePeriod, @NotNull TemporalUnit temporalUnit) {
|
||||
fireDamagePeriod = temporalUnit.getDuration().multipliedBy(fireDamagePeriod).toMillis();
|
||||
this.fireDamagePeriod = fireDamagePeriod;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user