diff --git a/src/main/java/noppes/npcs/ai/EntityAIReturn.java b/src/main/java/noppes/npcs/ai/EntityAIReturn.java index 771f42797..94014013d 100644 --- a/src/main/java/noppes/npcs/ai/EntityAIReturn.java +++ b/src/main/java/noppes/npcs/ai/EntityAIReturn.java @@ -145,8 +145,11 @@ public class EntityAIReturn extends EntityAIBase } } } - npc.getNavigator().clearPathEntity(); - npc.getNavigator().tryMoveToXYZ(posX, posY, posZ, 1); + + if (range > 1f) { + npc.getNavigator().clearPathEntity(); + npc.getNavigator().tryMoveToXYZ(posX, posY, posZ, 1); + } } public void resetTask(){ diff --git a/src/main/java/noppes/npcs/ai/pathfinder/PathNavigateFlying.java b/src/main/java/noppes/npcs/ai/pathfinder/PathNavigateFlying.java index 944d87d55..fc52af434 100644 --- a/src/main/java/noppes/npcs/ai/pathfinder/PathNavigateFlying.java +++ b/src/main/java/noppes/npcs/ai/pathfinder/PathNavigateFlying.java @@ -46,6 +46,9 @@ public class PathNavigateFlying extends PathNavigate { private boolean canSwim; private static final String __OBFID = "CL_00001627"; + private int pathCooldown = 0; + private int maxCooldown = 2; + public PathNavigateFlying(EntityLiving p_i45873_1_, World worldIn) { super(p_i45873_1_, worldIn); this.theEntity = (EntityNPCInterface)p_i45873_1_; @@ -129,6 +132,13 @@ public class PathNavigateFlying extends PathNavigate { */ public boolean tryMoveToXYZ(double p_75492_1_, double p_75492_3_, double p_75492_5_, double p_75492_7_) { + if (this.pathCooldown == 0) { + this.pathCooldown = this.maxCooldown; + } else { + this.pathCooldown--; + return false; + } + FlyPathEntity pathentity = this.getPathToXYZ((double)MathHelper.floor_double(p_75492_1_), (double)((int)p_75492_3_), (double)MathHelper.floor_double(p_75492_5_)); return this.setPath(pathentity, p_75492_7_); } @@ -146,6 +156,13 @@ public class PathNavigateFlying extends PathNavigate { */ public boolean tryMoveToEntityLiving(Entity p_75497_1_, double p_75497_2_) { + if (this.pathCooldown == 0) { + this.pathCooldown = this.maxCooldown; + } else { + this.pathCooldown--; + return false; + } + FlyPathEntity pathentity = this.getPathToEntityLiving(p_75497_1_); return pathentity != null && this.setPath(pathentity, p_75497_2_); } diff --git a/src/main/java/noppes/npcs/entity/EntityNPCFlying.java b/src/main/java/noppes/npcs/entity/EntityNPCFlying.java index de8b8d1f9..f391cb855 100644 --- a/src/main/java/noppes/npcs/entity/EntityNPCFlying.java +++ b/src/main/java/noppes/npcs/entity/EntityNPCFlying.java @@ -38,16 +38,7 @@ public abstract class EntityNPCFlying extends EntityNPCInterface { return; } - double heightOffGround = 0; - if(this.ai.hasFlyLimit) { - for (int blockY = (int) this.posY; blockY > 0; blockY--) { - heightOffGround = this.posY - blockY; - if (this.worldObj.getBlock((int) this.posX, blockY, (int) this.posZ) != Blocks.air || heightOffGround > this.ai.flyHeightLimit){ - break; - } - } - } - + double heightOffGround = this.posY - this.worldObj.getTopSolidOrLiquidBlock((int) this.posX, (int) this.posZ); if (heightOffGround > this.ai.flyHeightLimit && this.ai.hasFlyLimit) { super.moveEntityWithHeading(p_70612_1_,p_70612_2_); return;