Fix handling of new, additional buiomes

This commit is contained in:
Mike Primm 2021-12-05 05:01:59 -06:00
parent 37fd064434
commit f56f4378c5
8 changed files with 40 additions and 20 deletions

View file

@ -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);
}
}

View file

@ -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);

View file

@ -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);