fix chunk glitch

This commit is contained in:
Sen 2025-07-01 16:36:33 +02:00
parent 24e249913d
commit f241158cc1
Signed by: sen
GPG key ID: 3AC50A6F47D1B722
3 changed files with 21 additions and 5 deletions

View file

@ -8,15 +8,19 @@ import common.init.Blocks;
import common.util.NibbleArray;
public class BlockArray {
private int yBase;
private final int yBase;
private final State filler;
private int blocks;
private int ticked;
private int filled;
private char[] data;
private NibbleArray blocklight;
private NibbleArray skylight;
public BlockArray(int y, boolean sky, State filler) {
this.yBase = y;
this.filler = filler;
this.data = new char[4096];
this.blocklight = new NibbleArray();
if(sky)
@ -47,6 +51,10 @@ public class BlockArray {
if(block.getTickRandomly())
++this.ticked;
}
if(ostate == this.filler)
++this.filled;
if(state == this.filler)
--this.filled;
this.data[y << 8 | z << 4 | x] = (char)BlockRegistry.getId(state);
}
@ -54,6 +62,10 @@ public class BlockArray {
return this.get(x, y, z).getBlock();
}
public boolean hasData() {
return this.filler != null ? (this.filled > 0) : (this.blocks > 0);
}
public boolean isEmpty() {
return this.blocks == 0;
}
@ -85,15 +97,19 @@ public class BlockArray {
public void update() {
this.blocks = 0;
this.ticked = 0;
this.filled = 0;
for(int i = 0; i < 16; ++i) {
for(int j = 0; j < 16; ++j) {
for(int k = 0; k < 16; ++k) {
Block block = this.getBlock(i, j, k);
State state = this.get(i, j, k);
Block block = state.getBlock();
if(block != Blocks.air) {
++this.blocks;
if(block.getTickRandomly())
++this.ticked;
}
if(this.filler != null && state != this.filler)
++this.filled;
}
}
}