diff --git a/DynmapCore/src/main/java/org/dynmap/common/BiomeMap.java b/DynmapCore/src/main/java/org/dynmap/common/BiomeMap.java index e782e688..a1225922 100644 --- a/DynmapCore/src/main/java/org/dynmap/common/BiomeMap.java +++ b/DynmapCore/src/main/java/org/dynmap/common/BiomeMap.java @@ -150,7 +150,7 @@ public class BiomeMap { private static void resizeIfNeeded(int idx) { if ((idx >= biome_by_index.length) ) { int oldlen = biome_by_index.length; - biome_by_index = Arrays.copyOf(biome_by_index, biome_by_index.length * 3 / 2); + biome_by_index = Arrays.copyOf(biome_by_index, idx * 3 / 2); for (int i = oldlen; i < biome_by_index.length; i++) { if (biome_by_index[i] == null) { BiomeMap bm = new BiomeMap(i, "BIOME_" + i); @@ -176,15 +176,18 @@ public class BiomeMap { this.id = id; // If index is NO_INDEX, find one after the well known ones if (idx == NO_INDEX) { - idx = LAST_WELL_KNOWN + 1; + idx = LAST_WELL_KNOWN; while (true) { - resizeIfNeeded(idx); + idx++; + resizeIfNeeded(idx); if (biome_by_index[idx].isDef) { break; } } } - idx++; /* Insert one after ID value - null is zero index */ + else { + idx++; /* Insert one after ID value - null is zero index */ + } this.index = idx; if (idx >= 0) { resizeIfNeeded(idx); @@ -262,9 +265,6 @@ public class BiomeMap { public int getBiomeID() { return index - 1; // Index of biome in MC biome table } - public final String toString() { - return id; - } public static final BiomeMap[] values() { return biome_by_index; } @@ -298,4 +298,7 @@ public class BiomeMap { public boolean isDefault() { return isDef; } + public String toString() { + return String.format("%s[%d]:t%f,h%f,w%x,g%x,f%x,rl=%s", id, index, tmp, rain, watercolormult, grassmult, foliagemult, resourcelocation); + } } diff --git a/DynmapCore/src/main/java/org/dynmap/common/chunk/GenericChunk.java b/DynmapCore/src/main/java/org/dynmap/common/chunk/GenericChunk.java index 1e778c34..9cc198bc 100644 --- a/DynmapCore/src/main/java/org/dynmap/common/chunk/GenericChunk.java +++ b/DynmapCore/src/main/java/org/dynmap/common/chunk/GenericChunk.java @@ -64,7 +64,10 @@ public class GenericChunk { public final long getInhabitedTicks() { return inhabitedTicks; } - + public String toString() { + return String.format("chunk(%d,%d:%s,off=%d", cx, cz, Arrays.deepToString((sections)), cy_min); + } + // Generic empty (coordinates are wrong, but safe otherwise public static final GenericChunk EMPTY = new GenericChunk(0, 0, -4, new GenericChunkSection[24], 0); diff --git a/DynmapCore/src/main/java/org/dynmap/common/chunk/GenericChunkSection.java b/DynmapCore/src/main/java/org/dynmap/common/chunk/GenericChunkSection.java index 46ed5b11..6022d8f5 100644 --- a/DynmapCore/src/main/java/org/dynmap/common/chunk/GenericChunkSection.java +++ b/DynmapCore/src/main/java/org/dynmap/common/chunk/GenericChunkSection.java @@ -61,6 +61,9 @@ public class GenericChunkSection { public final BiomeMap getBiome(GenericChunkPos pos) { return biomes[pos.soffset & 0xFF]; // Just ZX portion } + public String toString() { + return String.format("Biome2D(%s)", Arrays.deepToString(biomes)); + } } // For 3D biome map private static class BiomeAccess3D implements BiomeAccess { @@ -75,6 +78,9 @@ public class GenericChunkSection { public final BiomeMap getBiome(GenericChunkPos pos) { return biomes[pos.sdiv4offset]; } + public String toString() { + return String.format("Biome3D(%s)", Arrays.deepToString(biomes)); + } } // For single biome map private static class BiomeAccessSingle implements BiomeAccess { @@ -88,6 +94,9 @@ public class GenericChunkSection { public final BiomeMap getBiome(GenericChunkPos pos) { return biome; } + public String toString() { + return String.format("Biome1(%s)", biome); + } } // Lighting access interface public interface LightingAccess { @@ -132,6 +141,9 @@ public class GenericChunkSection { emitted = emitac; isEmpty = empty; } + public String toString() { + return String.format("sect(bip:%s)", biomes); + } private static BiomeAccess defaultBiome = new BiomeAccessSingle(BiomeMap.NULL); private static BlockStateAccess defaultBlockState = new BlockStateAccessSingle(DynmapBlockState.AIR); private static LightingAccess defaultLight = new LightingAccessSingle(0); diff --git a/bukkit-helper-118/src/main/java/org/dynmap/bukkit/helper/v118/BukkitVersionHelperSpigot118.java b/bukkit-helper-118/src/main/java/org/dynmap/bukkit/helper/v118/BukkitVersionHelperSpigot118.java index c5702aba..abfca50b 100644 --- a/bukkit-helper-118/src/main/java/org/dynmap/bukkit/helper/v118/BukkitVersionHelperSpigot118.java +++ b/bukkit-helper-118/src/main/java/org/dynmap/bukkit/helper/v118/BukkitVersionHelperSpigot118.java @@ -56,6 +56,7 @@ import java.util.IdentityHashMap; import java.util.Iterator; import java.util.List; import java.util.Map; +import java.util.Set; /** @@ -283,12 +284,7 @@ public class BukkitVersionHelperSpigot118 extends BukkitVersionHelper { @Override /** Get ID string from biomebase */ public String getBiomeBaseIDString(Object bb) { - String s = ((BiomeBase)bb).toString(); - if (s != null) { - String[] ss = s.split("\\."); - return ss[ss.length-1]; - } - return null; + return getBiomeReg().b((BiomeBase)bb).a(); } @Override public String getBiomeBaseResourceLocsation(Object bb) { diff --git a/bukkit-helper-118/src/main/java/org/dynmap/bukkit/helper/v118/MapChunkCache118.java b/bukkit-helper-118/src/main/java/org/dynmap/bukkit/helper/v118/MapChunkCache118.java index 9c9e0007..6dc7fbcc 100644 --- a/bukkit-helper-118/src/main/java/org/dynmap/bukkit/helper/v118/MapChunkCache118.java +++ b/bukkit-helper-118/src/main/java/org/dynmap/bukkit/helper/v118/MapChunkCache118.java @@ -35,6 +35,7 @@ import java.util.Arrays; import java.util.LinkedList; import java.util.List; import java.util.ArrayList; +import org.dynmap.Log; /** * Container for managing chunks - dependent upon using chunk snapshots, since rendering is off server thread @@ -56,7 +57,9 @@ public class MapChunkCache118 extends GenericMapChunkCache { if (nbt == null) return null; // Start generic chunk builder GenericChunk.Builder bld = new GenericChunk.Builder(dw.minY, dw.worldheight); - bld.coords(nbt.h("xPos"), nbt.h("zPos")); + int cx = nbt.h("xPos"); + int cz = nbt.h("zPos"); + bld.coords(cx, cz); if (nbt.e("InhabitedTime")) { bld.inhabitedTicks(nbt.i("InhabitedTime")); } @@ -213,7 +216,9 @@ public class MapChunkCache118 extends GenericMapChunkCache { bdata = new SimpleBitStorage(bdataPacked.length, 64, bdataPacked); for (int j = 0; j < 64; j++) { int b = bdata != null ? bdata.a(j) : 0; - sbld.xyzBiome(j & 0x3, (j & 0x30) >> 4, (j & 0xC) >> 2, BiomeMap.byBiomeResourceLocation(bpalette.j(b))); + String rl = bpalette.j(b); + BiomeMap bm = BiomeMap.byBiomeResourceLocation(rl); + sbld.xyzBiome(j & 0x3, (j & 0x30) >> 4, (j & 0xC) >> 2, bm); } } else { // Else, apply legacy biomes diff --git a/fabric-1.18/src/main/java/org/dynmap/fabric_1_18/DynmapPlugin.java b/fabric-1.18/src/main/java/org/dynmap/fabric_1_18/DynmapPlugin.java index dd7d49b6..f78e6d74 100644 --- a/fabric-1.18/src/main/java/org/dynmap/fabric_1_18/DynmapPlugin.java +++ b/fabric-1.18/src/main/java/org/dynmap/fabric_1_18/DynmapPlugin.java @@ -388,7 +388,7 @@ public class DynmapPlugin { else { bmap = BiomeMap.byBiomeID(i); } - if (bmap.isDefault()) { + if (bmap.isDefault() || (bmap == BiomeMap.NULL)) { bmap = new BiomeMap((rl != null) ? BiomeMap.NO_INDEX : i, id, tmp, hum, rl); Log.verboseinfo("Add custom biome [" + bmap.toString() + "] (" + i + ")"); cnt++; diff --git a/forge-1.18/src/main/java/org/dynmap/forge_1_18/DynmapPlugin.java b/forge-1.18/src/main/java/org/dynmap/forge_1_18/DynmapPlugin.java index 2b04b8b1..eef644fd 100644 --- a/forge-1.18/src/main/java/org/dynmap/forge_1_18/DynmapPlugin.java +++ b/forge-1.18/src/main/java/org/dynmap/forge_1_18/DynmapPlugin.java @@ -1403,7 +1403,7 @@ public class DynmapPlugin else { bmap = BiomeMap.byBiomeID(i); } - if (bmap.isDefault()) { // If matched default, replace with new one + if (bmap.isDefault() || (bmap == BiomeMap.NULL)) { bmap = new BiomeMap((rl != null) ? BiomeMap.NO_INDEX : i, id, tmp, hum, rl); Log.verboseinfo("Add custom biome [" + bmap.toString() + "] (" + i + ")"); cnt++; diff --git a/spigot/src/main/java/org/dynmap/bukkit/DynmapPlugin.java b/spigot/src/main/java/org/dynmap/bukkit/DynmapPlugin.java index f3ccf8e8..f580bf93 100644 --- a/spigot/src/main/java/org/dynmap/bukkit/DynmapPlugin.java +++ b/spigot/src/main/java/org/dynmap/bukkit/DynmapPlugin.java @@ -837,13 +837,14 @@ public class DynmapPlugin extends JavaPlugin implements DynmapAPI { else { bmap = BiomeMap.byBiomeID(i); } - if (bmap.isDefault()) { + if (bmap.isDefault() || (bmap == BiomeMap.NULL)) { String id = helper.getBiomeBaseIDString(bb); - if(id == null) { + if (id == null) { id = "BIOME_" + i; } bmap = new BiomeMap((rl != null) ? BiomeMap.NO_INDEX : i, id, tmp, hum, rl); Log.verboseinfo("Add custom biome [" + bmap.toString() + "] (" + i + ") rl=" + rl); + //Log.info(String.format("rl=%s, bmap=%s", rl, bmap)); cnt++; } else {