[1.16.1] Possible bug with the reflection used in ModCompatibility.copyModBiomeWeights() method
TelepathicGrunt opened this issue ยท 0 comments
I came across this reflection that BoP does into Forge's BiomeManager and I noticed that it makes an assumption that may cause strange behaviors later.
Specifically, it seems it calls BiomeManager.setupBiomes() to try and get all vanilla biomes in order to filter them out of BiomeManager.getBiomes(type) later. Except, Forge moved the desert biomes into BiomeLayer so the desert index in setupBiomes's returned lists is actually empty
The problematic line of code:
BiomesOPlenty/src/main/java/biomesoplenty/init/ModCompatibility.java
Lines 28 to 63 in f910136
Personally, I think this can be cleaned up and that the reflection is really not needed. What I would do instead to get all modded BiomeEntry is the following (warning, a bit pesudocode here):
for (BiomeManager.BiomeType type : BiomeManager.BiomeType.values()) {
// Removes vanilla entries by checking if the biome namespace is not "minecraft"
// If a mod makes their biome with minecraft namespace, they need a bug report as that's a big no-no.
List<BiomeManager.BiomeEntry> moddedBiomesInType = BiomeManager.getBiomes(type).stream()
.filter(biomeEntry -> !biomeEntry.biome.getRegistryName().getNamespace().equals("minecraft"))
.collect(Collectors.toList());
// calls remapBiomeToBoP on each modded biome and its weight.
moddedBiomesInType.stream().forEach(biomeEntry -> remapBiomeToBoP(biomeEntry.biome, type, biomeEntry.weight));
}
I ignored the WrappedBiomeEntry as it doesn't seem like it is needed at all since only the biome and the weight is used. To check if a biome is modded, just the namespace needs to be checked. Any mod that tried to add a modded biome with the 'minecraft' namespace needs to get an issue report saying to change that. But really, I have not found anyone doing that in a loooong time so I do not believe this practice is widespread enough to really warrant going out of our way to support them.
If you are trying to support mods adding additional vanilla biome entries with different weights, then that does get more tricky as then, you have to get the desert biome entries too. Personally, if you are looking to do this, then it would probably be easier and safer to just define your own list of all vanilla biome entries with the vanilla weight and do something like a if( !hardcodedVanillaBiomeEntryList.contains(biomeManagerBiomeEntry) ) remapBiomeToBoP(biomeManagerBiomeEntry.biome, type, biomeManagerBiomeEntry.weight);
which would not need any reflection and you know the vanilla biome entries are untouched.
I hope this helps!