mirror of https://github.com/webbukkit/dynmap.git
Workaround bizarre 1.17->1.18 chunk lifecycle (Spigot, Fabric, Forge)
This commit is contained in:
parent
546ffffdc0
commit
54471c6695
|
@ -901,6 +901,8 @@ public abstract class GenericMapChunkCache extends MapChunkCache {
|
|||
nbt = nbt.getCompound("Level");
|
||||
}
|
||||
if (nbt == null) return null;
|
||||
boolean hasLight = false;
|
||||
boolean isEmpty = nbt.getString("Status").equals("empty"); // Incomplete migration
|
||||
// Start generic chunk builder
|
||||
GenericChunk.Builder bld = new GenericChunk.Builder(dw.minY, dw.worldheight);
|
||||
int x = nbt.getInt("xPos");
|
||||
|
@ -1047,9 +1049,11 @@ public abstract class GenericMapChunkCache extends MapChunkCache {
|
|||
}
|
||||
if (sec.contains("BlockLight")) {
|
||||
sbld.emittedLight(sec.getByteArray("BlockLight"));
|
||||
hasLight = true;
|
||||
}
|
||||
if (sec.contains("SkyLight")) {
|
||||
sbld.skyLight(sec.getByteArray("SkyLight"));
|
||||
hasLight = true;
|
||||
}
|
||||
// If section biome palette
|
||||
if (sec.contains("biomes")) {
|
||||
|
@ -1083,7 +1087,8 @@ public abstract class GenericMapChunkCache extends MapChunkCache {
|
|||
bld.addSection(secnum, sbld.build());
|
||||
sbld.reset();
|
||||
}
|
||||
return bld.build();
|
||||
// If isEmpty and has no light, drop it
|
||||
return (isEmpty && (!hasLight)) ? null : bld.build();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -57,7 +57,7 @@ public class MapChunkCache118 extends GenericMapChunkCache {
|
|||
if (nbt != null) {
|
||||
String stat = nbt.l("Status");
|
||||
ChunkStatus cs = ChunkStatus.a(stat);
|
||||
if ((stat != null) && cs.b(ChunkStatus.l)) { // ChunkStatus.LIGHT
|
||||
if ((stat != null) && (cs.b(ChunkStatus.l) || (cs == ChunkStatus.c))) { // ChunkStatus.LIGHT OR ChunkStatus.EMPTY (migrated use this for some reason)
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -60,30 +60,6 @@ public class FabricMapChunkCache extends GenericMapChunkCache {
|
|||
super.setChunks(dw, chunks);
|
||||
}
|
||||
|
||||
private NbtCompound readChunk(int x, int z) {
|
||||
try {
|
||||
ThreadedAnvilChunkStorage acl = cps.threadedAnvilChunkStorage;
|
||||
|
||||
ChunkPos coord = new ChunkPos(x, z);
|
||||
NbtCompound rslt = acl.getNbt(coord);
|
||||
if (rslt != null) {
|
||||
// Don't load uncooked chunks
|
||||
String stat = rslt.getString("Status");
|
||||
ChunkStatus cs = ChunkStatus.byId(stat);
|
||||
if ((stat == null) ||
|
||||
// Needs to be at least lighted
|
||||
(!cs.isAtLeast(ChunkStatus.LIGHT))) {
|
||||
rslt = null;
|
||||
}
|
||||
}
|
||||
//Log.info(String.format("loadChunk(%d,%d)=%s", x, z, (rslt != null) ? rslt.toString() : "null"));
|
||||
return rslt;
|
||||
} catch (Exception exc) {
|
||||
Log.severe(String.format("Error reading chunk: %s,%d,%d", dw.getName(), x, z), exc);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isLitChunk(NbtCompound nbt) {
|
||||
if ((nbt != null) && nbt.contains("Level")) {
|
||||
nbt = nbt.getCompound("Level");
|
||||
|
@ -91,7 +67,7 @@ public class FabricMapChunkCache extends GenericMapChunkCache {
|
|||
if (nbt != null) {
|
||||
String stat = nbt.getString("Status");
|
||||
ChunkStatus cs = ChunkStatus.byId(stat);
|
||||
if ((stat != null) && cs.isAtLeast(ChunkStatus.LIGHT)) { // ChunkStatus.LIGHT
|
||||
if ((stat != null) && (cs.isAtLeast(ChunkStatus.LIGHT) || (cs == ChunkStatus.EMPTY))) { // ChunkStatus.LIGHT OR migrated EMPTY
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -115,7 +91,19 @@ public class FabricMapChunkCache extends GenericMapChunkCache {
|
|||
}
|
||||
return gc;
|
||||
}
|
||||
|
||||
|
||||
private NbtCompound readChunk(int x, int z) {
|
||||
try {
|
||||
ThreadedAnvilChunkStorage acl = cps.threadedAnvilChunkStorage;
|
||||
|
||||
ChunkPos coord = new ChunkPos(x, z);
|
||||
return acl.getNbt(coord);
|
||||
} catch (Exception exc) {
|
||||
Log.severe(String.format("Error reading chunk: %s,%d,%d", dw.getName(), x, z), exc);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
// Load generic chunk from unloaded chunk
|
||||
protected GenericChunk loadChunk(DynmapChunk chunk) {
|
||||
GenericChunk gc = null;
|
||||
|
|
|
@ -38,7 +38,7 @@ public class ForgeMapChunkCache extends GenericMapChunkCache {
|
|||
if (nbt != null) {
|
||||
String stat = nbt.getString("Status");
|
||||
ChunkStatus cs = ChunkStatus.byName(stat);
|
||||
if ((stat != null) && cs.isOrAfter(ChunkStatus.LIGHT)) { // ChunkStatus.LIGHT
|
||||
if ((stat != null) && (cs.isOrAfter(ChunkStatus.LIGHT) || (cs == ChunkStatus.EMPTY))) { // ChunkStatus.LIGHT or migrated EMPTY
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue