add option to fix rain lag

This commit is contained in:
Sen 2025-06-30 11:37:23 +02:00
parent 2a0e6c3cf7
commit ea2d11ae3a
Signed by: sen
GPG key ID: 3AC50A6F47D1B722
7 changed files with 164 additions and 260 deletions

View file

@ -61,7 +61,7 @@ public abstract class Chunk {
for(int y = 0; y < this.entities.length; ++y) {
this.entities[y] = new InheritanceMultiMap(Entity.class);
}
Arrays.fill(this.precHeight, -99999999);
Arrays.fill(this.precHeight, Integer.MIN_VALUE);
}
public int getHeight(int x, int z) {
@ -88,7 +88,7 @@ public abstract class Chunk {
for(int x = 0; x < 16; ++x) {
for(int z = 0; z < 16; ++z) {
this.precHeight[x + (z << 4)] = -99999999;
this.precHeight[x + (z << 4)] = Integer.MIN_VALUE;
for(int y = top + 16; y > bottom; --y) {
if(this.getOpacity(x, y - 1, z) != 0) {
@ -315,7 +315,7 @@ public abstract class Chunk {
int o = z << 4 | x;
if(y >= this.precHeight[o] - 1) {
this.precHeight[o] = -99999999;
this.precHeight[o] = Integer.MIN_VALUE;
}
int h = this.height[o];
@ -631,13 +631,12 @@ public abstract class Chunk {
int o = x | z << 4;
BlockPos loc = new BlockPos(pos.getX(), this.precHeight[o], pos.getZ());
if(loc.getY() == -99999999) {
if(loc.getY() == Integer.MIN_VALUE) {
int y = this.top + 15;
int min = this.bottom < -64 ? -64 : this.bottom;
loc = new BlockPos(pos.getX(), y, pos.getZ());
int h = -99999999;
while(loc.getY() > min && h == -99999999) {
while(loc.getY() > min) {
Block block = this.getBlock(loc);
Material mat = block.getMaterial();
@ -647,11 +646,11 @@ public abstract class Chunk {
loc = loc.down();
}
else {
h = loc.getY() + 1;
return new BlockPos(pos.getX(), this.precHeight[o] = loc.getY() + 1, pos.getZ());
}
}
this.precHeight[o] = h;
return new BlockPos(pos.getX(), this.precHeight[o] = -64, pos.getZ());
}
return new BlockPos(pos.getX(), this.precHeight[o], pos.getZ());