use of net.minecraft.world.level.biome.FixedBiomeSource in project The-Aether by Gilded-Games.
the class AetherWorldData method generate.
@Override
public void generate(RegistryAccess registryAccess) {
// It if crashes on .get(), then you've got bigger problems than removing Optional here
DimensionType dimensionType = registryAccess.registry(Registry.DIMENSION_TYPE_REGISTRY).map(reg -> Registry.register(reg, new ResourceLocation(Aether.MODID, "aether_type"), this.aetherDimensionType())).get();
NoiseGeneratorSettings worldNoiseSettings = registryAccess.registry(BuiltinRegistries.NOISE_GENERATOR_SETTINGS.key()).map(reg -> Registry.register(reg, new ResourceLocation(Aether.MODID, "skyland_generation"), this.aetherNoiseSettings())).get();
NoiseBasedChunkGenerator aetherChunkGen = new NoiseBasedChunkGenerator(RegistryAccess.builtin().registryOrThrow(Registry.NOISE_REGISTRY), new FixedBiomeSource(AetherBiomeData.FLOATING_FOREST), 0L, () -> worldNoiseSettings);
this.serialize(Registry.LEVEL_STEM_REGISTRY, new ResourceLocation(Aether.MODID, "the_aether"), new LevelStem(() -> dimensionType, aetherChunkGen), LevelStem.CODEC);
}
use of net.minecraft.world.level.biome.FixedBiomeSource in project blueprint by team-abnormals.
the class BiomeSourceModificationManager method onServerAboutToStart.
@SuppressWarnings("unchecked")
@SubscribeEvent
public static void onServerAboutToStart(ServerAboutToStartEvent event) {
if (INSTANCE == null)
return;
List<BiomeSourceModifier> modifiers = INSTANCE.modifiers;
if (modifiers.isEmpty())
return;
MinecraftServer server = event.getServer();
WorldGenSettings worldGenSettings = server.getWorldData().worldGenSettings();
var dimensions = worldGenSettings.dimensions();
var keySet = dimensions.keySet();
SelectionSpace selectionSpace = (consumer) -> keySet.forEach(location -> consumer.accept(location, null));
HashMap<ResourceLocation, ArrayList<BiomeUtil.ModdedBiomeProvider>> map = new HashMap<>();
for (BiomeSourceModifier modifier : modifiers) {
BiomeUtil.ModdedBiomeProvider provider = modifier.provider();
if (provider.getWeight() <= 0)
return;
modifier.targetSelector().getTargetNames(selectionSpace).forEach(location -> {
map.computeIfAbsent(location, __ -> new ArrayList<>()).add(provider);
});
}
long seed = worldGenSettings.seed();
RegistryAccess registryAccess = server.registryAccess();
Registry<Biome> biomeRegistry = registryAccess.registryOrThrow(Registry.BIOME_REGISTRY);
Registry<NormalNoise.NoiseParameters> noiseParametersRegistry = registryAccess.registryOrThrow(Registry.NOISE_REGISTRY);
Registry<DensityFunction> densityFunctionRegistry = registryAccess.registryOrThrow(Registry.DENSITY_FUNCTION_REGISTRY);
NoiseSettings defaultNoiseSettings = registryAccess.registryOrThrow(Registry.NOISE_GENERATOR_SETTINGS_REGISTRY).getOrThrow(NoiseGeneratorSettings.OVERWORLD).noiseSettings();
DensityFunction defaultModdedness = densityFunctionRegistry.getOrThrow(ModdedBiomeSource.DEFAULT_MODDEDNESS);
for (Map.Entry<ResourceKey<LevelStem>, LevelStem> entry : dimensions.entrySet()) {
ResourceLocation location = entry.getKey().location();
ArrayList<BiomeUtil.ModdedBiomeProvider> providersForKey = map.get(location);
if (providersForKey != null && !providersForKey.isEmpty()) {
ChunkGenerator chunkGenerator = entry.getValue().generator();
BiomeSource source = chunkGenerator.getBiomeSource();
// TODO: Mostly experimental! Works with Terralith, Biomes O' Plenty, and more, but still needs more testing!
if (!(source instanceof FixedBiomeSource) && !(source instanceof CheckerboardColumnBiomeSource)) {
boolean legacy = false;
boolean noiseBased = chunkGenerator instanceof NoiseBasedChunkGenerator;
NoiseSettings noiseSettings = defaultNoiseSettings;
if (noiseBased) {
try {
NoiseGeneratorSettings settings = ((Holder<NoiseGeneratorSettings>) NOISE_GENERATOR_SETTINGS.get(chunkGenerator)).value();
if (settings != null) {
legacy = settings.useLegacyRandomSource();
noiseSettings = settings.noiseSettings();
}
} catch (IllegalAccessException ignored) {
}
}
DensityFunction moddedness = densityFunctionRegistry.get(new ResourceLocation(Blueprint.MOD_ID, "moddedness/" + location.getNamespace() + "/" + location.getPath()));
ModdedBiomeSource moddedBiomeSource = new ModdedBiomeSource(biomeRegistry, noiseParametersRegistry, densityFunctionRegistry, source, noiseSettings, seed, legacy, moddedness != null ? moddedness : defaultModdedness, new ModdedBiomeSource.WeightedBiomeSlices(providersForKey.toArray(new BiomeUtil.ModdedBiomeProvider[0])));
chunkGenerator.biomeSource = moddedBiomeSource;
chunkGenerator.runtimeBiomeSource = moddedBiomeSource;
if (noiseBased)
((ModdedSurfaceSystem) ((NoiseBasedChunkGenerator) chunkGenerator).surfaceSystem).setModdedBiomeSource(moddedBiomeSource);
}
}
}
}
Aggregations