-
Notifications
You must be signed in to change notification settings - Fork 91
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
51 additions
and
77 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
69 changes: 34 additions & 35 deletions
69
src/main/java/com/jsorrell/skyblock/gen/SkyBlockGenerationSettings.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,74 +1,73 @@ | ||
package com.jsorrell.skyblock.gen; | ||
|
||
import com.mojang.serialization.Lifecycle; | ||
import net.minecraft.util.math.noise.DoublePerlinNoiseSampler; | ||
import net.minecraft.util.registry.DynamicRegistryManager; | ||
import net.minecraft.util.registry.Registry; | ||
import net.minecraft.util.registry.SimpleRegistry; | ||
import net.minecraft.world.biome.Biome; | ||
import net.minecraft.world.biome.source.MultiNoiseBiomeSource; | ||
import net.minecraft.world.biome.source.TheEndBiomeSource; | ||
import net.minecraft.world.dimension.DimensionOptions; | ||
import net.minecraft.world.dimension.DimensionType; | ||
import net.minecraft.world.gen.chunk.ChunkGenerator; | ||
import net.minecraft.world.gen.chunk.ChunkGeneratorSettings; | ||
|
||
public class SkyBlockGenerationSettings { | ||
|
||
public static final String NAME = "skyblock"; | ||
|
||
public static SimpleRegistry<DimensionOptions> getSkyBlockDimensionOptions( | ||
Registry<DimensionType> dimensionTypeRegistry, | ||
Registry<DoublePerlinNoiseSampler.NoiseParameters> noiseRegistry, | ||
Registry<Biome> biomeRegistry, | ||
Registry<ChunkGeneratorSettings> settingsRegistry, | ||
public static SimpleRegistry<DimensionOptions> getSkyBlockDimensionOptionsRegistry( | ||
DynamicRegistryManager drm, | ||
long seed) { | ||
SimpleRegistry<DimensionOptions> simpleRegistry = | ||
new SimpleRegistry<>(Registry.DIMENSION_KEY, Lifecycle.experimental()); | ||
simpleRegistry.add( | ||
SimpleRegistry<DimensionOptions> dimensionOptionsRegistry = new SimpleRegistry<>(Registry.DIMENSION_KEY, Lifecycle.experimental()); | ||
|
||
Registry<DimensionType> dimensionTypeRegistry = drm.get(Registry.DIMENSION_TYPE_KEY); | ||
|
||
dimensionOptionsRegistry.add( | ||
DimensionOptions.OVERWORLD, | ||
new DimensionOptions( | ||
() -> dimensionTypeRegistry.get(DimensionType.OVERWORLD_REGISTRY_KEY), | ||
createOverworldGenerator(noiseRegistry, biomeRegistry, settingsRegistry, seed)), | ||
() -> dimensionTypeRegistry.getOrThrow(DimensionType.OVERWORLD_REGISTRY_KEY), | ||
createOverworldGenerator(drm, seed)), | ||
Lifecycle.stable()); | ||
simpleRegistry.add( | ||
|
||
dimensionOptionsRegistry.add( | ||
DimensionOptions.NETHER, | ||
new DimensionOptions( | ||
() -> dimensionTypeRegistry.get(DimensionType.THE_NETHER_REGISTRY_KEY), | ||
createNetherGenerator(noiseRegistry, biomeRegistry, settingsRegistry, seed)), | ||
() -> dimensionTypeRegistry.getOrThrow(DimensionType.THE_NETHER_REGISTRY_KEY), | ||
createNetherGenerator(drm, seed)), | ||
Lifecycle.stable()); | ||
simpleRegistry.add( | ||
|
||
dimensionOptionsRegistry.add( | ||
DimensionOptions.END, | ||
new DimensionOptions( | ||
() -> dimensionTypeRegistry.get(DimensionType.THE_END_REGISTRY_KEY), | ||
createEndGenerator(noiseRegistry, biomeRegistry, settingsRegistry, seed)), | ||
() -> dimensionTypeRegistry.getOrThrow(DimensionType.THE_END_REGISTRY_KEY), | ||
createEndGenerator(drm, seed)), | ||
Lifecycle.stable()); | ||
return simpleRegistry; | ||
return dimensionOptionsRegistry; | ||
} | ||
|
||
public static ChunkGenerator createOverworldGenerator(Registry<DoublePerlinNoiseSampler.NoiseParameters> noiseRegistry, | ||
Registry<Biome> biomeRegistry, Registry<ChunkGeneratorSettings> settingsRegistry, long seed) { | ||
public static SkyBlockChunkGenerator createOverworldGenerator(DynamicRegistryManager drm, long seed) { | ||
Registry<ChunkGeneratorSettings> chunkGeneratorSettingsRegistry = drm.get(Registry.CHUNK_GENERATOR_SETTINGS_KEY); | ||
return new SkyBlockChunkGenerator( | ||
noiseRegistry, | ||
MultiNoiseBiomeSource.Preset.OVERWORLD.getBiomeSource(biomeRegistry).withSeed(seed), | ||
drm.get(Registry.NOISE_WORLDGEN), | ||
MultiNoiseBiomeSource.Preset.OVERWORLD.getBiomeSource(drm.get(Registry.BIOME_KEY), true), | ||
seed, | ||
() -> settingsRegistry.getOrThrow(ChunkGeneratorSettings.OVERWORLD)); | ||
() -> chunkGeneratorSettingsRegistry.getOrThrow(ChunkGeneratorSettings.OVERWORLD)); | ||
} | ||
|
||
public static ChunkGenerator createNetherGenerator(Registry<DoublePerlinNoiseSampler.NoiseParameters> noiseRegistry, | ||
Registry<Biome> biomeRegistry, Registry<ChunkGeneratorSettings> settingsRegistry, long seed) { | ||
public static SkyBlockChunkGenerator createNetherGenerator(DynamicRegistryManager drm, long seed) { | ||
Registry<ChunkGeneratorSettings> chunkGeneratorSettingsRegistry = drm.get(Registry.CHUNK_GENERATOR_SETTINGS_KEY); | ||
return new SkyBlockChunkGenerator( | ||
noiseRegistry, | ||
MultiNoiseBiomeSource.Preset.NETHER.getBiomeSource(biomeRegistry).withSeed(seed), | ||
drm.get(Registry.NOISE_WORLDGEN), | ||
MultiNoiseBiomeSource.Preset.NETHER.getBiomeSource(drm.get(Registry.BIOME_KEY)).withSeed(seed), | ||
seed, | ||
() -> settingsRegistry.getOrThrow(ChunkGeneratorSettings.NETHER)); | ||
() -> chunkGeneratorSettingsRegistry.getOrThrow(ChunkGeneratorSettings.NETHER)); | ||
} | ||
|
||
public static ChunkGenerator createEndGenerator(Registry<DoublePerlinNoiseSampler.NoiseParameters> noiseRegistry, | ||
Registry<Biome> biomeRegistry, Registry<ChunkGeneratorSettings> settingsRegistry, long seed) { | ||
public static SkyBlockChunkGenerator createEndGenerator(DynamicRegistryManager drm, long seed) { | ||
Registry<ChunkGeneratorSettings> chunkGeneratorSettingsRegistry = drm.get(Registry.CHUNK_GENERATOR_SETTINGS_KEY); | ||
return new SkyBlockChunkGenerator( | ||
noiseRegistry, | ||
new TheEndBiomeSource(biomeRegistry, seed), | ||
drm.get(Registry.NOISE_WORLDGEN), | ||
new TheEndBiomeSource(drm.get(Registry.BIOME_KEY), seed), | ||
seed, | ||
() -> settingsRegistry.getOrThrow(ChunkGeneratorSettings.END)); | ||
() -> chunkGeneratorSettingsRegistry.getOrThrow(ChunkGeneratorSettings.END)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters