This commit is contained in:
mcrcortex
2025-04-04 13:20:20 +10:00
parent 3c079397cd
commit 856b5b5b56
2 changed files with 17 additions and 14 deletions

View File

@@ -154,7 +154,7 @@ public class WorldConversionFactory {
long sample = 0; long sample = 0;
int c = 0; int c = 0;
int dec = 0; int dec = 0;
for (int i = 0; i < 0xFFF; i++) { for (int i = 0; i <= 0xFFF; i++) {
if (dec-- == 0) { if (dec-- == 0) {
sample = bDat[c++]; sample = bDat[c++];
dec = iterPerLong; dec = iterPerLong;
@@ -180,17 +180,13 @@ public class WorldConversionFactory {
} }
int bId = pc[0]; int bId = pc[0];
if (bId == 0) {//Its air if (bId == 0) {//Its air
for (int i = 0; i < 0xFFF; i++) { for (int i = 0; i <= 0xFFF; i++) {
data[i] = Mapper.airWithLight(lightSupplier.supply(i&0xF, (i>>8)&0xF, (i>>4)&0xF)); data[i] = Mapper.airWithLight(lightSupplier.supply(i&0xF, (i>>8)&0xF, (i>>4)&0xF));
} }
} else { } else {
for (int i = 0; i < 0xFFF; i++) { for (int i = 0; i <= 0xFFF; i++) {
byte light = lightSupplier.supply(i&0xF, (i>>8)&0xF, (i>>4)&0xF); byte light = lightSupplier.supply(i&0xF, (i>>8)&0xF, (i>>4)&0xF);
if (light != 0) { data[i] = Mapper.composeMappingId(light, bId, biomes[Integer.compress(i,0b1100_1100_1100)]);
data[i] = Mapper.composeMappingId(light, bId, biomes[Integer.compress(i,0b1100_1100_1100)]);
} else {
data[i] = Mapper.AIR;
}
} }
} }
} }

View File

@@ -39,16 +39,23 @@ public class WorldUpdater {
{//Do a bunch of funny math {//Do a bunch of funny math
var secD = worldSection.data;
int baseVIdx = VoxelizedSection.getBaseIndexForLevel(lvl); int baseVIdx = VoxelizedSection.getBaseIndexForLevel(lvl);
int baseSec = bx | (bz << 5) | (by << 10); int baseSec = bx | (bz << 5) | (by << 10);
int secMsk = 0xF >> lvl; int secMsk = 0xF >> lvl;
secMsk |= (secMsk << 5) | (secMsk << 10); secMsk |= (secMsk << 5) | (secMsk << 10);
var secD = worldSection.data; int iSecMsk1 =(~secMsk)+1;
for (int i = 0; i <= 0xFFF >> (lvl * 3); i++) {
int secIdx = Integer.expand(i, secMsk)+baseSec; int secIdx = 0;
long newId = vdat[baseVIdx+i]; for (int i = baseVIdx; i <= (0xFFF >> (lvl * 3)) + baseVIdx; i++) {
long oldId = secD[secIdx]; secD[secIdx] = newId; int cSecIdx = secIdx+baseSec;
nonAirCountDelta += (Mapper.isAir(newId)?1:0)-(Mapper.isAir(oldId)?1:0); secIdx = (secIdx + iSecMsk1)&secMsk;
long newId = vdat[i];
long oldId = secD[cSecIdx]; secD[cSecIdx] = newId;
nonAirCountDelta += (Mapper.isAir(newId)?0:1)-(Mapper.isAir(oldId)?0:1);//its 0:1 cause its nonAir
didStateChange |= newId != oldId; didStateChange |= newId != oldId;
} }
} }