mirror of
https://github.com/webbukkit/dynmap.git
synced 2024-11-27 12:45:59 +01:00
Fix handling of new, additional buiomes
This commit is contained in:
parent
37fd064434
commit
f56f4378c5
@ -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) {
|
||||
idx++;
|
||||
resizeIfNeeded(idx);
|
||||
if (biome_by_index[idx].isDef) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
@ -64,6 +64,9 @@ 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);
|
||||
|
@ -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);
|
||||
|
@ -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) {
|
||||
|
@ -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
|
||||
|
@ -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++;
|
||||
|
@ -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++;
|
||||
|
@ -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 {
|
||||
|
Loading…
Reference in New Issue
Block a user