1.9.4 /1.10 Forge version
BakermanLP opened this issue ยท 15 comments
Is it possible to make this compatible to Minecraft 1.9.4 / 1.10 and Forge?
I tried that on my own, but don't get this beast to compile.
There is a working version out in the jenkins:
http://build.mctcp.com/job/TerrainControl%20-%20Master%20-%20Gradle/default/
There are some minor bugs / problems. Just try it out with the limitation of max 256 biomes.
I think, that the current version in the jenkins is beta stable. That issue can be closed.
It should at least compile on 1.9. If you haven't seen this file, please take a look. If you're still stuck, I can try to help you, just post what you have already
The problem is with biome registration. Currently, the server sends a packet with biome names/ids/colors whenever the user joins a server or switches to another world. This means that biomes can be registered and unregistered during gameplay, and I haven't found a way to do this in Forge. Back in Minecraft 1.8, there was just a simple BiomeGenBase[] array that we could manipulate.
I am sorry, but I can't program java. But I found here a code snipet, that seems to fit:
https://bitbucket.org/XendricInteractive/ersatz-materials/src/d1bc5f25f0b2582c80114a6c41aa2fd09a7cd981/main/java/com/xendric/registers/BiomeRegistry.java?at=master&fileviewer=file-view-default
@rutgerkok It's the same location as it would be in Vanilla, 'Biome.REGISTRY'. Forge just redirects it to its GameData.
public static final RegistryNamespaced<ResourceLocation, Biome> REGISTRY = net.minecraftforge.fml.common.registry.GameData.getBiomeRegistry();
Forge also maintains a BiomeDictionary which registers biome "types" to Biomes. So if you want to register/unregister biomes then you need to first make sure it is part of the registry then make sure you assign the proper types in Forge's BiomeDictionary.
If we could get an update to Forge 1.10.2 that would help us because many users are updating SpongeForge now.
@bloodmc Thank you. If you're interested, I have written down all the problems that I have encountered below.
Back when
BiomeGenBase[].biomes
was the registry, TC did all the work of registering the biomes. When a world was loaded, it looked up what custom biomes it needed to load and registered the biome ids (which are stored in TC's config files). It worked this way on Spigot and Forge.Nowadays, Forge has a complicated biome registry. Forge automatically assigns biome ids. When you register something, the id is saved in the level.dat of that world. Spigot still requires us to keep track manually of all biome ids. So now we have two incompatible systems, but this can probably be worked around. But it is not the only problem.
The second problem is that we have the so-called virtual biomes. As there are only 256 possible biome ids in total, it is easy to have too many biomes in a world. Virtual biomes solve this problem: it uses a biome that is not registered during terrain generation. This sounds crazy, but it works. In this way, there can be as many BiomeGenBase instances as we like. In Minecraft 1.8, the unregistered biome had overridden
BiomeGenBase.getBiomeId()
to return the id of another biome that (unlike the virtual biome) was registered. In this way, Minecraft could still save the biome under the id of a similar biome.
BiomeGenBase.getBiomeId()
doesn't exist anymore, but using a hack it was possible to get virtual biomes working again on Spigot. On Forge, this hack doesn't work.A third problem is that a Forge client should be able to join a Spigot server, and see all the custom biomes with the correct colors and weather. In Minecraft 1.8, the server sent a packet with all required information, and the client registered all the biomes. I know that Forge has a system for registry synchronization, but as far as I know the client already needs to know about the biome names in advance.
I don't know enough about Forge to easily find workarounds. I have updated the code to compile against Forge 1.10.2, but because of the above issues it is barely functional; for example, it crashes when you open a singleplayer world for the second time.
@rutgerkok OK thanks. I will take a look when I can or have someone take a look for you. We can keep this ticket open until your concerns are resolved.
It basically boils down to that my hacks don't work anymore with all the checks in Forge's registry. I'm sure that there are other, better ways to work with unregistered biomes and with Spigot servers that send configs.
I have started the work on getting the biome id management out the common parts of TerrainControl, so that Forge can handle that part.
Would you happen to know if there is a way to execute code for a world before Forge loads the level.dat? Now Forge complains about missing biomes, which is because the TerrainControl config loader hasn't been called yet.
@rutgerkok
You would have to run code during
This is called before FML loads level.dat from the main world.
What code do you want to execute exactly?
@bloodmc Thanks! I just want to load the config files of the world, so that the biomes can be registered before Forge encouters "missing biomes" in the level.dat file.
@rutgerkok ok so do it during FMLServerAboutToStartEvent. Keep in mind that the worlds wont be loaded at this point but you should be able to register the biomes fine.
Update: Actually you may want to do registration earlier during PreInit. But yea, anything on or before FMLServerAboutToStartEvent should work.
You basically need to register "placeholders" for your virtual biomes. In earlier Minecraft versions, you manipulated the array to make it past the 256 limit but now its made more concrete that you can't do that.
One of your placeholders maps to many biomes internally in TC so it should be a simple matter of switching your process of doing virtual biomes TO such a system. Keep in mind I've no idea how TC works internally so it may end up being a rather large issue of internal plumbing for it to work.