cap chunk height check in worldgen

This commit is contained in:
Sen 2025-05-21 15:49:02 +02:00
parent 2dd83c61dc
commit dfa5026a29
2 changed files with 17 additions and 12 deletions

View file

@ -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();