From 2c55fce23e2c2a58a463d95bbaededb0c46af7f4 Mon Sep 17 00:00:00 2001 From: Jake Potrebic Date: Fri, 9 Jul 2021 03:16:57 -0700 Subject: [PATCH] Fix collisions during world generation (#6129) --- .../Optimize-Collision-to-not-load-chunks.patch | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/patches/server/Optimize-Collision-to-not-load-chunks.patch b/patches/server/Optimize-Collision-to-not-load-chunks.patch index 2eb1a719a7..19e76f851f 100644 --- a/patches/server/Optimize-Collision-to-not-load-chunks.patch +++ b/patches/server/Optimize-Collision-to-not-load-chunks.patch @@ -76,11 +76,18 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + boolean far = this.source != null && net.minecraft.server.MCUtil.distanceSq(this.source.getX(), y, this.source.getZ(), x, y, z) > 14; + this.pos.set(x, y, z); + -+ boolean isRegionLimited = this.collisionGetter instanceof net.minecraft.server.level.WorldGenRegion; -+ BlockState blockState = isRegionLimited ? Blocks.VOID_AIR.defaultBlockState() : ((!far && this.source instanceof net.minecraft.server.level.ServerPlayer) || (this.source != null && this.source.collisionLoadChunks) -+ ? this.collisionGetter.getBlockState(this.pos) -+ : this.collisionGetter.getTypeIfLoaded(this.pos) -+ ); ++ BlockState blockState; ++ if (this.collisionGetter instanceof net.minecraft.server.level.WorldGenRegion) { ++ BlockGetter blockGetter = this.getChunk(x, z); ++ if (blockGetter == null) { ++ continue; ++ } ++ blockState = blockGetter.getBlockState(this.pos); ++ } else if ((!far && this.source instanceof net.minecraft.server.level.ServerPlayer) || (this.source != null && this.source.collisionLoadChunks)) { ++ blockState = this.collisionGetter.getBlockState(this.pos); ++ } else { ++ blockState = this.collisionGetter.getTypeIfLoaded(this.pos); ++ } + + if (blockState == null) { + if (!(this.source instanceof net.minecraft.server.level.ServerPlayer) || this.source.level.paperConfig.preventMovingIntoUnloadedChunks) {