Co-authored-by: Bjarne Koll <git@lynxplay.dev> Co-authored-by: Jake Potrebic <jake.m.potrebic@gmail.com> Co-authored-by: Lulu13022002 <41980282+Lulu13022002@users.noreply.github.com> Co-authored-by: MiniDigger | Martin <admin@minidigger.dev> Co-authored-by: Nassim Jahnke <nassim@njahnke.dev> Co-authored-by: Noah van der Aa <ndvdaa@gmail.com> Co-authored-by: Owen1212055 <23108066+Owen1212055@users.noreply.github.com> Co-authored-by: Shane Freeder <theboyetronic@gmail.com> Co-authored-by: Spottedleaf <Spottedleaf@users.noreply.github.com> Co-authored-by: Tamion <70228790+notTamion@users.noreply.github.com> Co-authored-by: Warrior <50800980+Warriorrrr@users.noreply.github.com>
46 lines
1.8 KiB
Diff
46 lines
1.8 KiB
Diff
--- a/net/minecraft/world/level/PathNavigationRegion.java
|
|
+++ b/net/minecraft/world/level/PathNavigationRegion.java
|
|
@@ -66,13 +_,41 @@
|
|
private ChunkAccess getChunk(int x, int z) {
|
|
int i = x - this.centerX;
|
|
int i1 = z - this.centerZ;
|
|
- if (i >= 0 && i < this.chunks.length && i1 >= 0 && i1 < this.chunks[i].length) {
|
|
+ if (i >= 0 && i < this.chunks.length && i1 >= 0 && i1 < this.chunks[i].length) { // Paper - if this changes, update getChunkIfLoaded below
|
|
ChunkAccess chunkAccess = this.chunks[i][i1];
|
|
return (ChunkAccess)(chunkAccess != null ? chunkAccess : new EmptyLevelChunk(this.level, new ChunkPos(x, z), this.plains.get()));
|
|
} else {
|
|
return new EmptyLevelChunk(this.level, new ChunkPos(x, z), this.plains.get());
|
|
}
|
|
}
|
|
+
|
|
+ // Paper start - if loaded util
|
|
+ @Nullable
|
|
+ private ChunkAccess getChunkIfLoaded(int x, int z) {
|
|
+ // Based on getChunk(int, int)
|
|
+ int xx = x - this.centerX;
|
|
+ int zz = z - this.centerZ;
|
|
+
|
|
+ if (xx >= 0 && xx < this.chunks.length && zz >= 0 && zz < this.chunks[xx].length) {
|
|
+ return this.chunks[xx][zz];
|
|
+ }
|
|
+ return null;
|
|
+ }
|
|
+
|
|
+ @Nullable
|
|
+ @Override
|
|
+ public final FluidState getFluidIfLoaded(BlockPos pos) {
|
|
+ ChunkAccess chunk = getChunkIfLoaded(pos.getX() >> 4, pos.getZ() >> 4);
|
|
+ return chunk == null ? null : chunk.getFluidState(pos);
|
|
+ }
|
|
+
|
|
+ @Nullable
|
|
+ @Override
|
|
+ public final BlockState getBlockStateIfLoaded(BlockPos pos) {
|
|
+ ChunkAccess chunk = getChunkIfLoaded(pos.getX() >> 4, pos.getZ() >> 4);
|
|
+ return chunk == null ? null : chunk.getBlockState(pos);
|
|
+ }
|
|
+ // Paper end
|
|
|
|
@Override
|
|
public WorldBorder getWorldBorder() {
|