use of potionstudios.byg.mixin.access.NoiseGeneratorSettingsAccess in project BYG by AOCAWOL.
the class AddSurfaceRulesUtil method appendSurfaceRule.
public static void appendSurfaceRule(WorldData worldData, ResourceKey<LevelStem> levelStemKey, SurfaceRules.RuleSource ruleSource) {
if (worldData == null) {
// For some reason mods can make world data null as seen in some user crash logs, this makes that issue clearer for us.
throw new NullPointerException("Minecraft server's world data is null, this should be impossible...");
}
LevelStem levelStem = worldData.worldGenSettings().dimensions().get(levelStemKey);
if (OverworldBiomeConfig.getConfig(false).generateOverworld()) {
ChunkGenerator chunkGenerator = levelStem.generator();
if (chunkGenerator != null && chunkGenerator instanceof NoiseBasedChunkGenerator) {
Object noiseGeneratorSettings = ((NoiseBasedChunkGeneratorAccess) chunkGenerator).byg_getSettings().value();
((NoiseGeneratorSettingsAccess) noiseGeneratorSettings).byg_setSurfaceRule(SurfaceRules.sequence(ruleSource, ((NoiseGeneratorSettings) noiseGeneratorSettings).surfaceRule()));
}
}
}
Aggregations