Client-server fog fix

This commit is contained in:
paulevsGitch 2020-10-01 23:48:25 +03:00
parent 504d7e49e0
commit 893b1085b9
7 changed files with 27 additions and 8 deletions

View file

@ -20,6 +20,7 @@ import ru.betterend.world.generator.BiomeType;
public class BiomeRegistry {
private static final Map<EndBiome, RegistryKey<Biome>> KEYS = Maps.newHashMap();
private static final HashMap<Biome, EndBiome> MUTABLE = Maps.newHashMap();
private static final HashMap<Biome, EndBiome> CLIENT = Maps.newHashMap();
public static final BiomePicker LAND_BIOMES = new BiomePicker();
public static final BiomePicker VOID_BIOMES = new BiomePicker();
@ -69,6 +70,7 @@ public class BiomeRegistry {
public static EndBiome registerBiome(EndBiome biome, BiomeType type) {
registerBiomeDirect(biome);
addToPicker(biome, type);
CLIENT.put(biome.getBiome(), biome);
return biome;
}
@ -94,7 +96,31 @@ public class BiomeRegistry {
return KEYS.get(biome);
}
private static boolean equals(Biome biome1, Biome biome2) {
return (biome1.getDepth() - biome2.getDepth() == 0) &&
(biome1.getDownfall() - biome2.getDownfall() == 0) &&
(biome1.getScale() - biome2.getScale() == 0) &&
(biome1.getCategory() == biome2.getCategory()) &&
(biome1.getFogColor() == biome2.getFogColor()) &&
(biome1.getSkyColor() == biome2.getSkyColor()) &&
(biome1.getWaterColor() == biome2.getWaterColor()) &&
(biome1.getWaterFogColor() == biome2.getWaterFogColor()) &&
(biome1.getPrecipitation().equals(biome2.getPrecipitation()));
}
public static EndBiome getFromBiome(Biome biome) {
return MUTABLE.getOrDefault(biome, END);
EndBiome endBiome = MUTABLE.get(biome);
if (endBiome == null) {
for (Biome key: CLIENT.keySet()) {
if (equals(key, biome)) {
endBiome = CLIENT.get(key);
MUTABLE.put(biome, endBiome);
return endBiome;
}
}
MUTABLE.put(biome, END);
return END;
}
return endBiome;
}
}