Updated MeleeAttackGoal.java

This commit is contained in:
Németh Noel 2021-06-30 01:34:27 +02:00
parent b8b8a40a99
commit 68b94674d0

View File

@ -8,21 +8,23 @@ import net.minestom.server.entity.pathfinding.Navigator;
import net.minestom.server.utils.Position;
import net.minestom.server.utils.time.Cooldown;
import net.minestom.server.utils.time.TimeUnit;
import net.minestom.server.utils.time.UpdateOption;
import org.jetbrains.annotations.NotNull;
import java.time.Duration;
import java.time.temporal.TemporalUnit;
/**
* Attacks the entity's target ({@link EntityCreature#getTarget()}) OR the closest entity
* which can be targeted with the entity {@link TargetSelector}.
*/
public class MeleeAttackGoal extends GoalSelector {
private final Cooldown cooldown = new Cooldown(new UpdateOption(5, TimeUnit.TICK));
private final Cooldown cooldown = new Cooldown(Duration.of(5, TimeUnit.SERVER_TICK));
private long lastHit;
private final double range;
private final int delay;
private final TimeUnit timeUnit;
private final TemporalUnit timeUnit;
private boolean stop;
private Entity cachedTarget;
@ -33,7 +35,7 @@ public class MeleeAttackGoal extends GoalSelector {
* @param delay the delay between each attacks
* @param timeUnit the unit of the delay
*/
public MeleeAttackGoal(@NotNull EntityCreature entityCreature, double range, int delay, @NotNull TimeUnit timeUnit) {
public MeleeAttackGoal(@NotNull EntityCreature entityCreature, double range, int delay, @NotNull TemporalUnit timeUnit) {
super(entityCreature);
this.range = range;
this.delay = delay;