mirror of
https://github.com/GeyserMC/Geyser.git
synced 2024-08-14 23:57:35 +00:00
Add best-fit replacement biomes for custom biomes
This commit is contained in:
parent
8c96c3b11d
commit
a5beebdffa
1 changed files with 38 additions and 1 deletions
|
@ -50,9 +50,46 @@ public class BiomeTranslator {
|
||||||
CompoundTag biomeTag = (CompoundTag) tag;
|
CompoundTag biomeTag = (CompoundTag) tag;
|
||||||
|
|
||||||
String javaIdentifier = ((StringTag) biomeTag.get("name")).getValue();
|
String javaIdentifier = ((StringTag) biomeTag.get("name")).getValue();
|
||||||
int bedrockId = Registries.BIOME_IDENTIFIERS.get().getOrDefault(javaIdentifier, 0);
|
int bedrockId = Registries.BIOME_IDENTIFIERS.get().getOrDefault(javaIdentifier, -1);
|
||||||
int javaId = ((IntTag) biomeTag.get("id")).getValue();
|
int javaId = ((IntTag) biomeTag.get("id")).getValue();
|
||||||
|
|
||||||
|
if (bedrockId == -1) {
|
||||||
|
// There is no matching Bedrock variation for this biome; let's set the closest match based on biome category
|
||||||
|
String category = ((StringTag) ((CompoundTag) biomeTag.get("element")).get("category")).getValue();
|
||||||
|
String replacementBiome;
|
||||||
|
switch (category) {
|
||||||
|
case "extreme_hills":
|
||||||
|
replacementBiome = "minecraft:mountains";
|
||||||
|
break;
|
||||||
|
case "icy":
|
||||||
|
replacementBiome = "minecraft:ice_spikes";
|
||||||
|
break;
|
||||||
|
case "mushroom":
|
||||||
|
replacementBiome = "minecraft:mushroom_fields";
|
||||||
|
break;
|
||||||
|
case "nether":
|
||||||
|
replacementBiome = "minecraft:nether_wastes";
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
replacementBiome = "minecraft:ocean"; // Typically ID 0 so a good default
|
||||||
|
break;
|
||||||
|
case "taiga":
|
||||||
|
case "jungle":
|
||||||
|
case "mesa":
|
||||||
|
case "plains":
|
||||||
|
case "savanna":
|
||||||
|
case "the_end":
|
||||||
|
case "beach":
|
||||||
|
case "ocean":
|
||||||
|
case "desert":
|
||||||
|
case "river":
|
||||||
|
case "swamp":
|
||||||
|
replacementBiome = "minecraft:" + category;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
bedrockId = Registries.BIOME_IDENTIFIERS.get().getInt(replacementBiome);
|
||||||
|
}
|
||||||
|
|
||||||
if (javaId != bedrockId) {
|
if (javaId != bedrockId) {
|
||||||
// When we see the Java ID, we should instead apply the Bedrock ID
|
// When we see the Java ID, we should instead apply the Bedrock ID
|
||||||
biomeTranslations.put(javaId, bedrockId);
|
biomeTranslations.put(javaId, bedrockId);
|
||||||
|
|
Loading…
Reference in a new issue