Handle the server sending invalid biome IDs in chunks

Should hopefully address #2400 - the Java client handles invalid biome IDs and simply complains in its logs.
This commit is contained in:
Camotoy 2021-07-31 16:34:24 -04:00
parent a197f60446
commit 3d50155ee3
No known key found for this signature in database
GPG key ID: 7EEFB66FE798081F

View file

@ -92,9 +92,12 @@ public class BiomeTranslator {
bedrockId = Registries.BIOME_IDENTIFIERS.get().getInt(replacementBiome); bedrockId = Registries.BIOME_IDENTIFIERS.get().getInt(replacementBiome);
} }
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);
if (javaId == 0) {
// Matches Java behavior when it sees an invalid biome - it just replaces it with ID 0
biomeTranslations.defaultReturnValue(bedrockId);
} }
} }
} }
@ -132,8 +135,8 @@ public class BiomeTranslator {
int x = i & 3; int x = i & 3;
int y = (i >> 4) & 3; int y = (i >> 4) & 3;
int z = (i >> 2) & 3; int z = (i >> 2) & 3;
// Get the Bedrock biome ID override, or this ID if it's the same // Get the Bedrock biome ID override
int biomeId = biomeTranslations.getOrDefault(javaId, javaId); int biomeId = biomeTranslations.get(javaId);
int idx = storage.idFor(biomeId); int idx = storage.idFor(biomeId);
// Convert biome coordinates into block coordinates // Convert biome coordinates into block coordinates
// Bedrock expects a full 4096 blocks // Bedrock expects a full 4096 blocks