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
+ @Nullable
+ public final BlockState getBlockStateIfLoaded(BlockPos blockposition) {
+ public final BlockState getBlockStateIfLoaded(BlockPos pos) {
+ // CraftBukkit start - tree generation
+ if (captureTreeGeneration) {
+ CraftBlockState previous = capturedBlockStates.get(blockposition);
+ if (this.captureTreeGeneration) {
+ CraftBlockState previous = this.capturedBlockStates.get(pos);
+ if (previous != null) {
+ return previous.getHandle();
+ }
+ }
+ // CraftBukkit end
+ if (!isInWorldBounds(blockposition)) {
+ return Blocks.AIR.defaultBlockState();
+ }
+ ChunkAccess chunk = this.getChunkIfLoadedImmediately(blockposition.getX() >> 4, blockposition.getZ() >> 4);
+ if (this.isOutsideBuildHeight(pos)) {
+ return Blocks.VOID_AIR.defaultBlockState();
+ } else {
+ 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