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

@ -181,8 +181,8 @@ public class Chunk {
} }
protected void genHeights() { protected void genHeights() {
int top = this.getTopSegment(); int top = this.top;
int bottom = this.getBottomSegment(); int bottom = this.bottom;
this.minHeight = Integer.MAX_VALUE; this.minHeight = Integer.MAX_VALUE;
for(int x = 0; x < 16; ++x) { for(int x = 0; x < 16; ++x) {
@ -209,8 +209,8 @@ public class Chunk {
} }
public void genSkyLight() { public void genSkyLight() {
int top = this.getTopSegment(); int top = this.top;
int bottom = this.getBottomSegment(); int bottom = this.bottom;
this.minHeight = Integer.MAX_VALUE; this.minHeight = Integer.MAX_VALUE;
for(int x = 0; x < 16; ++x) { for(int x = 0; x < 16; ++x) {
@ -330,7 +330,7 @@ public class Chunk {
private void relightBlock(int x, int y, int z) { private void relightBlock(int x, int y, int z) {
int h = this.height[z << 4 | x]; int h = this.height[z << 4 | x];
int min = this.getBottomSegment(); int min = this.bottom;
int cy = h; int cy = h;
if(y > h) { if(y > h) {
@ -811,8 +811,8 @@ public class Chunk {
BlockPos loc = new BlockPos(pos.getX(), this.precHeight[o], pos.getZ()); BlockPos loc = new BlockPos(pos.getX(), this.precHeight[o], pos.getZ());
if(loc.getY() == -99999999) { if(loc.getY() == -99999999) {
int y = this.getTopSegment() + 15; int y = this.top + 15;
int min = this.getBottomSegment(); int min = this.bottom;
loc = new BlockPos(pos.getX(), y, pos.getZ()); loc = new BlockPos(pos.getX(), y, pos.getZ());
int h = -1; int h = -1;
@ -1089,8 +1089,8 @@ public class Chunk {
} }
private boolean updateColumn(int x, int z) { private boolean updateColumn(int x, int z) {
int top = this.getTopSegment(); int top = this.top;
int bottom = this.getBottomSegment(); int bottom = this.bottom;
boolean opaque = false; boolean opaque = false;
boolean below = false; boolean below = false;
BlockPos.MutableBlockPos pos = new BlockPos.MutableBlockPos((this.xPos << 4) + x, 0, (this.zPos << 4) + z); BlockPos.MutableBlockPos pos = new BlockPos.MutableBlockPos((this.xPos << 4) + x, 0, (this.zPos << 4) + z);

View file

@ -2438,11 +2438,16 @@ public final class WorldServer extends AWorldServer {
public BlockPos getTopSolidOrLiquidBlock(BlockPos pos) { public BlockPos getTopSolidOrLiquidBlock(BlockPos pos) {
Chunk chunk = this.getChunk(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; 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(); blockpos1 = blockpos.down();
Material material = chunk.getBlock(blockpos1).getMaterial(); Material material = chunk.getBlock(blockpos1).getMaterial();