Skip to content
This repository has been archived by the owner on Jan 21, 2024. It is now read-only.

Commit

Permalink
Citizens navigation fix
Browse files Browse the repository at this point in the history
  • Loading branch information
windcolor-dev committed May 23, 2022
1 parent be6baec commit 6abd51e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 41 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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

Expand All @@ -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);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 6abd51e

Please sign in to comment.