From b82095fcb65fef747f23b81cb8a04fb41ae0bd9b Mon Sep 17 00:00:00 2001 From: Kosma Moczek Date: Fri, 26 Nov 2021 18:37:22 +0100 Subject: [PATCH] fabric-1.18: update to 1.18 chunk format --- .../java/org/dynmap/fabric_1_18/ChunkSnapshot.java | 12 +++++++----- .../org/dynmap/fabric_1_18/FabricMapChunkCache.java | 1 - 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/fabric-1.18/src/main/java/org/dynmap/fabric_1_18/ChunkSnapshot.java b/fabric-1.18/src/main/java/org/dynmap/fabric_1_18/ChunkSnapshot.java index bba5e014..688e7904 100644 --- a/fabric-1.18/src/main/java/org/dynmap/fabric_1_18/ChunkSnapshot.java +++ b/fabric-1.18/src/main/java/org/dynmap/fabric_1_18/ChunkSnapshot.java @@ -165,7 +165,7 @@ public class ChunkSnapshot { sectcnt++; } /* Get sections */ - NbtList sect = nbt.getList("Sections", 10); + NbtList sect = nbt.getList("sections", 10); for (int i = 0; i < sect.size(); i++) { NbtCompound sec = sect.getCompound(i); int secnum = sec.getByte("Y"); @@ -186,10 +186,11 @@ public class ChunkSnapshot { sections.set(secnum + sectoff, cursect); DynmapBlockState[] states = cursect.states; DynmapBlockState[] palette = null; - // If we've got palette and block states list, process non-empty section - if (sec.contains("Palette", 9) && sec.contains("BlockStates", 12)) { - NbtList plist = sec.getList("Palette", 10); - long[] statelist = sec.getLongArray("BlockStates"); + NbtCompound block_states = sec.getCompound("block_states"); + // If we've block state data, process non-empty section + if (block_states.contains("data", 12)) { + long[] statelist = block_states.getLongArray("data"); + NbtList plist = block_states.getList("palette", 10); palette = new DynmapBlockState[plist.size()]; for (int pi = 0; pi < plist.size(); pi++) { NbtCompound tc = plist.getCompound(pi); @@ -247,6 +248,7 @@ public class ChunkSnapshot { } } /* Get biome data */ + // TODO: Update to new 1.18 format (3D biomes, sectioned): this.biome = new int[COLUMNS_PER_CHUNK]; if (nbt.contains("Biomes")) { int[] bb = nbt.getIntArray("Biomes"); diff --git a/fabric-1.18/src/main/java/org/dynmap/fabric_1_18/FabricMapChunkCache.java b/fabric-1.18/src/main/java/org/dynmap/fabric_1_18/FabricMapChunkCache.java index bb881dc8..e496d199 100644 --- a/fabric-1.18/src/main/java/org/dynmap/fabric_1_18/FabricMapChunkCache.java +++ b/fabric-1.18/src/main/java/org/dynmap/fabric_1_18/FabricMapChunkCache.java @@ -1099,7 +1099,6 @@ public class FabricMapChunkCache extends MapChunkCache { Log.severe("ChunkSerializer.serialize threw a NullPointerException", e); continue; } - if (nbt != null) nbt = nbt.getCompound("Level"); try { SnapshotCache.SnapshotRec ssr = prepChunkSnapshot(chunk, nbt); ss = ssr.ss;