Layout for World customization Screen
This commit is contained in:
parent
f45eaddde6
commit
faa20c608e
5 changed files with 162 additions and 72 deletions
|
@ -7,7 +7,7 @@ import net.minecraft.world.level.levelgen.presets.WorldPreset;
|
||||||
import net.fabricmc.api.EnvType;
|
import net.fabricmc.api.EnvType;
|
||||||
import net.fabricmc.api.Environment;
|
import net.fabricmc.api.Environment;
|
||||||
|
|
||||||
import org.betterx.bclib.gui.worldgen.WorldSetupScreen;
|
import org.betterx.bclib.gui.screens.WorldSetupScreen;
|
||||||
import org.betterx.bclib.presets.worldgen.WorldPresets;
|
import org.betterx.bclib.presets.worldgen.WorldPresets;
|
||||||
|
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
|
@ -0,0 +1,149 @@
|
||||||
|
package org.betterx.bclib.gui.screens;
|
||||||
|
|
||||||
|
import net.minecraft.client.gui.screens.worldselection.CreateWorldScreen;
|
||||||
|
import net.minecraft.client.gui.screens.worldselection.WorldCreationContext;
|
||||||
|
import net.minecraft.core.Registry;
|
||||||
|
import net.minecraft.network.chat.CommonComponents;
|
||||||
|
import net.minecraft.network.chat.Component;
|
||||||
|
import net.minecraft.world.level.chunk.ChunkGenerator;
|
||||||
|
import net.minecraft.world.level.dimension.LevelStem;
|
||||||
|
import net.minecraft.world.level.levelgen.FlatLevelSource;
|
||||||
|
import net.minecraft.world.level.levelgen.WorldGenSettings;
|
||||||
|
import net.minecraft.world.level.levelgen.flat.FlatLevelGeneratorSettings;
|
||||||
|
import net.minecraft.world.level.levelgen.structure.StructureSet;
|
||||||
|
|
||||||
|
import net.fabricmc.api.EnvType;
|
||||||
|
import net.fabricmc.api.Environment;
|
||||||
|
|
||||||
|
import org.betterx.bclib.BCLib;
|
||||||
|
import org.betterx.bclib.gui.gridlayout.GridCheckboxCell;
|
||||||
|
import org.betterx.bclib.gui.gridlayout.GridLayout;
|
||||||
|
import org.betterx.bclib.presets.worldgen.BCLChunkGenerator;
|
||||||
|
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
|
@Environment(EnvType.CLIENT)
|
||||||
|
public class WorldSetupScreen extends BCLibScreen {
|
||||||
|
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);
|
||||||
|
this.context = context;
|
||||||
|
this.createWorldScreen = parent;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private GridCheckboxCell bclibEnd;
|
||||||
|
private GridCheckboxCell bclibNether;
|
||||||
|
GridCheckboxCell endLegacy;
|
||||||
|
GridCheckboxCell netherLegacy;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void initLayout() {
|
||||||
|
final int netherVersion = BCLChunkGenerator.getBiomeVersionForGenerator(context
|
||||||
|
.worldGenSettings()
|
||||||
|
.dimensions()
|
||||||
|
.getOrCreateHolderOrThrow(
|
||||||
|
LevelStem.NETHER)
|
||||||
|
.value()
|
||||||
|
.generator());
|
||||||
|
final int endVersion = BCLChunkGenerator.getBiomeVersionForGenerator(context
|
||||||
|
.worldGenSettings()
|
||||||
|
.dimensions()
|
||||||
|
.getOrCreateHolderOrThrow(
|
||||||
|
LevelStem.END)
|
||||||
|
.value()
|
||||||
|
.generator());
|
||||||
|
|
||||||
|
final int BUTTON_HEIGHT = 20;
|
||||||
|
grid.addSpacerRow(20);
|
||||||
|
|
||||||
|
var row = grid.addRow();
|
||||||
|
var colNether = row.addColumn(0.5, GridLayout.GridValueType.PERCENTAGE);
|
||||||
|
var colEnd = row.addColumn(0.5, GridLayout.GridValueType.PERCENTAGE);
|
||||||
|
|
||||||
|
row = colNether.addRow();
|
||||||
|
row.addString(Component.translatable("title.bclib.the_nether"), GridLayout.Alignment.CENTER, this);
|
||||||
|
colNether.addSpacerRow(15);
|
||||||
|
|
||||||
|
var mainSettingsRow = colNether.addRow();
|
||||||
|
mainSettingsRow.addSpacer(16);
|
||||||
|
row = colNether.addRow();
|
||||||
|
row.addSpacer(32);
|
||||||
|
netherLegacy = row.addCheckbox(Component.translatable("title.screen.bclib.worldgen.legacy_square"),
|
||||||
|
endVersion == BCLChunkGenerator.BIOME_SOURCE_VERSION_SQUARE,
|
||||||
|
font,
|
||||||
|
(state) -> {
|
||||||
|
});
|
||||||
|
bclibNether = mainSettingsRow.addCheckbox(Component.translatable(
|
||||||
|
"title.screen.bclib.worldgen.custom_biome_source"),
|
||||||
|
netherVersion != BCLChunkGenerator.BIOME_SOURCE_VERSION_VANILLA,
|
||||||
|
font,
|
||||||
|
(state) -> {
|
||||||
|
netherLegacy.setEnabled(state);
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
row = colEnd.addRow(GridLayout.VerticalAlignment.CENTER);
|
||||||
|
row.addString(Component.translatable("title.bclib.the_end"), GridLayout.Alignment.CENTER, this);
|
||||||
|
colEnd.addSpacerRow(15);
|
||||||
|
|
||||||
|
mainSettingsRow = colEnd.addRow();
|
||||||
|
mainSettingsRow.addSpacer(16);
|
||||||
|
row = colEnd.addRow();
|
||||||
|
row.addSpacer(32);
|
||||||
|
|
||||||
|
endLegacy = row.addCheckbox(Component.translatable("title.screen.bclib.worldgen.legacy_square"),
|
||||||
|
endVersion == BCLChunkGenerator.BIOME_SOURCE_VERSION_SQUARE,
|
||||||
|
font,
|
||||||
|
(state) -> {
|
||||||
|
});
|
||||||
|
|
||||||
|
bclibEnd = mainSettingsRow.addCheckbox(Component.translatable(
|
||||||
|
"title.screen.bclib.worldgen.custom_biome_source"),
|
||||||
|
endVersion != BCLChunkGenerator.BIOME_SOURCE_VERSION_VANILLA,
|
||||||
|
font,
|
||||||
|
(state) -> {
|
||||||
|
endLegacy.setEnabled(state);
|
||||||
|
});
|
||||||
|
|
||||||
|
grid.addSpacerRow(15);
|
||||||
|
row = grid.addRow();
|
||||||
|
row.addFiller();
|
||||||
|
row.addButton(CommonComponents.GUI_DONE, BUTTON_HEIGHT, font, (button) -> {
|
||||||
|
updateSettings();
|
||||||
|
onClose();
|
||||||
|
});
|
||||||
|
grid.addSpacerRow(10);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateSettings() {
|
||||||
|
int endVersion = BCLChunkGenerator.DEFAULT_BIOME_SOURCE_VERSION;
|
||||||
|
if (bclibEnd.isChecked()) {
|
||||||
|
if (endLegacy.isChecked()) endVersion = BCLChunkGenerator.BIOME_SOURCE_VERSION_SQUARE;
|
||||||
|
else endVersion = BCLChunkGenerator.BIOME_SOURCE_VERSION_HEX;
|
||||||
|
} else {
|
||||||
|
endVersion = BCLChunkGenerator.BIOME_SOURCE_VERSION_VANILLA;
|
||||||
|
}
|
||||||
|
|
||||||
|
int netherVersion = BCLChunkGenerator.DEFAULT_BIOME_SOURCE_VERSION;
|
||||||
|
if (bclibNether.isChecked()) {
|
||||||
|
if (netherLegacy.isChecked()) netherVersion = BCLChunkGenerator.BIOME_SOURCE_VERSION_SQUARE;
|
||||||
|
else netherVersion = BCLChunkGenerator.BIOME_SOURCE_VERSION_HEX;
|
||||||
|
} else {
|
||||||
|
netherVersion = BCLChunkGenerator.BIOME_SOURCE_VERSION_VANILLA;
|
||||||
|
}
|
||||||
|
|
||||||
|
BCLib.LOGGER.info("Custom World Versions: end=" + endVersion + ", nether=" + netherVersion);
|
||||||
|
}
|
||||||
|
|
||||||
|
private WorldCreationContext.Updater worldConfiguration(FlatLevelGeneratorSettings flatLevelGeneratorSettings) {
|
||||||
|
|
||||||
|
return (frozen, worldGenSettings) -> {
|
||||||
|
Registry<StructureSet> registry = frozen.registryOrThrow(Registry.STRUCTURE_SET_REGISTRY);
|
||||||
|
ChunkGenerator chunkGenerator = new FlatLevelSource(registry, flatLevelGeneratorSettings);
|
||||||
|
return WorldGenSettings.replaceOverworldGenerator(frozen, worldGenSettings, chunkGenerator);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,69 +0,0 @@
|
||||||
package org.betterx.bclib.gui.worldgen;
|
|
||||||
|
|
||||||
import net.minecraft.client.gui.screens.worldselection.CreateWorldScreen;
|
|
||||||
import net.minecraft.client.gui.screens.worldselection.WorldCreationContext;
|
|
||||||
import net.minecraft.core.Registry;
|
|
||||||
import net.minecraft.network.chat.CommonComponents;
|
|
||||||
import net.minecraft.network.chat.Component;
|
|
||||||
import net.minecraft.world.level.chunk.ChunkGenerator;
|
|
||||||
import net.minecraft.world.level.levelgen.FlatLevelSource;
|
|
||||||
import net.minecraft.world.level.levelgen.WorldGenSettings;
|
|
||||||
import net.minecraft.world.level.levelgen.flat.FlatLevelGeneratorSettings;
|
|
||||||
import net.minecraft.world.level.levelgen.structure.StructureSet;
|
|
||||||
|
|
||||||
import net.fabricmc.api.EnvType;
|
|
||||||
import net.fabricmc.api.Environment;
|
|
||||||
|
|
||||||
import org.betterx.bclib.gui.gridlayout.GridLayout;
|
|
||||||
import org.betterx.bclib.gui.gridlayout.GridScreen;
|
|
||||||
|
|
||||||
import org.jetbrains.annotations.Nullable;
|
|
||||||
|
|
||||||
@Environment(EnvType.CLIENT)
|
|
||||||
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);
|
|
||||||
this.context = context;
|
|
||||||
this.createWorldScreen = parent;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void initLayout() {
|
|
||||||
final int BUTTON_HEIGHT = 20;
|
|
||||||
grid.addSpacerRow();
|
|
||||||
|
|
||||||
var row = grid.addRow();
|
|
||||||
var colNether = row.addColumn(0.5, GridLayout.GridValueType.PERCENTAGE);
|
|
||||||
var colEnd = row.addColumn(0.5, GridLayout.GridValueType.PERCENTAGE);
|
|
||||||
|
|
||||||
row = colNether.addRow(GridLayout.VerticalAlignment.CENTER);
|
|
||||||
row.addString(Component.literal("The Nether"), GridLayout.Alignment.CENTER, this);
|
|
||||||
|
|
||||||
row = colEnd.addRow(GridLayout.VerticalAlignment.CENTER);
|
|
||||||
row.addString(Component.literal("The End"), GridLayout.Alignment.CENTER, this);
|
|
||||||
|
|
||||||
grid.addSpacerRow(15);
|
|
||||||
row = grid.addRow();
|
|
||||||
row.addFiller();
|
|
||||||
row.addButton(CommonComponents.GUI_DONE, BUTTON_HEIGHT, font, (button) -> {
|
|
||||||
//TODO: update settings
|
|
||||||
onClose();
|
|
||||||
});
|
|
||||||
grid.addSpacerRow(10);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void updateSettings() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private static WorldCreationContext.Updater worldConfiguration(FlatLevelGeneratorSettings flatLevelGeneratorSettings) {
|
|
||||||
return (frozen, worldGenSettings) -> {
|
|
||||||
Registry<StructureSet> registry = frozen.registryOrThrow(Registry.STRUCTURE_SET_REGISTRY);
|
|
||||||
ChunkGenerator chunkGenerator = new FlatLevelSource(registry, flatLevelGeneratorSettings);
|
|
||||||
return WorldGenSettings.replaceOverworldGenerator(frozen, worldGenSettings, chunkGenerator);
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -50,5 +50,10 @@
|
||||||
"title.bclib.datafixer.error.continue": "Continue and Mark as Fixed",
|
"title.bclib.datafixer.error.continue": "Continue and Mark as Fixed",
|
||||||
"title.config.bclib.main.ui.suppressExperimentalDialogOnLoad": "Disable Experimental Warning Screen on Load",
|
"title.config.bclib.main.ui.suppressExperimentalDialogOnLoad": "Disable Experimental Warning Screen on Load",
|
||||||
"tooltip.bclib.place_on": "Lebt auf: %s",
|
"tooltip.bclib.place_on": "Lebt auf: %s",
|
||||||
"generator.bclib.normal": "BetterX"
|
"generator.bclib.normal": "BetterX",
|
||||||
|
"title.screen.bclib.worldgen.main": "Welt-Generator Eigenschaften",
|
||||||
|
"title.bclib.the_nether": "Nether",
|
||||||
|
"title.bclib.the_end": "Das Ende",
|
||||||
|
"title.screen.bclib.worldgen.custom_biome_source": "Benutzerdefinierte Biomquelle verwenden",
|
||||||
|
"title.screen.bclib.worldgen.legacy_square": "Legacy-Verteilung (1.17)"
|
||||||
}
|
}
|
|
@ -51,5 +51,10 @@
|
||||||
"title.config.bclib.client.rendering.customFogRendering": "Custom Fog Rendering",
|
"title.config.bclib.client.rendering.customFogRendering": "Custom Fog Rendering",
|
||||||
"title.config.bclib.client.rendering.netherThickFog": "Nether Thick Fog",
|
"title.config.bclib.client.rendering.netherThickFog": "Nether Thick Fog",
|
||||||
"tooltip.bclib.place_on": "Survives on: %s",
|
"tooltip.bclib.place_on": "Survives on: %s",
|
||||||
"generator.bclib.normal": "BetterX"
|
"generator.bclib.normal": "BetterX",
|
||||||
|
"title.screen.bclib.worldgen.main": "World Generator Settings",
|
||||||
|
"title.bclib.the_nether": "The Nether",
|
||||||
|
"title.bclib.the_end": "The End",
|
||||||
|
"title.screen.bclib.worldgen.custom_biome_source": "Use Custom Biome Source",
|
||||||
|
"title.screen.bclib.worldgen.legacy_square": "Use Legacy Map (1.17)"
|
||||||
}
|
}
|
Loading…
Add table
Add a link
Reference in a new issue