mirror of
https://github.com/CitizensDev/Citizens2.git
synced 2025-02-22 23:31:31 +01:00
Fix player ticking
This commit is contained in:
parent
98c5c48c23
commit
ffac34f734
@ -80,7 +80,7 @@ public class AStarNavigationStrategy extends AbstractPathStrategy {
|
||||
public boolean update() {
|
||||
if (plan == null) {
|
||||
if (planner == null) {
|
||||
planner = new AStarPlanner(params, npc.getStoredLocation(), destination);
|
||||
planner = new AStarPlanner(params, npc.getEntity().getLocation(NPC_LOCATION), destination);
|
||||
}
|
||||
CancelReason reason = planner.tick(Setting.ASTAR_ITERATIONS_PER_TICK.asInt(),
|
||||
Setting.MAXIMUM_ASTAR_ITERATIONS.asInt());
|
||||
@ -98,7 +98,7 @@ public class AStarNavigationStrategy extends AbstractPathStrategy {
|
||||
}
|
||||
Location loc = npc.getEntity().getLocation(NPC_LOCATION);
|
||||
/* Proper door movement - gets stuck on corners at times
|
||||
|
||||
|
||||
Block block = currLoc.getWorld().getBlockAt(vector.getBlockX(), vector.getBlockY(), vector.getBlockZ());
|
||||
if (MinecraftBlockExaminer.isDoor(block.getType())) {
|
||||
Door door = (Door) block.getState().getData();
|
||||
@ -169,16 +169,14 @@ public class AStarNavigationStrategy extends AbstractPathStrategy {
|
||||
return PassableState.IGNORE;
|
||||
}
|
||||
});
|
||||
VectorGoal goal = new VectorGoal(to, (float) params.pathDistanceMargin());
|
||||
state = ASTAR.getStateFor(goal,
|
||||
new VectorNode(goal, from, new NMSChunkBlockSource(from, params.range()), params.examiners()));
|
||||
}
|
||||
|
||||
public CancelReason tick(int iterationsPerTick, int maxIterations) {
|
||||
if (plan != null)
|
||||
if (this.plan != null)
|
||||
return null;
|
||||
if (state == null) {
|
||||
VectorGoal goal = new VectorGoal(to, (float) params.pathDistanceMargin());
|
||||
state = ASTAR.getStateFor(goal,
|
||||
new VectorNode(goal, from, new NMSChunkBlockSource(from, params.range()), params.examiners()));
|
||||
}
|
||||
Path plan = ASTAR.run(state, iterationsPerTick);
|
||||
if (plan == null) {
|
||||
if (state.isEmpty()) {
|
||||
|
@ -498,7 +498,12 @@ public class NMS {
|
||||
}
|
||||
|
||||
public static Runnable playerTicker(Player entity) {
|
||||
return BRIDGE.playerTicker(entity);
|
||||
Runnable tick = BRIDGE.playerTicker(entity);
|
||||
return () -> {
|
||||
if (entity.isValid()) {
|
||||
tick.run();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public static void registerEntityClass(Class<?> clazz) {
|
||||
|
@ -59,11 +59,7 @@ public class PlayerUpdateTask extends BukkitRunnable {
|
||||
}
|
||||
|
||||
public PlayerTick(Player player) {
|
||||
this(player, () -> {
|
||||
if (player.isValid()) {
|
||||
NMS.playerTicker(player);
|
||||
}
|
||||
});
|
||||
this(player, NMS.playerTicker(player));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -376,7 +376,7 @@ citizens.editors.waypoints.guided.added-guide=Added a [[guide]] waypoint which t
|
||||
citizens.editors.waypoints.guided.added-available=Added a [[destination]] waypoint which the NPC will randomly pathfind between.
|
||||
citizens.editors.waypoints.guided.already-taken=There is already a waypoint here.
|
||||
citizens.editors.waypoints.linear.added-waypoint=[[Added]] a waypoint at ({0}) ([[{1}]] total).
|
||||
citizens.editors.waypoints.linear.begin=<green>=== [[Linear Waypoint Editor]] ===<br> [[Left click]] to add a waypoint, [[right click]] to remove it.<br> You can right click while sneaking to select and remove specific points.<br> Type [[markers]] to hide waypoints,<br> [[triggers]] to enter the trigger editor,<br> [[clear]] to clear all waypoints,<br> [[cycle]] to make NPCs cycle through waypoints instead of looping.
|
||||
citizens.editors.waypoints.linear.begin=<green>=== [[Linear Waypoint Editor]] ===<br> [[Left click]] to add a waypoint, [[right click]] to remove it.<br> Right click while sneaking to select and remove points.<br> Type [[markers]] to hide waypoints,<br> [[triggers]] to enter the trigger editor,<br> [[clear]] to clear all waypoints,<br> [[cycle]] to make NPCs cycle through waypoints instead of looping.
|
||||
citizens.editors.waypoints.linear.selected-waypoint=Selected waypoint at {0}. Sneak + right click again to remove this waypoint.
|
||||
citizens.editors.waypoints.linear.end=Exited the linear waypoint editor.
|
||||
citizens.editors.waypoints.linear.not-showing-markers=[[Stopped]] showing waypoint markers.
|
||||
|
@ -309,7 +309,8 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable
|
||||
}
|
||||
moveOnCurrentHeading();
|
||||
}
|
||||
NMSImpl.updateAI(this);
|
||||
|
||||
updateAI();
|
||||
|
||||
if (npc.data().get(NPC.Metadata.COLLIDABLE, !npc.isProtected())) {
|
||||
cs();
|
||||
|
@ -370,7 +370,8 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable
|
||||
}
|
||||
moveOnCurrentHeading();
|
||||
}
|
||||
NMSImpl.updateAI(this);
|
||||
|
||||
updateAI();
|
||||
|
||||
if (npc.data().get(NPC.Metadata.COLLIDABLE, !npc.isProtected())) {
|
||||
ct();
|
||||
|
@ -396,7 +396,7 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable
|
||||
}
|
||||
moveOnCurrentHeading();
|
||||
}
|
||||
NMSImpl.updateAI(this);
|
||||
updateAI();
|
||||
|
||||
if (npc.data().get(NPC.Metadata.COLLIDABLE, !npc.isProtected())) {
|
||||
cB();
|
||||
|
@ -374,7 +374,7 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable
|
||||
}
|
||||
moveOnCurrentHeading();
|
||||
}
|
||||
NMSImpl.updateAI(this);
|
||||
updateAI();
|
||||
|
||||
if (npc.data().get(NPC.Metadata.COLLIDABLE, !npc.isProtected())) {
|
||||
cN();
|
||||
|
@ -379,7 +379,7 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable
|
||||
}
|
||||
moveOnCurrentHeading();
|
||||
}
|
||||
NMSImpl.updateAI(this);
|
||||
updateAI();
|
||||
|
||||
if (npc.data().get(NPC.Metadata.COLLIDABLE, !npc.isProtected())) {
|
||||
collideNearby();
|
||||
|
@ -378,7 +378,7 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable
|
||||
}
|
||||
moveOnCurrentHeading();
|
||||
}
|
||||
NMSImpl.updateAI(this);
|
||||
updateAI();
|
||||
|
||||
if (npc.data().get(NPC.Metadata.COLLIDABLE, !npc.isProtected())) {
|
||||
collideNearby();
|
||||
|
@ -408,7 +408,7 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable
|
||||
}
|
||||
moveOnCurrentHeading();
|
||||
}
|
||||
NMSImpl.updateAI(this);
|
||||
updateAI();
|
||||
|
||||
if (npc.data().get(NPC.Metadata.COLLIDABLE, !npc.isProtected())) {
|
||||
collideNearby();
|
||||
|
@ -189,7 +189,7 @@ public class EntityHumanNPC extends ServerPlayer implements NPCHolder, Skinnable
|
||||
}
|
||||
moveOnCurrentHeading();
|
||||
}
|
||||
NMSImpl.updateAI(this);
|
||||
updateAI();
|
||||
|
||||
if (isSpectator()) {
|
||||
this.noPhysics = true;
|
||||
|
@ -190,7 +190,7 @@ public class EntityHumanNPC extends ServerPlayer implements NPCHolder, Skinnable
|
||||
}
|
||||
moveOnCurrentHeading();
|
||||
}
|
||||
NMSImpl.updateAI(this);
|
||||
updateAI();
|
||||
|
||||
if (isSpectator()) {
|
||||
this.noPhysics = true;
|
||||
|
@ -196,7 +196,7 @@ public class EntityHumanNPC extends ServerPlayer implements NPCHolder, Skinnable
|
||||
moveOnCurrentHeading();
|
||||
}
|
||||
|
||||
NMSImpl.updateAI(this);
|
||||
updateAI();
|
||||
|
||||
if (isSpectator()) {
|
||||
this.noPhysics = true;
|
||||
|
@ -103,7 +103,6 @@ public class PlayerMoveControl extends MoveControl {
|
||||
|
||||
@Override
|
||||
public void tick() {
|
||||
|
||||
this.entity.zza = 0;
|
||||
if (this.moving) {
|
||||
this.moving = false;
|
||||
|
@ -312,7 +312,8 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable
|
||||
}
|
||||
moveOnCurrentHeading();
|
||||
}
|
||||
NMSImpl.updateAI(this);
|
||||
|
||||
updateAI();
|
||||
|
||||
if (npc.data().get(NPC.Metadata.COLLIDABLE, !npc.isProtected())) {
|
||||
bL();
|
||||
|
Loading…
Reference in New Issue
Block a user