mirror of
https://github.com/CitizensDev/Citizens2.git
synced 2025-02-05 15:01:26 +01:00
Allow flying NPCs to have their path set via command
This commit is contained in:
parent
3c9b42355f
commit
3896c67709
@ -10,7 +10,6 @@ import net.citizensnpcs.editor.EquipmentEditor;
|
||||
import net.citizensnpcs.trait.text.Text;
|
||||
import net.citizensnpcs.trait.waypoint.Waypoints;
|
||||
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@Requirements(selected = true, ownership = true)
|
||||
@ -48,8 +47,7 @@ public class EditorCommands {
|
||||
max = 1,
|
||||
flags = "*",
|
||||
permission = "citizens.npc.edit.path")
|
||||
@Requirements(selected = true, ownership = true, excludedTypes = { EntityType.BLAZE, EntityType.ENDER_DRAGON,
|
||||
EntityType.GHAST, EntityType.BAT, EntityType.WITHER, EntityType.SQUID })
|
||||
@Requirements(selected = true, ownership = true)
|
||||
public void path(CommandContext args, Player player, NPC npc) {
|
||||
Editor.enterOrLeave(player, npc.getTrait(Waypoints.class).getEditor(player, args));
|
||||
}
|
||||
|
@ -86,6 +86,7 @@ public class CitizensNavigator implements Navigator, Runnable {
|
||||
return executing != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPaused() {
|
||||
return paused;
|
||||
}
|
||||
@ -126,8 +127,9 @@ public class CitizensNavigator implements Navigator, Runnable {
|
||||
NavigationCompleteEvent event = new NavigationCompleteEvent(this);
|
||||
PathStrategy old = executing;
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
if (old == executing)
|
||||
if (old == executing) {
|
||||
stopNavigating(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -139,6 +141,7 @@ public class CitizensNavigator implements Navigator, Runnable {
|
||||
root.setBoolean("usedefaultstuckaction", defaultParams.stuckAction() == TeleportStuckAction.INSTANCE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPaused(boolean paused) {
|
||||
this.paused = paused;
|
||||
}
|
||||
|
@ -134,13 +134,15 @@ public class MCTargetStrategy implements PathStrategy, EntityTarget {
|
||||
|
||||
private class AStarTargeter implements TargetNavigator {
|
||||
private int failureTimes = 0;
|
||||
private AStarNavigationStrategy strategy = new AStarNavigationStrategy(npc, target.getBukkitEntity()
|
||||
.getLocation(TARGET_LOCATION), parameters);
|
||||
private PathStrategy strategy;
|
||||
|
||||
public AStarTargeter() {
|
||||
setStrategy();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPath() {
|
||||
strategy = new AStarNavigationStrategy(npc, target.getBukkitEntity().getLocation(TARGET_LOCATION),
|
||||
parameters);
|
||||
setStrategy();
|
||||
strategy.update();
|
||||
CancelReason subReason = strategy.getCancelReason();
|
||||
if (subReason == CancelReason.STUCK) {
|
||||
@ -153,6 +155,12 @@ public class MCTargetStrategy implements PathStrategy, EntityTarget {
|
||||
}
|
||||
}
|
||||
|
||||
private void setStrategy() {
|
||||
Location location = target.getBukkitEntity().getLocation(TARGET_LOCATION);
|
||||
strategy = npc.isFlyable() ? new FlyingAStarNavigationStrategy(npc, location, parameters)
|
||||
: new AStarNavigationStrategy(npc, location, parameters);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stop() {
|
||||
strategy.stop();
|
||||
|
Loading…
Reference in New Issue
Block a user