Functional WorldSetupScreen
This commit is contained in:
parent
faa20c608e
commit
dd0c259b56
9 changed files with 197 additions and 112 deletions
|
@ -90,11 +90,11 @@ public class GridRow extends GridContainer {
|
|||
OnPress onPress) {
|
||||
GridCell cell = new GridCell(width, height, widthType, (transform) -> {
|
||||
Button customButton = new Button(transform.left,
|
||||
transform.top,
|
||||
transform.width,
|
||||
transform.height,
|
||||
text,
|
||||
onPress);
|
||||
transform.top,
|
||||
transform.width,
|
||||
transform.height,
|
||||
text,
|
||||
onPress);
|
||||
customButton.setAlpha(alpha);
|
||||
return customButton;
|
||||
}, null);
|
||||
|
@ -104,6 +104,11 @@ public class GridRow extends GridContainer {
|
|||
|
||||
public GridCheckboxCell addCheckbox(Component text, boolean checked, Font font, Consumer<Boolean> onChange) {
|
||||
final int width = font.width(text.getVisualOrderText()) + 24 + 2 * 12;
|
||||
return addCheckbox(text, checked, width, widthType, onChange);
|
||||
}
|
||||
|
||||
public GridCheckboxCell addCheckbox(Component text, boolean checked, double width,
|
||||
GridLayout.GridValueType widthType, Consumer<Boolean> onChange) {
|
||||
|
||||
GridCheckboxCell cell = new GridCheckboxCell(text, checked, 1.0f, width, widthType, 20, onChange);
|
||||
this.cells.add(cell);
|
||||
|
@ -157,16 +162,16 @@ public class GridRow extends GridContainer {
|
|||
|
||||
public GridCell addImage(ResourceLocation location, float alpha, int width, int height) {
|
||||
return addImage(location,
|
||||
alpha,
|
||||
width,
|
||||
GridLayout.GridValueType.CONSTANT,
|
||||
height,
|
||||
0,
|
||||
0,
|
||||
width,
|
||||
height,
|
||||
width,
|
||||
height);
|
||||
alpha,
|
||||
width,
|
||||
GridLayout.GridValueType.CONSTANT,
|
||||
height,
|
||||
0,
|
||||
0,
|
||||
width,
|
||||
height,
|
||||
width,
|
||||
height);
|
||||
}
|
||||
|
||||
public GridCell addImage(ResourceLocation location,
|
||||
|
@ -186,16 +191,16 @@ public class GridRow extends GridContainer {
|
|||
int resourceWidth,
|
||||
int resourceHeight) {
|
||||
return addImage(location,
|
||||
alpha,
|
||||
width,
|
||||
widthType,
|
||||
height,
|
||||
0,
|
||||
0,
|
||||
resourceWidth,
|
||||
resourceWidth,
|
||||
resourceWidth,
|
||||
resourceHeight);
|
||||
alpha,
|
||||
width,
|
||||
widthType,
|
||||
height,
|
||||
0,
|
||||
0,
|
||||
resourceWidth,
|
||||
resourceWidth,
|
||||
resourceWidth,
|
||||
resourceHeight);
|
||||
}
|
||||
|
||||
public GridCell addImage(ResourceLocation location,
|
||||
|
@ -209,16 +214,16 @@ public class GridRow extends GridContainer {
|
|||
int resourceWidth,
|
||||
int resourceHeight) {
|
||||
return addImage(location,
|
||||
1.0f,
|
||||
width,
|
||||
widthType,
|
||||
height,
|
||||
uvLeft,
|
||||
uvTop,
|
||||
uvWidth,
|
||||
uvHeight,
|
||||
resourceWidth,
|
||||
resourceHeight);
|
||||
1.0f,
|
||||
width,
|
||||
widthType,
|
||||
height,
|
||||
uvLeft,
|
||||
uvTop,
|
||||
uvWidth,
|
||||
uvHeight,
|
||||
resourceWidth,
|
||||
resourceHeight);
|
||||
}
|
||||
|
||||
public GridCell addImage(ResourceLocation location,
|
||||
|
@ -233,16 +238,16 @@ public class GridRow extends GridContainer {
|
|||
int resourceWidth,
|
||||
int resourceHeight) {
|
||||
GridCell cell = new GridImageCell(location,
|
||||
width,
|
||||
widthType,
|
||||
height,
|
||||
alpha,
|
||||
uvLeft,
|
||||
uvTop,
|
||||
uvWidth,
|
||||
uvHeight,
|
||||
resourceWidth,
|
||||
resourceHeight);
|
||||
width,
|
||||
widthType,
|
||||
height,
|
||||
alpha,
|
||||
uvLeft,
|
||||
uvTop,
|
||||
uvWidth,
|
||||
uvHeight,
|
||||
resourceWidth,
|
||||
resourceHeight);
|
||||
this.cells.add(cell);
|
||||
return cell;
|
||||
}
|
||||
|
@ -303,11 +308,11 @@ public class GridRow extends GridContainer {
|
|||
public GridStringCell addString(Component text, int color, GridScreen parent) {
|
||||
final int width = parent.getWidth(text);
|
||||
return this.addString(text,
|
||||
width,
|
||||
GridLayout.GridValueType.CONSTANT,
|
||||
color,
|
||||
GridLayout.Alignment.CENTER,
|
||||
parent);
|
||||
width,
|
||||
GridLayout.GridValueType.CONSTANT,
|
||||
color,
|
||||
GridLayout.Alignment.CENTER,
|
||||
parent);
|
||||
}
|
||||
|
||||
public GridStringCell addString(Component text, GridLayout.Alignment contentAlignment, GridScreen parent) {
|
||||
|
@ -336,12 +341,12 @@ public class GridRow extends GridContainer {
|
|||
GridLayout.Alignment contentAlignment,
|
||||
GridScreen parent) {
|
||||
GridStringCell cell = new GridStringCell(width,
|
||||
widthType,
|
||||
parent.getFont().lineHeight,
|
||||
contentAlignment,
|
||||
parent,
|
||||
text,
|
||||
color);
|
||||
widthType,
|
||||
parent.getFont().lineHeight,
|
||||
contentAlignment,
|
||||
parent,
|
||||
text,
|
||||
color);
|
||||
this.cells.add(cell);
|
||||
return cell;
|
||||
}
|
||||
|
|
|
@ -2,15 +2,12 @@ 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.resources.ResourceKey;
|
||||
import net.minecraft.world.level.dimension.BuiltinDimensionTypes;
|
||||
import net.minecraft.world.level.dimension.DimensionType;
|
||||
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;
|
||||
|
@ -19,6 +16,8 @@ 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.betterx.bclib.presets.worldgen.WorldPresets;
|
||||
import org.betterx.bclib.world.generator.BCLBiomeSource;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
|
@ -72,14 +71,16 @@ public class WorldSetupScreen extends BCLibScreen {
|
|||
row = colNether.addRow();
|
||||
row.addSpacer(32);
|
||||
netherLegacy = row.addCheckbox(Component.translatable("title.screen.bclib.worldgen.legacy_square"),
|
||||
endVersion == BCLChunkGenerator.BIOME_SOURCE_VERSION_SQUARE,
|
||||
font,
|
||||
endVersion == BCLBiomeSource.BIOME_SOURCE_VERSION_SQUARE,
|
||||
1.0,
|
||||
GridLayout.GridValueType.PERCENTAGE,
|
||||
(state) -> {
|
||||
});
|
||||
bclibNether = mainSettingsRow.addCheckbox(Component.translatable(
|
||||
"title.screen.bclib.worldgen.custom_biome_source"),
|
||||
netherVersion != BCLChunkGenerator.BIOME_SOURCE_VERSION_VANILLA,
|
||||
font,
|
||||
netherVersion != BCLBiomeSource.BIOME_SOURCE_VERSION_VANILLA,
|
||||
1.0,
|
||||
GridLayout.GridValueType.PERCENTAGE,
|
||||
(state) -> {
|
||||
netherLegacy.setEnabled(state);
|
||||
});
|
||||
|
@ -95,15 +96,17 @@ public class WorldSetupScreen extends BCLibScreen {
|
|||
row.addSpacer(32);
|
||||
|
||||
endLegacy = row.addCheckbox(Component.translatable("title.screen.bclib.worldgen.legacy_square"),
|
||||
endVersion == BCLChunkGenerator.BIOME_SOURCE_VERSION_SQUARE,
|
||||
font,
|
||||
endVersion == BCLBiomeSource.BIOME_SOURCE_VERSION_SQUARE,
|
||||
1.0,
|
||||
GridLayout.GridValueType.PERCENTAGE,
|
||||
(state) -> {
|
||||
});
|
||||
|
||||
bclibEnd = mainSettingsRow.addCheckbox(Component.translatable(
|
||||
"title.screen.bclib.worldgen.custom_biome_source"),
|
||||
endVersion != BCLChunkGenerator.BIOME_SOURCE_VERSION_VANILLA,
|
||||
font,
|
||||
endVersion != BCLBiomeSource.BIOME_SOURCE_VERSION_VANILLA,
|
||||
1.0,
|
||||
GridLayout.GridValueType.PERCENTAGE,
|
||||
(state) -> {
|
||||
endLegacy.setEnabled(state);
|
||||
});
|
||||
|
@ -119,31 +122,43 @@ public class WorldSetupScreen extends BCLibScreen {
|
|||
}
|
||||
|
||||
private void updateSettings() {
|
||||
int endVersion = BCLChunkGenerator.DEFAULT_BIOME_SOURCE_VERSION;
|
||||
int endVersion = BCLBiomeSource.DEFAULT_BIOME_SOURCE_VERSION;
|
||||
if (bclibEnd.isChecked()) {
|
||||
if (endLegacy.isChecked()) endVersion = BCLChunkGenerator.BIOME_SOURCE_VERSION_SQUARE;
|
||||
else endVersion = BCLChunkGenerator.BIOME_SOURCE_VERSION_HEX;
|
||||
if (endLegacy.isChecked()) endVersion = BCLBiomeSource.BIOME_SOURCE_VERSION_SQUARE;
|
||||
else endVersion = BCLBiomeSource.BIOME_SOURCE_VERSION_HEX;
|
||||
} else {
|
||||
endVersion = BCLChunkGenerator.BIOME_SOURCE_VERSION_VANILLA;
|
||||
endVersion = BCLBiomeSource.BIOME_SOURCE_VERSION_VANILLA;
|
||||
}
|
||||
|
||||
int netherVersion = BCLChunkGenerator.DEFAULT_BIOME_SOURCE_VERSION;
|
||||
int netherVersion = BCLBiomeSource.DEFAULT_BIOME_SOURCE_VERSION;
|
||||
if (bclibNether.isChecked()) {
|
||||
if (netherLegacy.isChecked()) netherVersion = BCLChunkGenerator.BIOME_SOURCE_VERSION_SQUARE;
|
||||
else netherVersion = BCLChunkGenerator.BIOME_SOURCE_VERSION_HEX;
|
||||
if (netherLegacy.isChecked()) netherVersion = BCLBiomeSource.BIOME_SOURCE_VERSION_SQUARE;
|
||||
else netherVersion = BCLBiomeSource.BIOME_SOURCE_VERSION_HEX;
|
||||
} else {
|
||||
netherVersion = BCLChunkGenerator.BIOME_SOURCE_VERSION_VANILLA;
|
||||
netherVersion = BCLBiomeSource.BIOME_SOURCE_VERSION_VANILLA;
|
||||
}
|
||||
|
||||
BCLib.LOGGER.info("Custom World Versions: end=" + endVersion + ", nether=" + netherVersion);
|
||||
updateConfiguration(LevelStem.END, BuiltinDimensionTypes.END, endVersion);
|
||||
updateConfiguration(LevelStem.NETHER, BuiltinDimensionTypes.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);
|
||||
};
|
||||
private void updateConfiguration(
|
||||
ResourceKey<LevelStem> dimensionKey,
|
||||
ResourceKey<DimensionType> dimensionTypeKey,
|
||||
int biomeSourceVersion
|
||||
) {
|
||||
createWorldScreen.worldGenSettingsComponent.updateSettings(
|
||||
(registryAccess, worldGenSettings) -> WorldPresets.replaceGenerator(
|
||||
dimensionKey,
|
||||
dimensionTypeKey,
|
||||
biomeSourceVersion,
|
||||
registryAccess,
|
||||
worldGenSettings
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@ import net.minecraft.world.level.levelgen.presets.WorldPresets;
|
|||
import net.minecraft.world.level.levelgen.structure.StructureSet;
|
||||
import net.minecraft.world.level.levelgen.synth.NormalNoise;
|
||||
|
||||
import org.betterx.bclib.presets.worldgen.BCLChunkGenerator;
|
||||
import org.betterx.bclib.world.generator.BCLBiomeSource;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
|
@ -82,14 +82,14 @@ public abstract class WorldPresetsBootstrapMixin {
|
|||
this.structureSets,
|
||||
this.noises,
|
||||
this.netherNoiseSettings,
|
||||
Optional.of(BCLChunkGenerator.BIOME_SOURCE_VERSION_SQUARE)),
|
||||
Optional.of(BCLBiomeSource.BIOME_SOURCE_VERSION_SQUARE)),
|
||||
LevelStem.END,
|
||||
org.betterx.bclib.presets.worldgen.WorldPresets.getBCLEndLevelStem(this.biomes,
|
||||
this.endDimensionType,
|
||||
this.structureSets,
|
||||
this.noises,
|
||||
this.endNoiseSettings,
|
||||
Optional.of(BCLChunkGenerator.BIOME_SOURCE_VERSION_SQUARE))
|
||||
Optional.of(BCLBiomeSource.BIOME_SOURCE_VERSION_SQUARE))
|
||||
), 0
|
||||
);
|
||||
|
||||
|
|
|
@ -26,11 +26,6 @@ import org.betterx.bclib.world.generator.BCLBiomeSource;
|
|||
import java.util.Optional;
|
||||
|
||||
public class BCLChunkGenerator extends NoiseBasedChunkGenerator {
|
||||
public static int BIOME_SOURCE_VERSION_NONE = -1;
|
||||
public static int BIOME_SOURCE_VERSION_VANILLA = 0;
|
||||
public static int BIOME_SOURCE_VERSION_SQUARE = 17;
|
||||
public static int BIOME_SOURCE_VERSION_HEX = 18;
|
||||
public static int DEFAULT_BIOME_SOURCE_VERSION = BIOME_SOURCE_VERSION_HEX;
|
||||
|
||||
private static String TAG_GENERATOR = "generator";
|
||||
private static final String TAG_VERSION = "version";
|
||||
|
@ -81,13 +76,8 @@ public class BCLChunkGenerator extends NoiseBasedChunkGenerator {
|
|||
}
|
||||
|
||||
public static int getBiomeVersionForGenerator(ChunkGenerator generator) {
|
||||
if (generator == null) return BIOME_SOURCE_VERSION_NONE;
|
||||
|
||||
if (generator.getBiomeSource() instanceof BCLBiomeSource bcl) {
|
||||
return bcl.biomeSourceVersion;
|
||||
} else {
|
||||
return BIOME_SOURCE_VERSION_VANILLA;
|
||||
}
|
||||
if (generator == null) return BCLBiomeSource.getVersionBiomeSource(null);
|
||||
return BCLBiomeSource.getVersionBiomeSource(generator.getBiomeSource());
|
||||
}
|
||||
|
||||
public static Optional<Holder<LevelStem>> referenceStemForVersion(
|
||||
|
@ -99,13 +89,13 @@ public class BCLChunkGenerator extends NoiseBasedChunkGenerator {
|
|||
boolean generateBonusChest
|
||||
) {
|
||||
final WorldGenSettings referenceSettings;
|
||||
if (biomeSourceVersion == BIOME_SOURCE_VERSION_VANILLA) {
|
||||
if (biomeSourceVersion == BCLBiomeSource.BIOME_SOURCE_VERSION_VANILLA) {
|
||||
referenceSettings = net.minecraft.world.level.levelgen.presets.WorldPresets.createNormalWorldFromPreset(
|
||||
registryAccess,
|
||||
seed,
|
||||
generateStructures,
|
||||
generateBonusChest);
|
||||
} else if (biomeSourceVersion == BIOME_SOURCE_VERSION_SQUARE) {
|
||||
} else if (biomeSourceVersion == BCLBiomeSource.BIOME_SOURCE_VERSION_SQUARE) {
|
||||
referenceSettings = WorldPresets.createWorldFromPreset(
|
||||
WorldPresets.BCL_WORLD_17,
|
||||
registryAccess,
|
||||
|
@ -124,7 +114,7 @@ public class BCLChunkGenerator extends NoiseBasedChunkGenerator {
|
|||
|
||||
public static int getBiomeVersionForCurrentWorld(ResourceKey<LevelStem> key) {
|
||||
final CompoundTag settingsNbt = getSettingsNbt();
|
||||
if (!settingsNbt.contains(key.location().toString())) return DEFAULT_BIOME_SOURCE_VERSION;
|
||||
if (!settingsNbt.contains(key.location().toString())) return BCLBiomeSource.DEFAULT_BIOME_SOURCE_VERSION;
|
||||
return settingsNbt.getInt(key.location().toString());
|
||||
}
|
||||
|
||||
|
@ -155,7 +145,7 @@ public class BCLChunkGenerator extends NoiseBasedChunkGenerator {
|
|||
|
||||
if (settingsNbt.size() == 0) {
|
||||
BCLib.LOGGER.info("Found World without generator Settings. Setting up data...");
|
||||
int biomeSourceVersion = DEFAULT_BIOME_SOURCE_VERSION;
|
||||
int biomeSourceVersion = BCLBiomeSource.DEFAULT_BIOME_SOURCE_VERSION;
|
||||
|
||||
final CompoundTag bclRoot = WorldDataAPI.getRootTag(BCLib.MOD_ID);
|
||||
|
||||
|
@ -167,15 +157,15 @@ public class BCLChunkGenerator extends NoiseBasedChunkGenerator {
|
|||
|
||||
if (isPre18) {
|
||||
BCLib.LOGGER.info("World was create pre 1.18!");
|
||||
biomeSourceVersion = BIOME_SOURCE_VERSION_SQUARE;
|
||||
biomeSourceVersion = BCLBiomeSource.BIOME_SOURCE_VERSION_SQUARE;
|
||||
}
|
||||
|
||||
if (WorldDataAPI.hasMod("betternether")) {
|
||||
BCLib.LOGGER.info("Found Data from BetterNether, using for migration.");
|
||||
final CompoundTag bnRoot = WorldDataAPI.getRootTag("betternether");
|
||||
biomeSourceVersion = "1.17".equals(bnRoot.getString(TAG_BN_GEN_VERSION))
|
||||
? BIOME_SOURCE_VERSION_SQUARE
|
||||
: BIOME_SOURCE_VERSION_HEX;
|
||||
? BCLBiomeSource.BIOME_SOURCE_VERSION_SQUARE
|
||||
: BCLBiomeSource.BIOME_SOURCE_VERSION_HEX;
|
||||
}
|
||||
|
||||
BCLib.LOGGER.info("Set world to BiomeSource Version " + biomeSourceVersion);
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package org.betterx.bclib.presets.worldgen;
|
||||
|
||||
import net.minecraft.core.Holder;
|
||||
import net.minecraft.core.MappedRegistry;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.core.RegistryAccess;
|
||||
import net.minecraft.data.BuiltinRegistries;
|
||||
|
@ -9,6 +10,7 @@ import net.minecraft.resources.ResourceLocation;
|
|||
import net.minecraft.tags.WorldPresetTags;
|
||||
import net.minecraft.util.RandomSource;
|
||||
import net.minecraft.world.level.biome.Biome;
|
||||
import net.minecraft.world.level.chunk.ChunkGenerator;
|
||||
import net.minecraft.world.level.dimension.DimensionType;
|
||||
import net.minecraft.world.level.dimension.LevelStem;
|
||||
import net.minecraft.world.level.levelgen.NoiseGeneratorSettings;
|
||||
|
@ -18,6 +20,7 @@ import net.minecraft.world.level.levelgen.structure.StructureSet;
|
|||
import net.minecraft.world.level.levelgen.synth.NormalNoise;
|
||||
|
||||
import com.mojang.datafixers.util.Pair;
|
||||
import com.mojang.serialization.Lifecycle;
|
||||
import org.betterx.bclib.BCLib;
|
||||
import org.betterx.bclib.api.tag.TagAPI;
|
||||
import org.betterx.bclib.api.tag.TagType;
|
||||
|
@ -129,6 +132,63 @@ public class WorldPresets {
|
|||
return createDefaultWorldFromPreset(registryAccess, RandomSource.create().nextLong());
|
||||
}
|
||||
|
||||
public static WorldGenSettings replaceGenerator(
|
||||
ResourceKey<LevelStem> dimensionKey,
|
||||
ResourceKey<DimensionType> dimensionTypeKey,
|
||||
int biomeSourceVersion,
|
||||
RegistryAccess registryAccess,
|
||||
WorldGenSettings worldGenSettings
|
||||
) {
|
||||
Optional<Holder<LevelStem>> oLevelStem = BCLChunkGenerator.referenceStemForVersion(
|
||||
dimensionKey,
|
||||
biomeSourceVersion,
|
||||
registryAccess,
|
||||
worldGenSettings.seed(),
|
||||
worldGenSettings.generateStructures(),
|
||||
worldGenSettings.generateStructures()
|
||||
);
|
||||
|
||||
Registry<DimensionType> registry = registryAccess.registryOrThrow(Registry.DIMENSION_TYPE_REGISTRY);
|
||||
Registry<LevelStem> registry2 = withDimension(dimensionKey, dimensionTypeKey, registry,
|
||||
worldGenSettings.dimensions(),
|
||||
oLevelStem.map(l -> l.value().generator()).orElseThrow());
|
||||
return new WorldGenSettings(worldGenSettings.seed(),
|
||||
worldGenSettings.generateStructures(),
|
||||
worldGenSettings.generateBonusChest(),
|
||||
registry2);
|
||||
}
|
||||
|
||||
public static Registry<LevelStem> withDimension(ResourceKey<LevelStem> dimensionKey,
|
||||
ResourceKey<DimensionType> dimensionTypeKey,
|
||||
Registry<DimensionType> registry,
|
||||
Registry<LevelStem> registry2,
|
||||
ChunkGenerator chunkGenerator) {
|
||||
LevelStem levelStem = registry2.get(dimensionKey);
|
||||
Holder<DimensionType> holder = levelStem == null
|
||||
? registry.getOrCreateHolderOrThrow(dimensionTypeKey)
|
||||
: levelStem.typeHolder();
|
||||
return withDimension(dimensionKey, registry2, holder, chunkGenerator);
|
||||
}
|
||||
|
||||
public static Registry<LevelStem> withDimension(ResourceKey<LevelStem> dimensionKey, Registry<LevelStem> registry,
|
||||
Holder<DimensionType> holder,
|
||||
ChunkGenerator chunkGenerator) {
|
||||
MappedRegistry<LevelStem> writableRegistry = new MappedRegistry<LevelStem>(Registry.LEVEL_STEM_REGISTRY,
|
||||
Lifecycle.experimental(),
|
||||
null);
|
||||
writableRegistry.register(dimensionKey,
|
||||
new LevelStem(holder, chunkGenerator),
|
||||
Lifecycle.stable());
|
||||
for (Map.Entry<ResourceKey<LevelStem>, LevelStem> entry : registry.entrySet()) {
|
||||
ResourceKey<LevelStem> resourceKey = entry.getKey();
|
||||
if (resourceKey == dimensionKey) continue;
|
||||
writableRegistry.register(resourceKey,
|
||||
entry.getValue(),
|
||||
registry.lifecycle(entry.getValue()));
|
||||
}
|
||||
return writableRegistry;
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a custom WorldPreset (with custom rules and behaviour)
|
||||
* <p>
|
||||
|
|
|
@ -6,12 +6,16 @@ import net.minecraft.world.level.biome.Biome;
|
|||
import net.minecraft.world.level.biome.BiomeSource;
|
||||
|
||||
import org.betterx.bclib.api.biomes.BiomeAPI;
|
||||
import org.betterx.bclib.presets.worldgen.BCLChunkGenerator;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
public abstract class BCLBiomeSource extends BiomeSource {
|
||||
public static int BIOME_SOURCE_VERSION_NONE = -1;
|
||||
public static int BIOME_SOURCE_VERSION_VANILLA = 0;
|
||||
public static int BIOME_SOURCE_VERSION_SQUARE = 17;
|
||||
public static int BIOME_SOURCE_VERSION_HEX = 18;
|
||||
public static int DEFAULT_BIOME_SOURCE_VERSION = BIOME_SOURCE_VERSION_HEX;
|
||||
protected final Registry<Biome> biomeRegistry;
|
||||
protected long currentSeed;
|
||||
|
||||
|
@ -29,7 +33,7 @@ public abstract class BCLBiomeSource extends BiomeSource {
|
|||
super(preInit(biomeRegistry, list));
|
||||
|
||||
this.biomeRegistry = biomeRegistry;
|
||||
this.biomeSourceVersion = biomeSourceVersion.orElse(BCLChunkGenerator.DEFAULT_BIOME_SOURCE_VERSION);
|
||||
this.biomeSourceVersion = biomeSourceVersion.orElse(DEFAULT_BIOME_SOURCE_VERSION);
|
||||
this.currentSeed = seed;
|
||||
|
||||
System.out.println(this + " with Registry: " + biomeRegistry.getClass().getName() + "@" + Integer.toHexString(
|
||||
|
@ -52,4 +56,14 @@ public abstract class BCLBiomeSource extends BiomeSource {
|
|||
}
|
||||
|
||||
protected abstract void onInitMap(long newSeed);
|
||||
|
||||
public static int getVersionBiomeSource(BiomeSource biomeSource) {
|
||||
if (biomeSource == null) return BCLBiomeSource.BIOME_SOURCE_VERSION_NONE;
|
||||
|
||||
if (biomeSource instanceof BCLBiomeSource bcl) {
|
||||
return bcl.biomeSourceVersion;
|
||||
} else {
|
||||
return BCLBiomeSource.BIOME_SOURCE_VERSION_VANILLA;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,7 +22,6 @@ import org.betterx.bclib.config.ConfigKeeper.StringArrayEntry;
|
|||
import org.betterx.bclib.config.Configs;
|
||||
import org.betterx.bclib.interfaces.BiomeMap;
|
||||
import org.betterx.bclib.noise.OpenSimplexNoise;
|
||||
import org.betterx.bclib.presets.worldgen.BCLChunkGenerator;
|
||||
import org.betterx.bclib.world.biomes.BCLBiome;
|
||||
import org.betterx.bclib.world.generator.map.hex.HexBiomeMap;
|
||||
import org.betterx.bclib.world.generator.map.square.SquareBiomeMap;
|
||||
|
@ -187,7 +186,7 @@ public class BCLibEndBiomeSource extends BCLBiomeSource {
|
|||
|
||||
@Override
|
||||
protected void onInitMap(long seed) {
|
||||
if ((biomeSourceVersion != BCLChunkGenerator.BIOME_SOURCE_VERSION_HEX)) {
|
||||
if ((biomeSourceVersion != BCLBiomeSource.BIOME_SOURCE_VERSION_HEX)) {
|
||||
this.mapLand = new SquareBiomeMap(seed,
|
||||
GeneratorOptions.getBiomeSizeEndLand(),
|
||||
endLandBiomePicker);
|
||||
|
|
|
@ -19,7 +19,6 @@ import org.betterx.bclib.api.biomes.BiomeAPI;
|
|||
import org.betterx.bclib.config.ConfigKeeper.StringArrayEntry;
|
||||
import org.betterx.bclib.config.Configs;
|
||||
import org.betterx.bclib.interfaces.BiomeMap;
|
||||
import org.betterx.bclib.presets.worldgen.BCLChunkGenerator;
|
||||
import org.betterx.bclib.world.biomes.BCLBiome;
|
||||
import org.betterx.bclib.world.generator.map.MapStack;
|
||||
import org.betterx.bclib.world.generator.map.hex.HexBiomeMap;
|
||||
|
@ -156,7 +155,7 @@ public class BCLibNetherBiomeSource extends BCLBiomeSource {
|
|||
|
||||
@Override
|
||||
protected void onInitMap(long seed) {
|
||||
TriFunction<Long, Integer, BiomePicker, BiomeMap> mapConstructor = (biomeSourceVersion != BCLChunkGenerator.BIOME_SOURCE_VERSION_HEX)
|
||||
TriFunction<Long, Integer, BiomePicker, BiomeMap> mapConstructor = (biomeSourceVersion != BCLBiomeSource.BIOME_SOURCE_VERSION_HEX)
|
||||
? SquareBiomeMap::new
|
||||
: HexBiomeMap::new;
|
||||
if (worldHeight > 128 && GeneratorOptions.useVerticalBiomes()) {
|
||||
|
|
|
@ -10,3 +10,6 @@ accessible class net/minecraft/world/level/levelgen/SurfaceRules$LazyCondition
|
|||
accessible class net/minecraft/world/level/levelgen/SurfaceRules$SequenceRuleSource
|
||||
accessible class net/minecraft/world/level/levelgen/presets/WorldPresets$Bootstrap
|
||||
extendable class net/minecraft/world/level/levelgen/NoiseBasedChunkGenerator
|
||||
|
||||
#Methods
|
||||
accessible method net/minecraft/client/gui/screens/worldselection/WorldGenSettingsComponent updateSettings (Lnet/minecraft/client/gui/screens/worldselection/WorldCreationContext$Updater;)V
|
Loading…
Add table
Add a link
Reference in a new issue