Solved Remove biomes from the biome generator

Discussion in 'Spigot Plugin Development' started by NubeBuster, May 23, 2016.

  1. I am making a custom world generator so I don't have to use Terrain Control. I don't want to use Terrain Control because it is very resource heavy. The main reason why I don't want to use the vanilla generator is because I wan't to get rid of oceans. I have pretty much everything in my chunkgenerator working, except for one thing: I wan't to completely get rid of ocean biomes. I would prefer to remove them from the biome generation so I don't have to replace them after they have been spawned. How do I do this?
  2. MiniDigger


    just copy that array without the ocean biomes and set it back.
  3. @ProJoosh @MiniDigger I am sorry, I didn't properly look at the code. Thanks for helping me out!
  4. Code (Text):
                biomesField = BiomeBase.class.getDeclaredField("biomes");

                if (biomesField.get(null) instanceof BiomeBase[]) {
                    BiomeBase[] custom_biomes = new BiomeBase[] { BiomeBase.SWAMPLAND };

                    biomesField.set(null, custom_biomes);
    With this code I still get other biomes than SWAMPLAND. U put this in my onLoad method and have set load: STARTUP in my plugin.yml
  5. MiniDigger


    mhh, you did delete your current world, right?
    I have no idea how bukkit generates world. You should take a look at bukkits worldgenerator to see how its handles the biomes (and if it acesses the BiomeBases)
    On a side node: Your current code will not wirk in 1.9 because they moved the fields to a class named Biomes
  6. I did remove the world, and I don't care about 1.9. I have also taken some peeks in the code. However there is a lot of code and many parts I don't understand.
  7. MiniDigger


    I digged a bit around. Bukkit just wrappes the internal chunk generator.
    So if you want to remove a biome, you need to remove it from the nms classes.
    Try removing the biome from the biome registry (public static final RegistryMaterials<MinecraftKey, BiomeBase> REGISTRY_ID;) in nms BiomeBase.
    if that leads to IllegalStateException("Invalid Biome requested: " + s); you can't remove a biome. then you just can replace it. After replacing you need update the constant that contains the ocean biome in nms.Biomes too.
  8. I understand what you are saying, but I have no clue how to do this stuff
  9. @MiniDigger I got a clue. The reason why the previous code doesn't work is because I am not allowed to set the biome[] because it's final. Can I bypass that?
  10. MiniDigger


    setAceesible should handle that. if you don't get a exception it worked.
  11. I finally got it working. I had to follow a number of conditions:
    - The biomes need to be in the right place in the array (their id as index)
    - I need to edit the array which I get in the first place (kindof makes sense knowing java)
    and some other things I forget to mention

    but here's the working code for future coders:

    Code (Text):
            Field biomesField;
            try {
                biomesField = BiomeBase.class.getDeclaredField("biomes");

                if (biomesField.get(null) instanceof BiomeBase[]) {
                    BiomeBase[] biomes = (BiomeBase[]) biomesField.get(null);
                    for (int i = 0; i < biomes.length; i++) {
                        biomes[i] = null;
                    biomes[] = BiomeBase.SWAMPLAND;
            } catch (Exception e) {
    for only swamp, and the rest you can probably find out