This was an excellent answer. Thank you.
I actually have a BiomeSource and ChunkGenerator. My mod is supposed to clone the overworld to another dimension. With vanilla, by listening for all available biomes at the start, I just get them, use BiomeBuilder to replace some of their settings, and register them as mine. During run time for world gen, I relay chunk generation to my cloned version of the vanilla ChunkGenerator which leads to an exact replica of the overworld, with a little bit of spooky environment added in.
The problem here of course is datapack biomes aren't registered the same way. Ideally, my mod would always clone your (the users) overworld. For my personal purposes, copy-pasting terralith is fine but... it leaves something to be desired from the mod itself.
Is there anyway I can get the datapack biomes on world creation and perform my cloning operation on them and then save them in the world as you mentioned?
Additionally, here is my working code:
@Override
public Holder<Biome> getNoiseBiome(int x, int y, int z, Climate.Sampler sampler) {
var overworld = TUDChunkGenerator.GET_OVERWORLD_CHUNK_GEN().getBiomeSource().getNoiseBiome(x, y, z, sampler);
var tud = Registration.TUD_BIOME_KEYS.get(overworld.value().getRegistryName().getPath());
if(tud != null)
return getBiomeRegistry().getHolderOrThrow(tud);
else
return overworld;
}
While this works, as you can see, if it found a cloned biome, it uses the clone. If it did not (either because another mod loaded after it, or a datapack adds in data), it simply relays the overworld ChunkGenerator. This is not ideal and does not clone as well as it does when I have the biomes registered before hand.
I am open to alternative solutions, if needed.