Minor Update
This commit is contained in:
parent
0a5a608b7d
commit
7466048a22
3 changed files with 78 additions and 4 deletions
|
@ -22,7 +22,7 @@ public class WorldPresetsUI {
|
||||||
|
|
||||||
public static void setupClientside() {
|
public static void setupClientside() {
|
||||||
registerCustomizeUI(WorldPresets.BCL_WORLD, (createWorldScreen, worldCreationContext) -> {
|
registerCustomizeUI(WorldPresets.BCL_WORLD, (createWorldScreen, worldCreationContext) -> {
|
||||||
return new WorldSetupScreen(createWorldScreen);
|
return new WorldSetupScreen(createWorldScreen, worldCreationContext);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package org.betterx.bclib.gui.worldgen;
|
package org.betterx.bclib.gui.worldgen;
|
||||||
|
|
||||||
import net.minecraft.client.gui.screens.Screen;
|
import net.minecraft.client.gui.screens.worldselection.CreateWorldScreen;
|
||||||
import net.minecraft.client.gui.screens.worldselection.WorldCreationContext;
|
import net.minecraft.client.gui.screens.worldselection.WorldCreationContext;
|
||||||
import net.minecraft.core.Registry;
|
import net.minecraft.core.Registry;
|
||||||
import net.minecraft.network.chat.Component;
|
import net.minecraft.network.chat.Component;
|
||||||
|
@ -10,13 +10,22 @@ import net.minecraft.world.level.levelgen.WorldGenSettings;
|
||||||
import net.minecraft.world.level.levelgen.flat.FlatLevelGeneratorSettings;
|
import net.minecraft.world.level.levelgen.flat.FlatLevelGeneratorSettings;
|
||||||
import net.minecraft.world.level.levelgen.structure.StructureSet;
|
import net.minecraft.world.level.levelgen.structure.StructureSet;
|
||||||
|
|
||||||
|
import net.fabricmc.api.EnvType;
|
||||||
|
import net.fabricmc.api.Environment;
|
||||||
|
|
||||||
import org.betterx.bclib.gui.gridlayout.GridScreen;
|
import org.betterx.bclib.gui.gridlayout.GridScreen;
|
||||||
|
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
public class WorldSetupScreen extends GridScreen {
|
@Environment(EnvType.CLIENT)
|
||||||
public WorldSetupScreen(@Nullable Screen parent) {
|
public class WorldSetupScreen extends GridScreen {
|
||||||
|
private final WorldCreationContext context;
|
||||||
|
private final CreateWorldScreen createWorldScreen;
|
||||||
|
|
||||||
|
public WorldSetupScreen(@Nullable CreateWorldScreen parent, WorldCreationContext context) {
|
||||||
super(parent, Component.translatable("title.screen.bclib.worldgen.main"), 10, false);
|
super(parent, Component.translatable("title.screen.bclib.worldgen.main"), 10, false);
|
||||||
|
this.context = context;
|
||||||
|
this.createWorldScreen = parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -24,6 +33,10 @@ public class WorldSetupScreen extends GridScreen {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void updateSettings() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
private static WorldCreationContext.Updater worldConfiguration(FlatLevelGeneratorSettings flatLevelGeneratorSettings) {
|
private static WorldCreationContext.Updater worldConfiguration(FlatLevelGeneratorSettings flatLevelGeneratorSettings) {
|
||||||
return (frozen, worldGenSettings) -> {
|
return (frozen, worldGenSettings) -> {
|
||||||
Registry<StructureSet> registry = frozen.registryOrThrow(Registry.STRUCTURE_SET_REGISTRY);
|
Registry<StructureSet> registry = frozen.registryOrThrow(Registry.STRUCTURE_SET_REGISTRY);
|
||||||
|
|
|
@ -0,0 +1,61 @@
|
||||||
|
package org.betterx.bclib.presets.worldgen;
|
||||||
|
|
||||||
|
import net.minecraft.core.Holder;
|
||||||
|
import net.minecraft.core.Registry;
|
||||||
|
import net.minecraft.resources.RegistryOps;
|
||||||
|
import net.minecraft.world.level.biome.BiomeSource;
|
||||||
|
import net.minecraft.world.level.chunk.ChunkGenerator;
|
||||||
|
import net.minecraft.world.level.levelgen.NoiseBasedChunkGenerator;
|
||||||
|
import net.minecraft.world.level.levelgen.NoiseGeneratorSettings;
|
||||||
|
import net.minecraft.world.level.levelgen.structure.StructureSet;
|
||||||
|
import net.minecraft.world.level.levelgen.synth.NormalNoise;
|
||||||
|
|
||||||
|
import com.mojang.serialization.Codec;
|
||||||
|
import com.mojang.serialization.codecs.RecordCodecBuilder;
|
||||||
|
import org.betterx.bclib.interfaces.NoiseGeneratorSettingsProvider;
|
||||||
|
|
||||||
|
public class BCLChunkGenerator extends NoiseBasedChunkGenerator {
|
||||||
|
public static final Codec<BCLChunkGenerator> CODEC = RecordCodecBuilder
|
||||||
|
.create((RecordCodecBuilder.Instance<BCLChunkGenerator> builderInstance) -> {
|
||||||
|
final RecordCodecBuilder<BCLChunkGenerator, Registry<NormalNoise.NoiseParameters>> noiseGetter = RegistryOps
|
||||||
|
.retrieveRegistry(
|
||||||
|
Registry.NOISE_REGISTRY)
|
||||||
|
.forGetter(
|
||||||
|
BCLChunkGenerator::getNoises);
|
||||||
|
|
||||||
|
RecordCodecBuilder<BCLChunkGenerator, BiomeSource> biomeSourceCodec = BiomeSource.CODEC
|
||||||
|
.fieldOf("biome_source")
|
||||||
|
.forGetter((BCLChunkGenerator generator) -> generator.biomeSource);
|
||||||
|
|
||||||
|
RecordCodecBuilder<BCLChunkGenerator, Holder<NoiseGeneratorSettings>> settingsCodec = NoiseGeneratorSettings.CODEC
|
||||||
|
.fieldOf("settings")
|
||||||
|
.forGetter((BCLChunkGenerator generator) -> generator.settings);
|
||||||
|
|
||||||
|
|
||||||
|
return NoiseBasedChunkGenerator
|
||||||
|
.commonCodec(builderInstance)
|
||||||
|
.and(builderInstance.group(noiseGetter, biomeSourceCodec, settingsCodec))
|
||||||
|
.apply(builderInstance, builderInstance.stable(BCLChunkGenerator::new));
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
public BCLChunkGenerator(Registry<StructureSet> registry,
|
||||||
|
Registry<NormalNoise.NoiseParameters> registry2,
|
||||||
|
BiomeSource biomeSource,
|
||||||
|
Holder<NoiseGeneratorSettings> holder) {
|
||||||
|
super(registry, registry2, biomeSource, holder);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Codec<? extends ChunkGenerator> codec() {
|
||||||
|
return CODEC;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private Registry<NormalNoise.NoiseParameters> getNoises() {
|
||||||
|
if (this instanceof NoiseGeneratorSettingsProvider p) {
|
||||||
|
return p.bclib_getNoises();
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue