#1144: Add more Guardian API, particularly for its laser

By: Parker Hawke <hawkeboyz2@hotmail.com>
This commit is contained in:
CraftBukkit/Spigot
2023-04-02 13:49:05 +10:00
parent 257f5ad3e8
commit df5cb9bc3a
2 changed files with 48 additions and 0 deletions

View File

@@ -1,5 +1,6 @@
package org.bukkit.craftbukkit.entity;
import com.google.common.base.Preconditions;
import net.minecraft.world.entity.monster.EntityGuardian;
import org.bukkit.craftbukkit.CraftServer;
import org.bukkit.entity.EntityType;
@@ -8,6 +9,8 @@ import org.bukkit.entity.LivingEntity;
public class CraftGuardian extends CraftMonster implements Guardian {
private static final int MINIMUM_ATTACK_TICKS = -10;
public CraftGuardian(CraftServer server, EntityGuardian entity) {
super(server, entity);
}
@@ -58,6 +61,27 @@ public class CraftGuardian extends CraftMonster implements Guardian {
return getHandle().hasActiveAttackTarget();
}
@Override
public int getLaserDuration() {
return getHandle().getAttackDuration();
}
@Override
public void setLaserTicks(int ticks) {
Preconditions.checkArgument(ticks >= MINIMUM_ATTACK_TICKS, "ticks must be >= %s. Given %s", MINIMUM_ATTACK_TICKS, ticks);
EntityGuardian.PathfinderGoalGuardianAttack goal = getHandle().guardianAttackGoal;
if (goal != null) {
goal.attackTime = ticks;
}
}
@Override
public int getLaserTicks() {
EntityGuardian.PathfinderGoalGuardianAttack goal = getHandle().guardianAttackGoal;
return (goal != null) ? goal.attackTime : MINIMUM_ATTACK_TICKS;
}
@Override
public boolean isElder() {
return false;
@@ -67,4 +91,9 @@ public class CraftGuardian extends CraftMonster implements Guardian {
public void setElder(boolean shouldBeElder) {
throw new UnsupportedOperationException("Not supported.");
}
@Override
public boolean isMoving() {
return getHandle().isMoving();
}
}