use of net.minecraft.world.level.levelgen.NoiseBasedChunkGenerator 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()));
}
}
}
use of net.minecraft.world.level.levelgen.NoiseBasedChunkGenerator in project fabric-carpet by gnembon.
the class WorldTools method createWorld.
public static boolean createWorld(MinecraftServer server, String worldKey, Long seed) {
ResourceLocation worldId = new ResourceLocation(worldKey);
ServerLevel overWorld = server.overworld();
Set<ResourceKey<Level>> worldKeys = server.levelKeys();
for (ResourceKey<Level> worldRegistryKey : worldKeys) {
if (worldRegistryKey.location().equals(worldId)) {
// world with this id already exists
return false;
}
}
ServerLevelData serverWorldProperties = server.getWorldData().overworldData();
WorldGenSettings generatorOptions = server.getWorldData().worldGenSettings();
boolean bl = generatorOptions.isDebug();
long l = generatorOptions.seed();
long m = BiomeManager.obfuscateSeed(l);
List<CustomSpawner> list = List.of();
Registry<LevelStem> simpleRegistry = generatorOptions.dimensions();
LevelStem dimensionOptions = simpleRegistry.get(LevelStem.OVERWORLD);
ChunkGenerator chunkGenerator2;
Holder<DimensionType> dimensionType2;
if (dimensionOptions == null) {
dimensionType2 = server.registryAccess().registryOrThrow(Registry.DIMENSION_TYPE_REGISTRY).getOrCreateHolder(DimensionType.OVERWORLD_LOCATION);
;
chunkGenerator2 = WorldGenSettings.makeDefaultOverworld(server.registryAccess(), (new Random()).nextLong());
} else {
dimensionType2 = dimensionOptions.typeHolder();
chunkGenerator2 = dimensionOptions.generator();
}
ResourceKey<Level> customWorld = ResourceKey.create(Registry.DIMENSION_REGISTRY, worldId);
// chunkGenerator2 = GeneratorOptions.createOverworldGenerator(server.getRegistryManager().get(Registry.BIOME_KEY), server.getRegistryManager().get(Registry.NOISE_SETTINGS_WORLDGEN), (seed==null)?l:seed);
// from world/gen/GeneratorOptions
// chunkGenerator2 = new NoiseChunkGenerator(MultiNoiseBiomeSource.createVanillaSource(server.getRegistryManager().get(Registry.BIOME_KEY), seed), seed, () -> {
// return server.getRegistryManager().get(Registry.CHUNK_GENERATOR_SETTINGS_KEY).getOrThrow(ChunkGeneratorSettings.OVERWORLD);
// });
chunkGenerator2 = new NoiseBasedChunkGenerator(server.registryAccess().registryOrThrow(Registry.STRUCTURE_SET_REGISTRY), server.registryAccess().registryOrThrow(Registry.NOISE_REGISTRY), MultiNoiseBiomeSource.Preset.OVERWORLD.biomeSource(server.registryAccess().registryOrThrow(Registry.BIOME_REGISTRY)), seed, Holder.direct(server.registryAccess().registryOrThrow(Registry.NOISE_GENERATOR_SETTINGS_REGISTRY).getOrThrow(NoiseGeneratorSettings.OVERWORLD)));
ServerLevel serverWorld = new ServerLevel(server, Util.backgroundExecutor(), ((MinecraftServerInterface) server).getCMSession(), new DerivedLevelData(server.getWorldData(), serverWorldProperties), customWorld, dimensionType2, NOOP_LISTENER, chunkGenerator2, bl, (seed == null) ? l : seed, list, false);
overWorld.getWorldBorder().addListener(new BorderChangeListener.DelegateBorderChangeListener(serverWorld.getWorldBorder()));
((MinecraftServerInterface) server).getCMWorlds().put(customWorld, serverWorld);
return true;
}
use of net.minecraft.world.level.levelgen.NoiseBasedChunkGenerator in project BCLib by paulevsGitch.
the class DimensionTypeMixin method bclib_updateDimensions.
@Inject(method = "defaultDimensions(Lnet/minecraft/core/RegistryAccess;JZ)Lnet/minecraft/core/MappedRegistry;", locals = LocalCapture.CAPTURE_FAILHARD, at = @At("TAIL"))
private static void bclib_updateDimensions(RegistryAccess registryAccess, long seed, boolean bl, CallbackInfoReturnable<MappedRegistry<LevelStem>> info, MappedRegistry<LevelStem> mappedRegistry, Registry<DimensionType> registry, Registry<Biome> biomeRegistry, Registry<NoiseGeneratorSettings> noiseSettingsRegistry, Registry<NormalNoise.NoiseParameters> noiseParamRegistry) {
int id = mappedRegistry.getId(mappedRegistry.get(LevelStem.NETHER));
mappedRegistry.registerOrOverride(OptionalInt.of(id), LevelStem.NETHER, new LevelStem(() -> registry.getOrThrow(DimensionType.NETHER_LOCATION), new NoiseBasedChunkGenerator(noiseParamRegistry, new BCLibNetherBiomeSource(biomeRegistry, seed), seed, () -> noiseSettingsRegistry.getOrThrow(NoiseGeneratorSettings.NETHER))), Lifecycle.stable());
id = mappedRegistry.getId(mappedRegistry.get(LevelStem.END));
mappedRegistry.registerOrOverride(OptionalInt.of(id), LevelStem.END, new LevelStem(() -> registry.getOrThrow(DimensionType.END_LOCATION), new NoiseBasedChunkGenerator(noiseParamRegistry, new BCLibEndBiomeSource(biomeRegistry, seed), seed, () -> noiseSettingsRegistry.getOrThrow(NoiseGeneratorSettings.END))), Lifecycle.stable());
}
use of net.minecraft.world.level.levelgen.NoiseBasedChunkGenerator 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.levelgen.NoiseBasedChunkGenerator in project SkyblockBuilder by MelanX.
the class VoidWorldType method defaultEndGenerator.
private static ChunkGenerator defaultEndGenerator(RegistryAccess dynamicRegistries, long seed) {
Registry<NoiseGeneratorSettings> noiseGeneratorSettings = dynamicRegistries.registryOrThrow(Registry.NOISE_GENERATOR_SETTINGS_REGISTRY);
Registry<StructureSet> structureSets = dynamicRegistries.registryOrThrow(Registry.STRUCTURE_SET_REGISTRY);
Registry<NormalNoise.NoiseParameters> noises = dynamicRegistries.registryOrThrow(Registry.NOISE_REGISTRY);
TheEndBiomeSource biomeSource = new TheEndBiomeSource(dynamicRegistries.registryOrThrow(Registry.BIOME_REGISTRY), seed);
Holder<NoiseGeneratorSettings> settings = noiseGeneratorSettings.getOrCreateHolder(NoiseGeneratorSettings.END);
return new NoiseBasedChunkGenerator(structureSets, noises, biomeSource, seed, settings);
}
Aggregations