ReplaceToBiomeName broken on Minecraft 1.9
rutgerkok opened this issue ยท 1 comments
Instead of changing the biome into the requested biome, the biome is changed in what seems to be the output of the vanilla biome generator.
Techical details
Previously, the BiomeBase class had a field called 'id'. For custom biomes with ReplaceToBiomeName set (the so-called virtual biomes), we set this 'id' field to the id of the biome to replace to. This caused the biome to be saved (and sent to the client) as the biome specified in ReplaceToBiomeName.
This clever hack, which makes biomes with ids higher than 255 possible, no longer works in Minecraft 1.9. The id field is gone from BiomeBase. Instead, the biome id is fetched from a biome registry. As virtual biomes are not added to the registry, the registry returns -1 as the biome id for those biomes. This causes Minecraft to regenerate the biome, this time using some non-TC generator.
In other words, we need a new hack.
If the registry used a Map<BiomeBase, Integer>
, we could just add our virtual BiomeBase there. Instead, the getId method (called BiomeBase.a(BiomeBase)
, a static method) seems to do a linear search through the registry. I don't know the details of this yet (there seem to be two BiomeBase[] arrays in the registry).
If addition to the existing registry turns out to be be impossible, we need to write a biome registry ourselves, and inject it the BiomeBase class. This is not possible on Forge, as we could break other mods when doing this.
If anyone has another idea, please post it here.
Fixed in bce4c34
The registry with all the arrays (called RegistryID in Spigot) turned out to be a IntIdentityHashBiMap(MCP name). Registering the virtual biome, then re-registering the original biome did the trick.