fabric-1.18: update to 1.18 chunk format

This commit is contained in:
Kosma Moczek 2021-11-26 18:37:22 +01:00
parent c1c1ba13c8
commit f457ca02a4
2 changed files with 7 additions and 6 deletions

View file

@ -165,7 +165,7 @@ public class ChunkSnapshot {
sectcnt++; sectcnt++;
} }
/* Get sections */ /* Get sections */
NbtList sect = nbt.getList("Sections", 10); NbtList sect = nbt.getList("sections", 10);
for (int i = 0; i < sect.size(); i++) { for (int i = 0; i < sect.size(); i++) {
NbtCompound sec = sect.getCompound(i); NbtCompound sec = sect.getCompound(i);
int secnum = sec.getByte("Y"); int secnum = sec.getByte("Y");
@ -186,10 +186,11 @@ public class ChunkSnapshot {
sections.set(secnum + sectoff, cursect); sections.set(secnum + sectoff, cursect);
DynmapBlockState[] states = cursect.states; DynmapBlockState[] states = cursect.states;
DynmapBlockState[] palette = null; DynmapBlockState[] palette = null;
// If we've got palette and block states list, process non-empty section NbtCompound block_states = sec.getCompound("block_states");
if (sec.contains("Palette", 9) && sec.contains("BlockStates", 12)) { // If we've block state data, process non-empty section
NbtList plist = sec.getList("Palette", 10); if (block_states.contains("data", 12)) {
long[] statelist = sec.getLongArray("BlockStates"); long[] statelist = block_states.getLongArray("data");
NbtList plist = block_states.getList("palette", 10);
palette = new DynmapBlockState[plist.size()]; palette = new DynmapBlockState[plist.size()];
for (int pi = 0; pi < plist.size(); pi++) { for (int pi = 0; pi < plist.size(); pi++) {
NbtCompound tc = plist.getCompound(pi); NbtCompound tc = plist.getCompound(pi);
@ -247,6 +248,7 @@ public class ChunkSnapshot {
} }
} }
/* Get biome data */ /* Get biome data */
// TODO: Update to new 1.18 format (3D biomes, sectioned):
this.biome = new int[COLUMNS_PER_CHUNK]; this.biome = new int[COLUMNS_PER_CHUNK];
if (nbt.contains("Biomes")) { if (nbt.contains("Biomes")) {
int[] bb = nbt.getIntArray("Biomes"); int[] bb = nbt.getIntArray("Biomes");

View file

@ -1099,7 +1099,6 @@ public class FabricMapChunkCache extends MapChunkCache {
Log.severe("ChunkSerializer.serialize threw a NullPointerException", e); Log.severe("ChunkSerializer.serialize threw a NullPointerException", e);
continue; continue;
} }
if (nbt != null) nbt = nbt.getCompound("Level");
try { try {
SnapshotCache.SnapshotRec ssr = prepChunkSnapshot(chunk, nbt); SnapshotCache.SnapshotRec ssr = prepChunkSnapshot(chunk, nbt);
ss = ssr.ss; ss = ssr.ss;