mirror of
https://github.com/webbukkit/dynmap.git
synced 2024-12-24 17:47:40 +01:00
Biome shading fixes for 1.18 (Spigot, Fabric, Forge)
This commit is contained in:
parent
ebdab5e706
commit
76557bf312
@ -3,13 +3,14 @@ package org.dynmap.common;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.dynmap.Log;
|
||||
import org.dynmap.hdmap.HDBlockModels;
|
||||
|
||||
/* Generic biome mapping */
|
||||
public class BiomeMap {
|
||||
private static BiomeMap[] biome_by_index = new BiomeMap[1025];
|
||||
private static Map<String, BiomeMap> biome_by_name = new HashMap<>();
|
||||
public static final BiomeMap NULL = new BiomeMap(-1, "NULL", 0.5, 0.5, 0xFFFFFF, 0, 0);
|
||||
private static Map<String, BiomeMap> biome_by_rl = new HashMap<String, BiomeMap>();
|
||||
public static final BiomeMap NULL = new BiomeMap(-1, "NULL", 0.5, 0.5, 0xFFFFFF, 0, 0, null);
|
||||
|
||||
public static final BiomeMap OCEAN = new BiomeMap(0, "OCEAN");
|
||||
public static final BiomeMap PLAINS = new BiomeMap(1, "PLAINS", 0.8, 0.4);
|
||||
@ -17,7 +18,7 @@ public class BiomeMap {
|
||||
public static final BiomeMap EXTREME_HILLS = new BiomeMap(3, "EXTREME_HILLS", 0.2, 0.3);
|
||||
public static final BiomeMap FOREST = new BiomeMap(4, "FOREST", 0.7, 0.8);
|
||||
public static final BiomeMap TAIGA = new BiomeMap(5, "TAIGA", 0.05, 0.8);
|
||||
public static final BiomeMap SWAMPLAND = new BiomeMap(6, "SWAMPLAND", 0.8, 0.9, 0xE0FFAE, 0x4E0E4E, 0x4E0E4E);
|
||||
public static final BiomeMap SWAMPLAND = new BiomeMap(6, "SWAMPLAND", 0.8, 0.9, 0xE0FFAE, 0x4E0E4E, 0x4E0E4E, null);
|
||||
public static final BiomeMap RIVER = new BiomeMap(7, "RIVER");
|
||||
public static final BiomeMap HELL = new BiomeMap(8, "HELL", 2.0, 0.0);
|
||||
public static final BiomeMap SKY = new BiomeMap(9, "SKY");
|
||||
@ -43,6 +44,7 @@ public class BiomeMap {
|
||||
private int grassmult;
|
||||
private int foliagemult;
|
||||
private final String id;
|
||||
private final String resourcelocation;
|
||||
private final int index;
|
||||
private int biomeindex256; // Standard biome mapping index (for 256 x 256)
|
||||
private boolean isDef;
|
||||
@ -51,6 +53,11 @@ public class BiomeMap {
|
||||
|
||||
public static void loadWellKnownByVersion(String mcver) {
|
||||
if (loadDone) return;
|
||||
// Don't do this for 1.18 and on
|
||||
if (HDBlockModels.checkVersionRange(mcver, "1.18.0-")) {
|
||||
loadDone = true;
|
||||
return;
|
||||
}
|
||||
if (HDBlockModels.checkVersionRange(mcver, "1.7.0-")) {
|
||||
new BiomeMap(23, "JUNGLE_EDGE", 0.95, 0.8);
|
||||
new BiomeMap(24, "DEEP_OCEAN");
|
||||
@ -74,7 +81,7 @@ public class BiomeMap {
|
||||
new BiomeMap(131, "EXTREME_HILLS_MOUNTAINS", 0.2, 0.3);
|
||||
new BiomeMap(132, "FLOWER_FOREST", 0.7, 0.8);
|
||||
new BiomeMap(133, "TAIGA_MOUNTAINS", 0.05, 0.8);
|
||||
new BiomeMap(134, "SWAMPLAND_MOUNTAINS", 0.8, 0.9, 0xE0FFAE, 0x4E0E4E, 0x4E0E4E);
|
||||
new BiomeMap(134, "SWAMPLAND_MOUNTAINS", 0.8, 0.9, 0xE0FFAE, 0x4E0E4E, 0x4E0E4E, null);
|
||||
new BiomeMap(140, "ICE_PLAINS_SPIKES", 0.0, 0.5);
|
||||
new BiomeMap(149, "JUNGLE_MOUNTAINS", 1.2, 0.9);
|
||||
new BiomeMap(151, "JUNGLE_EDGE_MOUNTAINS", 0.95, 0.8);
|
||||
@ -138,7 +145,7 @@ public class BiomeMap {
|
||||
}
|
||||
return true;
|
||||
}
|
||||
private BiomeMap(int idx, String id, double tmp, double rain, int waterColorMultiplier, int grassmult, int foliagemult) {
|
||||
private BiomeMap(int idx, String id, double tmp, double rain, int waterColorMultiplier, int grassmult, int foliagemult, String rl) {
|
||||
/* Clamp values : we use raw values from MC code, which are clamped during color mapping only */
|
||||
setTemperature(tmp);
|
||||
setRainfall(rain);
|
||||
@ -157,14 +164,21 @@ public class BiomeMap {
|
||||
if(idx >= 0) {
|
||||
biome_by_index[idx] = this;
|
||||
}
|
||||
biome_by_name.put(id, this);
|
||||
this.resourcelocation = rl;
|
||||
if (rl != null) {
|
||||
biome_by_rl.put(rl, this);
|
||||
}
|
||||
}
|
||||
public BiomeMap(int idx, String id) {
|
||||
this(idx, id, 0.5, 0.5, 0xFFFFFF, 0, 0);
|
||||
this(idx, id, 0.5, 0.5, 0xFFFFFF, 0, 0, null);
|
||||
}
|
||||
|
||||
public BiomeMap(int idx, String id, double tmp, double rain) {
|
||||
this(idx, id, tmp, rain, 0xFFFFFF, 0, 0);
|
||||
this(idx, id, tmp, rain, 0xFFFFFF, 0, 0, null);
|
||||
}
|
||||
|
||||
public BiomeMap(int idx, String id, double tmp, double rain, String rl) {
|
||||
this(idx, id, tmp, rain, 0xFFFFFF, 0, 0, rl);
|
||||
}
|
||||
|
||||
private final int biomeLookup(int width) {
|
||||
@ -208,14 +222,9 @@ public class BiomeMap {
|
||||
else
|
||||
return NULL;
|
||||
}
|
||||
public static final BiomeMap byBiomeName(String name) {
|
||||
if (name.startsWith("minecraft:")) {
|
||||
name = name.substring(10);
|
||||
}
|
||||
name = name.toUpperCase();
|
||||
if (biome_by_name.containsKey(name))
|
||||
return biome_by_name.get(name);
|
||||
return NULL;
|
||||
public static final BiomeMap byBiomeResourceLocation(String resloc) {
|
||||
BiomeMap b = biome_by_rl.get(resloc);
|
||||
return (b != null) ? b : NULL;
|
||||
}
|
||||
public int getBiomeID() {
|
||||
return index - 1; // Index of biome in MC biome table
|
||||
|
@ -92,9 +92,9 @@ public class BukkitVersionHelperSpigot118 extends BukkitVersionHelper {
|
||||
return names.toArray(new String[0]);
|
||||
}
|
||||
|
||||
private static Registry<BiomeBase> reg = null;
|
||||
private static IRegistry<BiomeBase> reg = null;
|
||||
|
||||
private static Registry<BiomeBase> getBiomeReg() {
|
||||
private static IRegistry<BiomeBase> getBiomeReg() {
|
||||
if (reg == null) {
|
||||
reg = MinecraftServer.getServer().aV().d(IRegistry.aR);
|
||||
}
|
||||
@ -288,6 +288,10 @@ public class BukkitVersionHelperSpigot118 extends BukkitVersionHelper {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@Override
|
||||
public String getBiomeBaseResourceLocsation(Object bb) {
|
||||
return getBiomeReg().b((BiomeBase)bb).toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getUnloadQueue(World world) {
|
||||
|
@ -325,7 +325,7 @@ public class MapChunkCache118 extends AbstractMapChunkCache {
|
||||
bdata = new SimpleBitStorage(bdataPacked.length, 64, bdataPacked);
|
||||
for (int j = 0; j < 64; j++) {
|
||||
int b = bdata != null ? bdata.a(j) : 0;
|
||||
cursect.biomes[j] = b < bpalette.size() ? BiomeMap.byBiomeName(bpalette.j(b)).getBiomeID() : -1;
|
||||
cursect.biomes[j] = b < bpalette.size() ? BiomeMap.byBiomeResourceLocation(bpalette.j(b)).getBiomeID() : -1;
|
||||
}
|
||||
// Favor the Y=64 version
|
||||
if ((secnum == 4) || (lastsectwithbiome == null)) {
|
||||
|
@ -48,6 +48,10 @@ public abstract class BukkitVersionHelper {
|
||||
* Get ID string from biomebase
|
||||
*/
|
||||
public abstract String getBiomeBaseIDString(Object bb);
|
||||
/**
|
||||
* Get resource location from biomebase (1.18+)
|
||||
*/
|
||||
public String getBiomeBaseResourceLocsation(Object bb) { return null; }
|
||||
/**
|
||||
* Get ID from biomebase
|
||||
*/
|
||||
|
@ -285,7 +285,7 @@ public class ChunkSnapshot {
|
||||
bdata = new PackedIntegerArray(bdataPacked.length, 64, bdataPacked);
|
||||
for (int j = 0; j < 64; j++) {
|
||||
int b = bdata != null ? bdata.get(j) : 0;
|
||||
biomes[j] = b < bpalette.size() ? BiomeMap.byBiomeName(bpalette.getString(b)).getBiomeID() : -1;
|
||||
biomes[j] = b < bpalette.size() ? BiomeMap.byBiomeResourceLocation(bpalette.getString(b)).getBiomeID() : -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -376,13 +376,14 @@ public class DynmapPlugin {
|
||||
Biome bb = list[i];
|
||||
if (bb != null) {
|
||||
String id = biomeRegistry.getId(bb).getPath();
|
||||
String rl = biomeRegistry.getId(bb).toString();
|
||||
float tmp = bb.getTemperature(), hum = bb.getDownfall();
|
||||
int watermult = ((BiomeEffectsAccessor) bb.getEffects()).getWaterColor();
|
||||
Log.verboseinfo("biome[" + i + "]: hum=" + hum + ", tmp=" + tmp + ", mult=" + Integer.toHexString(watermult));
|
||||
|
||||
BiomeMap bmap = BiomeMap.byBiomeID(i);
|
||||
if (bmap.isDefault()) {
|
||||
bmap = new BiomeMap(i, id, tmp, hum);
|
||||
if ((rl != null) || bmap.isDefault()) {
|
||||
bmap = new BiomeMap(i, id, tmp, hum, rl);
|
||||
Log.verboseinfo("Add custom biome [" + bmap.toString() + "] (" + i + ")");
|
||||
cnt++;
|
||||
} else {
|
||||
|
@ -298,7 +298,7 @@ public class ChunkSnapshot
|
||||
bdata = new SimpleBitStorage(bdataPacked.length, 64, bdataPacked);
|
||||
for (int j = 0; j < 64; j++) {
|
||||
int b = bdata != null ? bdata.get(j) : 0;
|
||||
cursect.biomes[j] = b < bpalette.size() ? BiomeMap.byBiomeName(bpalette.getString(b)).getBiomeID() : -1;
|
||||
cursect.biomes[j] = b < bpalette.size() ? BiomeMap.byBiomeResourceLocation(bpalette.getString(b)).getBiomeID() : -1;
|
||||
}
|
||||
// Favor the Y=64 version
|
||||
if ((secnum == 4) || (lastsectwithbiome == null)) {
|
||||
|
@ -1394,14 +1394,15 @@ public class DynmapPlugin
|
||||
for (int i = 0; i < list.length; i++) {
|
||||
Biome bb = list[i];
|
||||
if (bb != null) {
|
||||
String id = bb.toString();
|
||||
String id = bb.getRegistryName().getPath();
|
||||
String rl = bb.getRegistryName().toString();
|
||||
float tmp = bb.getBaseTemperature(), hum = bb.getDownfall();
|
||||
int watermult = bb.getWaterColor();
|
||||
Log.verboseinfo("biome[" + i + "]: hum=" + hum + ", tmp=" + tmp + ", mult=" + Integer.toHexString(watermult));
|
||||
|
||||
BiomeMap bmap = BiomeMap.byBiomeID(i);
|
||||
if (bmap.isDefault()) {
|
||||
bmap = new BiomeMap(i, id, tmp, hum);
|
||||
if ((rl != null) || bmap.isDefault()) {
|
||||
bmap = new BiomeMap(i, id, tmp, hum, rl);
|
||||
Log.verboseinfo("Add custom biome [" + bmap.toString() + "] (" + i + ")");
|
||||
cnt++;
|
||||
}
|
||||
|
@ -818,19 +818,20 @@ public class DynmapPlugin extends JavaPlugin implements DynmapAPI {
|
||||
for(int i = 0; i < biomelist.length; i++) {
|
||||
Object bb = biomelist[i];
|
||||
if(bb != null) {
|
||||
String rl = helper.getBiomeBaseResourceLocsation(bb);
|
||||
float tmp = helper.getBiomeBaseTemperature(bb);
|
||||
float hum = helper.getBiomeBaseHumidity(bb);
|
||||
int watermult = helper.getBiomeBaseWaterMult(bb);
|
||||
//Log.info("biome[" + i + "]: hum=" + hum + ", tmp=" + tmp + ", mult=" + Integer.toHexString(watermult));
|
||||
Log.verboseinfo("biome[" + i + "]: hum=" + hum + ", tmp=" + tmp + ", mult=" + Integer.toHexString(watermult));
|
||||
|
||||
BiomeMap bmap = BiomeMap.byBiomeID(i);
|
||||
if (bmap.isDefault()) {
|
||||
if ((rl != null) || bmap.isDefault()) {
|
||||
String id = helper.getBiomeBaseIDString(bb);
|
||||
if(id == null) {
|
||||
id = "BIOME_" + i;
|
||||
}
|
||||
bmap = new BiomeMap(i, id, tmp, hum);
|
||||
//Log.info("Add custom biome [" + bmap.toString() + "] (" + i + ")");
|
||||
bmap = new BiomeMap(i, id, tmp, hum, rl);
|
||||
Log.verboseinfo("Add custom biome [" + bmap.toString() + "] (" + i + ") rl=" + rl);
|
||||
cnt++;
|
||||
}
|
||||
else {
|
||||
@ -839,7 +840,7 @@ public class DynmapPlugin extends JavaPlugin implements DynmapAPI {
|
||||
}
|
||||
if (watermult != -1) {
|
||||
bmap.setWaterColorMultiplier(watermult);
|
||||
//Log.info("Set watercolormult for " + bmap.toString() + " (" + i + ") to " + Integer.toHexString(watermult));
|
||||
Log.verboseinfo("Set watercolormult for " + bmap.toString() + " (" + i + ") to " + Integer.toHexString(watermult));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user