Fix getBlockStateIfLoaded world bounds check

Closes #8922
This commit is contained in:
Nassim Jahnke 2023-02-28 12:27:38 +01:00
parent 6910253909
commit 5a125e0fc3

View File

@ -6863,21 +6863,22 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ +
+ @Override + @Override
+ @Nullable + @Nullable
+ public final BlockState getBlockStateIfLoaded(BlockPos blockposition) { + public final BlockState getBlockStateIfLoaded(BlockPos pos) {
+ // CraftBukkit start - tree generation + // CraftBukkit start - tree generation
+ if (captureTreeGeneration) { + if (this.captureTreeGeneration) {
+ CraftBlockState previous = capturedBlockStates.get(blockposition); + CraftBlockState previous = this.capturedBlockStates.get(pos);
+ if (previous != null) { + if (previous != null) {
+ return previous.getHandle(); + return previous.getHandle();
+ } + }
+ } + }
+ // CraftBukkit end + // CraftBukkit end
+ if (!isInWorldBounds(blockposition)) { + if (this.isOutsideBuildHeight(pos)) {
+ return Blocks.AIR.defaultBlockState(); + return Blocks.VOID_AIR.defaultBlockState();
+ } + } else {
+ ChunkAccess chunk = this.getChunkIfLoadedImmediately(blockposition.getX() >> 4, blockposition.getZ() >> 4); + ChunkAccess chunk = this.getChunkIfLoadedImmediately(pos.getX() >> 4, pos.getZ() >> 4);
+ +
+ return chunk == null ? null : chunk.getBlockState(blockposition); + return chunk == null ? null : chunk.getBlockState(pos);
+ }
+ } + }
+ +
+ @Override + @Override