mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-26 12:36:07 +01:00
Fix ChunkCache .getXIfLoaded to use the local chunks in the cache
It was calling back out to world for it, we already have them. Also use the nocache method for building the chunk cache too.
This commit is contained in:
parent
f6f9157bd4
commit
ceb824dbde
@ -2670,7 +2670,7 @@ index 55373cae078ddaf6c7c974abf59183698f669c24..b39ce329aa0b2e8da679a7b658f707f1
|
||||
// CraftBukkit end
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/ChunkCache.java b/src/main/java/net/minecraft/server/ChunkCache.java
|
||||
index 11c4d23ba988dac5f3fd85142083c77fb603e673..53c15c1c0bf2d902e6b0325e0964f88f6d5fd6a5 100644
|
||||
index 11c4d23ba988dac5f3fd85142083c77fb603e673..a03e4c5b8693395f4a145ca565b074d6aed1913f 100644
|
||||
--- a/src/main/java/net/minecraft/server/ChunkCache.java
|
||||
+++ b/src/main/java/net/minecraft/server/ChunkCache.java
|
||||
@@ -8,7 +8,7 @@ public class ChunkCache implements IBlockAccess, ICollisionAccess {
|
||||
@ -2682,20 +2682,47 @@ index 11c4d23ba988dac5f3fd85142083c77fb603e673..53c15c1c0bf2d902e6b0325e0964f88f
|
||||
|
||||
public ChunkCache(World world, BlockPosition blockposition, BlockPosition blockposition1) {
|
||||
this.e = world;
|
||||
@@ -71,6 +71,20 @@ public class ChunkCache implements IBlockAccess, ICollisionAccess {
|
||||
@@ -27,7 +27,7 @@ public class ChunkCache implements IBlockAccess, ICollisionAccess {
|
||||
|
||||
for (k = this.a; k <= i; ++k) {
|
||||
for (l = this.b; l <= j; ++l) {
|
||||
- this.c[k - this.a][l - this.b] = ichunkprovider.a(k, l);
|
||||
+ this.c[k - this.a][l - this.b] = ((WorldServer)world).getChunkProvider().getChunkAtIfLoadedMainThreadNoCache(k, l); // Paper
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,7 +52,7 @@ public class ChunkCache implements IBlockAccess, ICollisionAccess {
|
||||
int k = i - this.a;
|
||||
int l = j - this.b;
|
||||
|
||||
- if (k >= 0 && k < this.c.length && l >= 0 && l < this.c[k].length) {
|
||||
+ if (k >= 0 && k < this.c.length && l >= 0 && l < this.c[k].length) { // Paper - if this changes, update getChunkIfLoaded below
|
||||
IChunkAccess ichunkaccess = this.c[k][l];
|
||||
|
||||
return (IChunkAccess) (ichunkaccess != null ? ichunkaccess : new ChunkEmpty(this.e, new ChunkCoordIntPair(i, j)));
|
||||
@@ -71,6 +71,29 @@ public class ChunkCache implements IBlockAccess, ICollisionAccess {
|
||||
return this.a(i, j);
|
||||
}
|
||||
|
||||
+ // Paper start - if loaded util
|
||||
+ private IChunkAccess getChunkIfLoaded(int x, int z) {
|
||||
+ int k = x - this.a;
|
||||
+ int l = z - this.b;
|
||||
+
|
||||
+ if (k >= 0 && k < this.c.length && l >= 0 && l < this.c[k].length) {
|
||||
+ return this.c[k][l];
|
||||
+ }
|
||||
+ return null;
|
||||
+ }
|
||||
+ @Override
|
||||
+ public Fluid getFluidIfLoaded(BlockPosition blockposition) {
|
||||
+ IChunkAccess chunk = getWorld().getChunkIfLoadedImmediately(blockposition.getX() >> 4, blockposition.getZ() >> 4);
|
||||
+ IChunkAccess chunk = getChunkIfLoaded(blockposition.getX() >> 4, blockposition.getZ() >> 4);
|
||||
+ return chunk == null ? null : chunk.getFluid(blockposition);
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public IBlockData getTypeIfLoaded(BlockPosition blockposition) {
|
||||
+ IChunkAccess chunk = getWorld().getChunkIfLoadedImmediately(blockposition.getX() >> 4, blockposition.getZ() >> 4);
|
||||
+ IChunkAccess chunk = getChunkIfLoaded(blockposition.getX() >> 4, blockposition.getZ() >> 4);
|
||||
+ return chunk == null ? null : chunk.getType(blockposition);
|
||||
+ }
|
||||
+ // Paper end
|
||||
|
@ -4,19 +4,6 @@ Date: Thu, 31 Mar 2016 19:17:58 -0400
|
||||
Subject: [PATCH] Do not load chunks for Pathfinding
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/ChunkCache.java b/src/main/java/net/minecraft/server/ChunkCache.java
|
||||
index 53c15c1c0bf2d902e6b0325e0964f88f6d5fd6a5..29c66b983dc503903a76bab753bb9035ec10f54c 100644
|
||||
--- a/src/main/java/net/minecraft/server/ChunkCache.java
|
||||
+++ b/src/main/java/net/minecraft/server/ChunkCache.java
|
||||
@@ -27,7 +27,7 @@ public class ChunkCache implements IBlockAccess, ICollisionAccess {
|
||||
|
||||
for (k = this.a; k <= i; ++k) {
|
||||
for (l = this.b; l <= j; ++l) {
|
||||
- this.c[k - this.a][l - this.b] = ichunkprovider.a(k, l);
|
||||
+ this.c[k - this.a][l - this.b] = world.getChunkIfLoadedImmediately(k, l); // Paper
|
||||
}
|
||||
}
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/NavigationAbstract.java b/src/main/java/net/minecraft/server/NavigationAbstract.java
|
||||
index 5e7158ba1053ae77fc5c5811d49214e877a5fe30..39a0c45bb0e3d2fcfbcc07192f9e1e61570c922e 100644
|
||||
--- a/src/main/java/net/minecraft/server/NavigationAbstract.java
|
||||
|
Loading…
Reference in New Issue
Block a user