Use foot location instead of eye location for initial pathfinding position

This commit is contained in:
fullwall 2016-06-05 19:27:24 +08:00
parent 0b8f754197
commit 0f38dca862
2 changed files with 3 additions and 6 deletions

View File

@ -2,7 +2,6 @@ package net.citizensnpcs.npc.ai;
import org.bukkit.Effect;
import org.bukkit.Location;
import org.bukkit.entity.LivingEntity;
import org.bukkit.util.Vector;
import net.citizensnpcs.Settings.Setting;
@ -16,7 +15,6 @@ import net.citizensnpcs.api.astar.pathfinder.VectorGoal;
import net.citizensnpcs.api.astar.pathfinder.VectorNode;
import net.citizensnpcs.api.npc.NPC;
import net.citizensnpcs.util.NMS;
import net.citizensnpcs.util.Util;
public class AStarNavigationStrategy extends AbstractPathStrategy {
private final Location destination;
@ -30,7 +28,7 @@ public class AStarNavigationStrategy extends AbstractPathStrategy {
this.params = params;
this.destination = dest;
this.npc = npc;
Location location = Util.getEyeLocation(npc.getEntity());
Location location = npc.getEntity().getLocation();
VectorGoal goal = new VectorGoal(dest, (float) params.pathDistanceMargin());
plan = ASTAR.runFully(goal,
new VectorNode(goal, location, new ChunkBlockSource(location, params.range()), params.examiners()),
@ -80,7 +78,7 @@ public class AStarNavigationStrategy extends AbstractPathStrategy {
npc.getEntity().getWorld().playEffect(vector.toLocation(npc.getEntity().getWorld()), Effect.ENDER_SIGNAL,
0);
}
if (distance > 0 && dY > NMS.getStepHeight((LivingEntity) npc.getEntity()) && xzDistance <= 2.75) {
if (distance > 0 && dY > NMS.getStepHeight(npc.getEntity()) && xzDistance <= 2.75) {
NMS.setShouldJump(npc.getEntity());
}
double destX = vector.getX() + 0.5, destZ = vector.getZ() + 0.5;

View File

@ -17,7 +17,6 @@ import net.citizensnpcs.api.astar.pathfinder.VectorGoal;
import net.citizensnpcs.api.astar.pathfinder.VectorNode;
import net.citizensnpcs.api.npc.NPC;
import net.citizensnpcs.util.NMS;
import net.citizensnpcs.util.Util;
import net.minecraft.server.v1_9_R2.MathHelper;
public class FlyingAStarNavigationStrategy extends AbstractPathStrategy {
@ -32,7 +31,7 @@ public class FlyingAStarNavigationStrategy extends AbstractPathStrategy {
this.target = dest;
this.parameters = params;
this.npc = npc;
Location location = Util.getEyeLocation(npc.getEntity());
Location location = npc.getEntity().getLocation();
VectorGoal goal = new VectorGoal(dest, (float) params.pathDistanceMargin());
boolean found = false;
for (BlockExaminer examiner : params.examiners()) {