NPCs no longer constantly pathfind when set to return to their home, and already there.

Flying NPCs:
-Pathfinding has a cooldown to decrease the amount of times they create a new path.
-Fly height limit implemented using getTopSolidOrLiquidBlock instead of iterating through blocks below the NPC.
This commit is contained in:
Luis C.M committed 2022-11-04 23:56:09 -05:00
1 parent 7dc0c25330
commit 4bad48352c
3 files changed
+23 -12

No files matched your search

@@ -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;