mirror of
https://github.com/CitizensDev/Citizens2.git
synced 2024-11-24 11:38:26 +01:00
Changes to navigator
This commit is contained in:
parent
fae265b22b
commit
f75b33dfce
@ -160,12 +160,13 @@ public class CitizensNavigator implements Navigator {
|
||||
NMS.updatePathfindingRange(npc, localParams.range());
|
||||
}
|
||||
|
||||
int lastX, lastY, lastZ;
|
||||
|
||||
private boolean updateStationaryStatus() {
|
||||
if (localParams.stationaryTicks() < 0)
|
||||
return false;
|
||||
localParams.stationaryTicks(100);// return false;
|
||||
EntityLiving handle = npc.getHandle();
|
||||
if ((int) handle.lastX == (int) handle.locX && (int) handle.lastY == (int) handle.locY
|
||||
&& (int) handle.lastZ == (int) handle.locZ) {
|
||||
if (lastX == (int) handle.locX && lastY == (int) handle.locY && lastZ == (int) handle.locZ) {
|
||||
if (++stationaryTicks >= localParams.stationaryTicks()) {
|
||||
StuckAction action = localParams.stuckAction();
|
||||
if (action != null)
|
||||
@ -176,6 +177,9 @@ public class CitizensNavigator implements Navigator {
|
||||
}
|
||||
} else
|
||||
stationaryTicks = 0;
|
||||
lastX = (int) handle.locX;
|
||||
lastY = (int) handle.locY;
|
||||
lastZ = (int) handle.locZ;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -3,11 +3,10 @@ package net.citizensnpcs.npc.ai;
|
||||
import net.citizensnpcs.api.ai.NavigatorParameters;
|
||||
import net.citizensnpcs.api.ai.TargetType;
|
||||
import net.citizensnpcs.npc.CitizensNPC;
|
||||
import net.minecraft.server.EntityLiving;
|
||||
import net.minecraft.server.EntityPlayer;
|
||||
import net.minecraft.server.Navigation;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class MCNavigationStrategy implements PathStrategy {
|
||||
private final Navigation navigation;
|
||||
@ -15,20 +14,17 @@ public class MCNavigationStrategy implements PathStrategy {
|
||||
private final Location target;
|
||||
|
||||
MCNavigationStrategy(final CitizensNPC npc, Location dest, NavigatorParameters params) {
|
||||
this(npc.getHandle(), dest, params);
|
||||
navigation.a(dest.getX(), dest.getY(), dest.getZ(), parameters.speed());
|
||||
}
|
||||
|
||||
private MCNavigationStrategy(EntityLiving entity, Location target, NavigatorParameters params) {
|
||||
this.target = target;
|
||||
this.target = dest;
|
||||
this.parameters = params;
|
||||
if (entity.getBukkitEntity() instanceof Player) {
|
||||
entity.onGround = true;
|
||||
if (npc.getHandle() instanceof EntityPlayer) {
|
||||
npc.getHandle().onGround = true;
|
||||
// not sure of a better way around this - if onGround is false, then
|
||||
// navigation won't execute, and calling entity.move doesn't
|
||||
// entirely fix the problem.
|
||||
}
|
||||
navigation = entity.getNavigation();
|
||||
navigation = npc.getHandle().getNavigation();
|
||||
navigation.a(parameters.avoidWater());
|
||||
navigation.a(dest.getX(), dest.getY(), dest.getZ(), parameters.speed());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -28,6 +28,7 @@ public class MCTargetStrategy implements PathStrategy, EntityTarget {
|
||||
this.navigation = this.handle.getNavigation();
|
||||
this.aggro = aggro;
|
||||
this.parameters = params;
|
||||
this.navigation.a(parameters.avoidWater());
|
||||
}
|
||||
|
||||
private boolean canAttack() {
|
||||
@ -88,6 +89,7 @@ public class MCTargetStrategy implements PathStrategy, EntityTarget {
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private static final int ATTACK_DELAY_TICKS = 20;
|
||||
|
||||
private static final double ATTACK_DISTANCE = 1.75 * 1.75;
|
||||
|
Loading…
Reference in New Issue
Block a user