Add best-fit replacement biomes for custom biomes

This commit is contained in:
Camotoy 2021-07-27 22:52:07 -04:00
parent 8c96c3b11d
commit a5beebdffa
No known key found for this signature in database
GPG Key ID: 7EEFB66FE798081F
1 changed files with 38 additions and 1 deletions

View File

@ -50,9 +50,46 @@ public class BiomeTranslator {
CompoundTag biomeTag = (CompoundTag) tag;
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();
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) {
// When we see the Java ID, we should instead apply the Bedrock ID
biomeTranslations.put(javaId, bedrockId);