Skip to content

Commit

Permalink
Hack for chunk migration
Browse files Browse the repository at this point in the history
  • Loading branch information
mikeprimm committed Sep 10, 2023
1 parent 85012ae commit 5645bae
Showing 1 changed file with 28 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.dynmap.forge_1_18_2;

import java.util.HashMap;
import java.util.List;

import net.minecraft.world.level.biome.Biome;
Expand All @@ -10,6 +11,7 @@
import org.dynmap.common.chunk.GenericChunk;
import org.dynmap.common.chunk.GenericChunkCache;
import org.dynmap.common.chunk.GenericMapChunkCache;
import org.dynmap.utils.TileFlags;

import net.minecraft.nbt.CompoundTag;
import net.minecraft.server.level.ServerChunkCache;
Expand Down Expand Up @@ -65,6 +67,8 @@ public void setChunks(ForgeWorld dw, List<DynmapChunk> chunks) {
super.setChunks(dw, chunks);
}

private static HashMap<String, TileFlags> tmap = new HashMap<String, TileFlags>();

private CompoundTag readChunk(int x, int z) {
try {
CompoundTag rslt = cps.chunkMap.read(new ChunkPos(x, z));
Expand All @@ -82,6 +86,30 @@ private CompoundTag readChunk(int x, int z) {
rslt = null;
}
}
if (rslt != null) {
int version = rslt.getInt("DataVersion");
if (version < 2975) {
boolean doIt = false;
synchronized(tmap) {
TileFlags tf = tmap.get(dw.getName());
if (tf == null) {
tf = new TileFlags();
tmap.put(dw.getName(), tf);
}
if (!tf.getFlag(x, z)) {
tf.setFlag(x, z, true);
doIt = true;
}
}
if (doIt) {
ChunkPos pos = new ChunkPos(x, z);
CompoundTag newrec = cps.chunkMap.readChunk(pos);
if (rslt != null) {
cps.chunkMap.write(pos, newrec.copy());
}
}
}
}
// Log.info(String.format("loadChunk(%d,%d)=%s", x, z, (rslt != null) ?
// rslt.toString() : "null"));
return rslt;
Expand Down

0 comments on commit 5645bae

Please sign in to comment.