From dfa5026a2960ca21f6346436cef7afc78bc0afed Mon Sep 17 00:00:00 2001 From: Sen Date: Wed, 21 May 2025 15:49:02 +0200 Subject: [PATCH] cap chunk height check in worldgen --- common/src/common/world/Chunk.java | 18 +++++++++--------- server/src/server/world/WorldServer.java | 11 ++++++++--- 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/common/src/common/world/Chunk.java b/common/src/common/world/Chunk.java index 6e6156c..506aa4f 100755 --- a/common/src/common/world/Chunk.java +++ b/common/src/common/world/Chunk.java @@ -181,8 +181,8 @@ public class Chunk { } protected void genHeights() { - int top = this.getTopSegment(); - int bottom = this.getBottomSegment(); + int top = this.top; + int bottom = this.bottom; this.minHeight = Integer.MAX_VALUE; for(int x = 0; x < 16; ++x) { @@ -209,8 +209,8 @@ public class Chunk { } public void genSkyLight() { - int top = this.getTopSegment(); - int bottom = this.getBottomSegment(); + int top = this.top; + int bottom = this.bottom; this.minHeight = Integer.MAX_VALUE; for(int x = 0; x < 16; ++x) { @@ -330,7 +330,7 @@ public class Chunk { private void relightBlock(int x, int y, int z) { int h = this.height[z << 4 | x]; - int min = this.getBottomSegment(); + int min = this.bottom; int cy = h; if(y > h) { @@ -811,8 +811,8 @@ public class Chunk { BlockPos loc = new BlockPos(pos.getX(), this.precHeight[o], pos.getZ()); if(loc.getY() == -99999999) { - int y = this.getTopSegment() + 15; - int min = this.getBottomSegment(); + int y = this.top + 15; + int min = this.bottom; loc = new BlockPos(pos.getX(), y, pos.getZ()); int h = -1; @@ -1089,8 +1089,8 @@ public class Chunk { } private boolean updateColumn(int x, int z) { - int top = this.getTopSegment(); - int bottom = this.getBottomSegment(); + int top = this.top; + int bottom = this.bottom; boolean opaque = false; boolean below = false; BlockPos.MutableBlockPos pos = new BlockPos.MutableBlockPos((this.xPos << 4) + x, 0, (this.zPos << 4) + z); diff --git a/server/src/server/world/WorldServer.java b/server/src/server/world/WorldServer.java index 53672f3..dd8a4f9 100755 --- a/server/src/server/world/WorldServer.java +++ b/server/src/server/world/WorldServer.java @@ -2438,11 +2438,16 @@ public final class WorldServer extends AWorldServer { public BlockPos getTopSolidOrLiquidBlock(BlockPos pos) { Chunk chunk = this.getChunk(pos); - BlockPos blockpos; + int h = chunk.getTopSegment(); + if(h == Integer.MIN_VALUE) + return new BlockPos(pos.getX(), 0, pos.getZ()); + BlockPos blockpos = new BlockPos(pos.getX(), h + 16, pos.getZ()); BlockPos blockpos1; - int bottom; + h = chunk.getBottomSegment(); + if(blockpos.getY() - h > 512) + h = blockpos.getY() - 512; - for(blockpos = new BlockPos(pos.getX(), chunk.getTopSegment() + 16, pos.getZ()), bottom = chunk.getBottomSegment(); blockpos.getY() >= bottom; blockpos = blockpos1) { + for(; blockpos.getY() >= h; blockpos = blockpos1) { blockpos1 = blockpos.down(); Material material = chunk.getBlock(blockpos1).getMaterial();