mirror of
https://github.com/CitizensDev/Citizens2.git
synced 2025-01-02 22:48:18 +01:00
Make Minecraft navigation canNavigateTo non destructive
This commit is contained in:
parent
b58a7a2040
commit
a96d800c91
@ -41,7 +41,6 @@ import net.citizensnpcs.api.util.DataKey;
|
|||||||
import net.citizensnpcs.api.util.Messaging;
|
import net.citizensnpcs.api.util.Messaging;
|
||||||
import net.citizensnpcs.api.util.SpigotUtil;
|
import net.citizensnpcs.api.util.SpigotUtil;
|
||||||
import net.citizensnpcs.npc.ai.AStarNavigationStrategy.AStarPlanner;
|
import net.citizensnpcs.npc.ai.AStarNavigationStrategy.AStarPlanner;
|
||||||
import net.citizensnpcs.npc.ai.MCNavigationStrategy.MCNavigator;
|
|
||||||
import net.citizensnpcs.trait.RotationTrait;
|
import net.citizensnpcs.trait.RotationTrait;
|
||||||
import net.citizensnpcs.trait.RotationTrait.PacketRotationSession;
|
import net.citizensnpcs.trait.RotationTrait.PacketRotationSession;
|
||||||
import net.citizensnpcs.util.NMS;
|
import net.citizensnpcs.util.NMS;
|
||||||
@ -104,8 +103,7 @@ public class CitizensNavigator implements Navigator, Runnable {
|
|||||||
planner.tick(Setting.MAXIMUM_ASTAR_ITERATIONS.asInt(), Setting.MAXIMUM_ASTAR_ITERATIONS.asInt());
|
planner.tick(Setting.MAXIMUM_ASTAR_ITERATIONS.asInt(), Setting.MAXIMUM_ASTAR_ITERATIONS.asInt());
|
||||||
return planner.plan != null;
|
return planner.plan != null;
|
||||||
} else {
|
} else {
|
||||||
MCNavigator nav = NMS.getTargetNavigator(npc.getEntity(), dest, params);
|
return NMS.canNavigateTo(npc.getEntity(), dest, params);
|
||||||
return nav.getCancelReason() == null;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -154,6 +154,10 @@ public class NMS {
|
|||||||
BRIDGE.cancelMoveDestination(entity);
|
BRIDGE.cancelMoveDestination(entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean canNavigateTo(Entity entity, Location dest, NavigatorParameters params) {
|
||||||
|
return BRIDGE.canNavigateTo(entity, dest, params);
|
||||||
|
}
|
||||||
|
|
||||||
public static void clearCustomNBT(ItemMeta meta) {
|
public static void clearCustomNBT(ItemMeta meta) {
|
||||||
if (CUSTOM_NBT_TAG_MISSING)
|
if (CUSTOM_NBT_TAG_MISSING)
|
||||||
return;
|
return;
|
||||||
|
@ -63,6 +63,8 @@ public interface NMSBridge {
|
|||||||
|
|
||||||
public void cancelMoveDestination(Entity entity);
|
public void cancelMoveDestination(Entity entity);
|
||||||
|
|
||||||
|
public boolean canNavigateTo(Entity entity, Location dest, NavigatorParameters params);
|
||||||
|
|
||||||
public default Iterable<Object> createBundlePacket(List<Object> packets) {
|
public default Iterable<Object> createBundlePacket(List<Object> packets) {
|
||||||
return packets;
|
return packets;
|
||||||
}
|
}
|
||||||
@ -95,12 +97,12 @@ public interface NMSBridge {
|
|||||||
|
|
||||||
public Location getDestination(Entity entity);
|
public Location getDestination(Entity entity);
|
||||||
|
|
||||||
|
public float getForwardBackwardMovement(Entity entity);
|
||||||
|
|
||||||
public GameProfileRepository getGameProfileRepository();
|
public GameProfileRepository getGameProfileRepository();
|
||||||
|
|
||||||
public float getHeadYaw(Entity entity);
|
public float getHeadYaw(Entity entity);
|
||||||
|
|
||||||
public float getForwardBackwardMovement(Entity entity);
|
|
||||||
|
|
||||||
public EntityPacketTracker getPacketTracker(Entity entity);
|
public EntityPacketTracker getPacketTracker(Entity entity);
|
||||||
|
|
||||||
public List<Entity> getPassengers(Entity entity);
|
public List<Entity> getPassengers(Entity entity);
|
||||||
@ -129,14 +131,14 @@ public interface NMSBridge {
|
|||||||
|
|
||||||
public Entity getVehicle(Entity entity);
|
public Entity getVehicle(Entity entity);
|
||||||
|
|
||||||
public float getXZMovement(Entity entity);
|
|
||||||
|
|
||||||
public default Collection<Player> getViewingPlayers(Entity entity) {
|
public default Collection<Player> getViewingPlayers(Entity entity) {
|
||||||
return entity.getTrackedBy();
|
return entity.getTrackedBy();
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getWidth(Entity entity);
|
public double getWidth(Entity entity);
|
||||||
|
|
||||||
|
public float getXZMovement(Entity entity);
|
||||||
|
|
||||||
public float getYaw(Entity entity);
|
public float getYaw(Entity entity);
|
||||||
|
|
||||||
public boolean isOnGround(Entity entity);
|
public boolean isOnGround(Entity entity);
|
||||||
|
@ -320,6 +320,13 @@ public class NMSImpl implements NMSBridge {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canNavigateTo(final org.bukkit.entity.Entity entity, final Location dest,
|
||||||
|
final NavigatorParameters params) {
|
||||||
|
final NavigationAbstract navigation = getNavigation(entity);
|
||||||
|
return navigation.a(dest.getX(), dest.getY(), dest.getZ()) != null;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public EntityPacketTracker createPacketTracker(org.bukkit.entity.Entity entity, PacketAggregator agg) {
|
public EntityPacketTracker createPacketTracker(org.bukkit.entity.Entity entity, PacketAggregator agg) {
|
||||||
Entity handle = getHandle(entity);
|
Entity handle = getHandle(entity);
|
||||||
|
@ -341,6 +341,13 @@ public class NMSImpl implements NMSBridge {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canNavigateTo(final org.bukkit.entity.Entity entity, final Location dest,
|
||||||
|
final NavigatorParameters params) {
|
||||||
|
final NavigationAbstract navigation = getNavigation(entity);
|
||||||
|
return navigation.a(dest.getX(), dest.getY(), dest.getZ()) != null;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public EntityPacketTracker createPacketTracker(org.bukkit.entity.Entity entity, PacketAggregator agg) {
|
public EntityPacketTracker createPacketTracker(org.bukkit.entity.Entity entity, PacketAggregator agg) {
|
||||||
Entity handle = getHandle(entity);
|
Entity handle = getHandle(entity);
|
||||||
|
@ -347,6 +347,13 @@ public class NMSImpl implements NMSBridge {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canNavigateTo(final org.bukkit.entity.Entity entity, final Location dest,
|
||||||
|
final NavigatorParameters params) {
|
||||||
|
final NavigationAbstract navigation = getNavigation(entity);
|
||||||
|
return navigation.a(dest.getX(), dest.getY(), dest.getZ()) != null;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public EntityPacketTracker createPacketTracker(org.bukkit.entity.Entity entity, PacketAggregator agg) {
|
public EntityPacketTracker createPacketTracker(org.bukkit.entity.Entity entity, PacketAggregator agg) {
|
||||||
Entity handle = getHandle(entity);
|
Entity handle = getHandle(entity);
|
||||||
|
@ -366,6 +366,13 @@ public class NMSImpl implements NMSBridge {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canNavigateTo(final org.bukkit.entity.Entity entity, final Location dest,
|
||||||
|
final NavigatorParameters params) {
|
||||||
|
final NavigationAbstract navigation = getNavigation(entity);
|
||||||
|
return navigation.a(dest.getX(), dest.getY(), dest.getZ()) != null;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public EntityPacketTracker createPacketTracker(org.bukkit.entity.Entity entity, PacketAggregator agg) {
|
public EntityPacketTracker createPacketTracker(org.bukkit.entity.Entity entity, PacketAggregator agg) {
|
||||||
Entity handle = getHandle(entity);
|
Entity handle = getHandle(entity);
|
||||||
|
@ -411,6 +411,13 @@ public class NMSImpl implements NMSBridge {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canNavigateTo(final org.bukkit.entity.Entity entity, final Location dest,
|
||||||
|
final NavigatorParameters params) {
|
||||||
|
final NavigationAbstract navigation = getNavigation(entity);
|
||||||
|
return navigation.a(dest.getX(), dest.getY(), dest.getZ(), 1) != null;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public EntityPacketTracker createPacketTracker(org.bukkit.entity.Entity entity, PacketAggregator agg) {
|
public EntityPacketTracker createPacketTracker(org.bukkit.entity.Entity entity, PacketAggregator agg) {
|
||||||
Entity handle = getHandle(entity);
|
Entity handle = getHandle(entity);
|
||||||
|
@ -426,6 +426,13 @@ public class NMSImpl implements NMSBridge {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canNavigateTo(final org.bukkit.entity.Entity entity, final Location dest,
|
||||||
|
final NavigatorParameters params) {
|
||||||
|
final NavigationAbstract navigation = getNavigation(entity);
|
||||||
|
return navigation.a(dest.getX(), dest.getY(), dest.getZ(), 1) != null;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public EntityPacketTracker createPacketTracker(org.bukkit.entity.Entity entity, PacketAggregator agg) {
|
public EntityPacketTracker createPacketTracker(org.bukkit.entity.Entity entity, PacketAggregator agg) {
|
||||||
Entity handle = getHandle(entity);
|
Entity handle = getHandle(entity);
|
||||||
|
@ -439,6 +439,13 @@ public class NMSImpl implements NMSBridge {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canNavigateTo(final org.bukkit.entity.Entity entity, final Location dest,
|
||||||
|
final NavigatorParameters params) {
|
||||||
|
final NavigationAbstract navigation = getNavigation(entity);
|
||||||
|
return navigation.a(dest.getX(), dest.getY(), dest.getZ(), 1) != null;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public EntityPacketTracker createPacketTracker(org.bukkit.entity.Entity entity, PacketAggregator agg) {
|
public EntityPacketTracker createPacketTracker(org.bukkit.entity.Entity entity, PacketAggregator agg) {
|
||||||
Entity handle = getHandle(entity);
|
Entity handle = getHandle(entity);
|
||||||
|
@ -452,6 +452,13 @@ public class NMSImpl implements NMSBridge {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canNavigateTo(final org.bukkit.entity.Entity entity, final Location dest,
|
||||||
|
final NavigatorParameters params) {
|
||||||
|
final PathNavigation navigation = getNavigation(entity);
|
||||||
|
return navigation.createPath(new BlockPos(dest.getX(), dest.getY(), dest.getZ()), 1) != null;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public EntityPacketTracker createPacketTracker(org.bukkit.entity.Entity entity, PacketAggregator agg) {
|
public EntityPacketTracker createPacketTracker(org.bukkit.entity.Entity entity, PacketAggregator agg) {
|
||||||
Entity handle = getHandle(entity);
|
Entity handle = getHandle(entity);
|
||||||
|
@ -458,6 +458,13 @@ public class NMSImpl implements NMSBridge {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canNavigateTo(final org.bukkit.entity.Entity entity, final Location dest,
|
||||||
|
final NavigatorParameters params) {
|
||||||
|
final PathNavigation navigation = getNavigation(entity);
|
||||||
|
return navigation.createPath(new BlockPos(dest.getX(), dest.getY(), dest.getZ()), 1) != null;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public EntityPacketTracker createPacketTracker(org.bukkit.entity.Entity entity, PacketAggregator agg) {
|
public EntityPacketTracker createPacketTracker(org.bukkit.entity.Entity entity, PacketAggregator agg) {
|
||||||
Entity handle = getHandle(entity);
|
Entity handle = getHandle(entity);
|
||||||
|
@ -496,6 +496,13 @@ public class NMSImpl implements NMSBridge {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canNavigateTo(final org.bukkit.entity.Entity entity, final Location dest,
|
||||||
|
final NavigatorParameters params) {
|
||||||
|
final PathNavigation navigation = getNavigation(entity);
|
||||||
|
return navigation.createPath(BlockPos.containing(dest.getX(), dest.getY(), dest.getZ()), 1) != null;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@SuppressWarnings("rawtypes")
|
@SuppressWarnings("rawtypes")
|
||||||
public Iterable<Object> createBundlePacket(List source) {
|
public Iterable<Object> createBundlePacket(List source) {
|
||||||
|
@ -507,6 +507,13 @@ public class NMSImpl implements NMSBridge {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canNavigateTo(final org.bukkit.entity.Entity entity, final Location dest,
|
||||||
|
final NavigatorParameters params) {
|
||||||
|
final PathNavigation navigation = getNavigation(entity);
|
||||||
|
return navigation.createPath(BlockPos.containing(dest.getX(), dest.getY(), dest.getZ()), 1) != null;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@SuppressWarnings("rawtypes")
|
@SuppressWarnings("rawtypes")
|
||||||
public Iterable<Object> createBundlePacket(List source) {
|
public Iterable<Object> createBundlePacket(List source) {
|
||||||
|
@ -494,6 +494,13 @@ public class NMSImpl implements NMSBridge {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canNavigateTo(final org.bukkit.entity.Entity entity, final Location dest,
|
||||||
|
final NavigatorParameters params) {
|
||||||
|
final PathNavigation navigation = getNavigation(entity);
|
||||||
|
return navigation.createPath(BlockPos.containing(dest.getX(), dest.getY(), dest.getZ()), 1) != null;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@SuppressWarnings("rawtypes")
|
@SuppressWarnings("rawtypes")
|
||||||
public Iterable<Object> createBundlePacket(List source) {
|
public Iterable<Object> createBundlePacket(List source) {
|
||||||
|
@ -301,6 +301,13 @@ public class NMSImpl implements NMSBridge {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canNavigateTo(final org.bukkit.entity.Entity entity, final Location dest,
|
||||||
|
final NavigatorParameters params) {
|
||||||
|
final NavigationAbstract navigation = getNavigation(entity);
|
||||||
|
return navigation.a(dest.getX(), dest.getY(), dest.getZ()) != null;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public EntityPacketTracker createPacketTracker(org.bukkit.entity.Entity entity, PacketAggregator agg) {
|
public EntityPacketTracker createPacketTracker(org.bukkit.entity.Entity entity, PacketAggregator agg) {
|
||||||
Entity handle = getHandle(entity);
|
Entity handle = getHandle(entity);
|
||||||
|
Loading…
Reference in New Issue
Block a user