NucleoidMC / fantasy

Library to support creating dimensions at runtime
GNU Lesser General Public License v3.0
96 stars 28 forks source link

A utility for specifying chunk generator settings for custom noise chunk generators should be added #24

Closed haykam821 closed 10 months ago

haykam821 commented 1 year ago

Currently, the ThreadedAnvilChunkGenerator class in vanilla initializes the noise configuration by obtaining settings from a NoiseChunkGenerator instance:

if (chunkGenerator instanceof NoiseChunkGenerator noiseChunkGenerator) {
    this.noiseConfig = NoiseConfig.create(noiseChunkGenerator.getSettings().value(), registryManager.getWrapperOrThrow(RegistryKeys.NOISE_PARAMETERS), seed);
} else {
    this.noiseConfig = NoiseConfig.create(ChunkGeneratorSettings.createMissingSettings(), registryManager.getWrapperOrThrow(RegistryKeys.NOISE_PARAMETERS), seed);
}

However, this implementation does not support noise configurations for chunk generators that are not an instance of the NoiseChunkGenerator class. Fantasy should rewrite this code with a mixin to look more similar to the following:

if (chunkGenerator instanceof FantasyNoiseSettingsProvider noiseSettingsProvider) {
    this.noiseConfig = NoiseConfig.create(noiseSettingsProvider.getSettings().value(), registryManager.getWrapperOrThrow(RegistryKeys.NOISE_PARAMETERS), seed);
} else {
    this.noiseConfig = NoiseConfig.create(ChunkGeneratorSettings.createMissingSettings(), registryManager.getWrapperOrThrow(RegistryKeys.NOISE_PARAMETERS), seed);
}