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?
I was able to do that slightly differently, but that's not quite what I need. This will replace the biomes I don't want. But that will result in a plains biome the size of a deep ocean
Code (Text): biomesField = BiomeBase.class.getDeclaredField("biomes"); biomesField.setAccessible(true); 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
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
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.
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.
@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?
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"); biomesField.setAccessible(true); 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.id] = BiomeBase.SWAMPLAND; } } catch (Exception e) { e.printStackTrace(); } for only swamp, and the rest you can probably find out