Tune memory use on generic chunks, lighting lookup performance

This commit is contained in:
Mike Primm 2021-12-28 22:14:19 -06:00
parent adcfedd68e
commit 0166895a7f
14 changed files with 300 additions and 37 deletions

View file

@ -132,6 +132,29 @@ public class FabricMapChunkCache extends MapChunkCache {
return 0;
}
}
@Override
/**
* Get block sky and emitted light, relative to current coordinate
* @return (emitted light * 256) + sky light
*/
public final int getBlockLight(BlockStep step) {
int emit = 0, sky = 15;
if (step.yoff != 0) { // Y coord - snap is valid already
int ny = y + step.yoff;
emit = snap.getBlockEmittedLight(x, ny, z);
sky = snap.getBlockSkyLight(x, ny, z);
}
else {
int nx = x + step.xoff;
int nz = z + step.zoff;
int nchunkindex = ((nx >> 4) - x_min) + (((nz >> 4) - z_min) * x_dim);
if ((nchunkindex < snapcnt) && (nchunkindex >= 0)) {
emit = snaparray[nchunkindex].getBlockEmittedLight(nx, y, nz);
sky = snaparray[nchunkindex].getBlockSkyLight(nx, y, nz);
}
}
return (emit << 8) + sky;
}
private void biomePrep() {
if (sameneighborbiomecnt != null) {