From 6abd51e91bf99da23f3defad0a47fdba7cf3a30f Mon Sep 17 00:00:00 2001 From: windcolor-dev Date: Mon, 23 May 2022 16:36:58 -0700 Subject: [PATCH] Citizens navigation fix --- .../minecraft/server/NavigationAbstract.java | 40 ++++--------------- .../java/net/minecraft/server/Pathfinder.java | 10 +---- 2 files changed, 9 insertions(+), 41 deletions(-) diff --git a/WindSpigot-Server/src/main/java/net/minecraft/server/NavigationAbstract.java b/WindSpigot-Server/src/main/java/net/minecraft/server/NavigationAbstract.java index e842200d..f1413679 100644 --- a/WindSpigot-Server/src/main/java/net/minecraft/server/NavigationAbstract.java +++ b/WindSpigot-Server/src/main/java/net/minecraft/server/NavigationAbstract.java @@ -58,15 +58,14 @@ public PathEntity doPathSearch(ChunkCache chunkcache, BlockPosition blockpositio public PathEntity doPathSearch(ChunkCache chunkcache, int x, int y, int z) { if (this.b()) { float f = this.i(); - return this.j.a((IBlockAccess) chunkcache, (Entity) this.b, x, y, z, f); + return this.j.a((IBlockAccess) chunkcache, (Entity) this.b, new BlockPosition(x, y, z), f); } return null; } public PathEntity doPathSearch(ChunkCache chunkcache, Entity entity) { - //return this.doPathSearch(chunkcache, (new BlockPosition(entity)).up()); - return this.doPathSearch(chunkcache, MathHelper.floor(entity.locX), MathHelper.floor(entity.locY) + 1, - MathHelper.floor(entity.locZ)); + return this.doPathSearch(chunkcache, (new BlockPosition(entity)).up()); + } // WindSpigot end @@ -88,27 +87,7 @@ public PathEntity a(double d0, double d1, double d2) { } public PathEntity a(int d0, int d1, int d2) { // remove final modifier - //return this.a(new BlockPosition(MathHelper.floor(d0), (int) d1, MathHelper.floor(d2))); - // debug msgs - WindSpigot.debug("Executing sync path search..."); - if (!this.b()) { - return null; - } else { - float f = this.i(); - - this.c.methodProfiler.a("pathfind"); - - int i = (int) (f + 8.0F); - - ChunkCache chunkcache = new ChunkCache(this.c, MathHelper.floor(b.locX) - i, MathHelper.floor(b.locY) - i, - MathHelper.floor(b.locZ) - i, MathHelper.floor(b.locX) + i, MathHelper.floor(b.locY) + i, - MathHelper.floor(b.locZ) + i, 0); - - PathEntity pathentity = this.j.a(chunkcache, this.b, d0, d1, d2, f); - - this.c.methodProfiler.b(); - return pathentity; - } + return this.a(new BlockPosition(MathHelper.floor(d0), (int) d1, MathHelper.floor(d2))); } // WindSpigot end @@ -119,15 +98,10 @@ public PathEntity a(BlockPosition blockposition) { float f = this.i(); this.c.methodProfiler.a("pathfind"); - // WindSpigot start - reduce usage of blockposition - //BlockPosition blockposition1 = new BlockPosition(this.b); + BlockPosition blockposition1 = new BlockPosition(this.b); int i = (int) (f + 8.0F); - //ChunkCache chunkcache = new ChunkCache(this.c, blockposition1.a(-i, -i, -i), blockposition1.a(i, i, i), 0); - - ChunkCache chunkcache = new ChunkCache(this.c, MathHelper.floor(b.locX - i), MathHelper.floor(b.locY - i), - MathHelper.floor(b.locZ - i), MathHelper.floor(b.locX + i), MathHelper.floor(b.locY + i), - MathHelper.floor(b.locZ + i), 0); - // WindSpigot end + ChunkCache chunkcache = new ChunkCache(this.c, blockposition1.a(-i, -i, -i), blockposition1.a(i, i, i), 0); + PathEntity pathentity = this.j.a(chunkcache, this.b, blockposition, f); diff --git a/WindSpigot-Server/src/main/java/net/minecraft/server/Pathfinder.java b/WindSpigot-Server/src/main/java/net/minecraft/server/Pathfinder.java index a3534206..7ed3447d 100644 --- a/WindSpigot-Server/src/main/java/net/minecraft/server/Pathfinder.java +++ b/WindSpigot-Server/src/main/java/net/minecraft/server/Pathfinder.java @@ -13,17 +13,11 @@ public PathEntity a(IBlockAccess var1, Entity var2, Entity var3, float var4) { return this.a(var1, var2, var3.locX, var3.getBoundingBox().b, var3.locZ, var4); } - // WindSpigot start - reduce blockposition usage public PathEntity a(IBlockAccess var1, Entity var2, BlockPosition var3, float var4) { - return this.a(var1, var2, var3.getX(), var3.getY(), var3.getZ(), var4); + return this.a(var1, var2, (double) ((float) var3.getX() + 0.5F), (double) ((float) var3.getY() + 0.5F), + (double) ((float) var3.getZ() + 0.5F), var4); } - public PathEntity a(IBlockAccess var1, Entity var2, int x, int y, int z, float var4) { - return this.a(var1, var2, (double) ((float) x + 0.5F), (double) ((float) y + 0.5F), - (double) ((float) z + 0.5F), var4); - } - // WindSpigot end - private PathEntity a(IBlockAccess var1, Entity var2, double var3, double var5, double var7, float var9) { // WindSpigot - synchronize