Removed WorldPresetSettings
This commit is contained in:
parent
877691011f
commit
fb19ebaae6
23 changed files with 291 additions and 543 deletions
|
@ -10,7 +10,6 @@ import org.betterx.worlds.together.biomesource.MergeableBiomeSource;
|
|||
import org.betterx.worlds.together.chunkgenerator.EnforceableChunkGenerator;
|
||||
import org.betterx.worlds.together.chunkgenerator.InjectableSurfaceRules;
|
||||
import org.betterx.worlds.together.chunkgenerator.RestorableBiomeSource;
|
||||
import org.betterx.worlds.together.levelgen.WorldGenUtil;
|
||||
|
||||
import com.mojang.serialization.Codec;
|
||||
import com.mojang.serialization.codecs.RecordCodecBuilder;
|
||||
|
@ -109,9 +108,10 @@ public class BCLChunkGenerator extends NoiseBasedChunkGenerator implements Resto
|
|||
public void restoreInitialBiomeSource(ResourceKey<LevelStem> dimensionKey) {
|
||||
if (initialBiomeSource != getBiomeSource()) {
|
||||
if (this instanceof ChunkGeneratorAccessor acc) {
|
||||
BiomeSource bs = WorldGenUtil.getWorldSettings()
|
||||
.addDatapackBiomes(initialBiomeSource, getBiomeSource().possibleBiomes());
|
||||
acc.bcl_setBiomeSource(bs);
|
||||
if (initialBiomeSource instanceof MergeableBiomeSource bs) {
|
||||
acc.bcl_setBiomeSource(bs.mergeWithBiomeSource(getBiomeSource()));
|
||||
}
|
||||
|
||||
rebuildFeaturesPerStep(getBiomeSource());
|
||||
}
|
||||
}
|
||||
|
@ -174,7 +174,7 @@ public class BCLChunkGenerator extends NoiseBasedChunkGenerator implements Resto
|
|||
} else {
|
||||
bs = referenceGenerator.getBiomeSource();
|
||||
}
|
||||
|
||||
|
||||
InternalBiomeAPI.applyModifications(bs, dimensionKey);
|
||||
referenceGenerator = new BCLChunkGenerator(
|
||||
generator.bclib_getStructureSetsRegistry(),
|
||||
|
|
|
@ -8,9 +8,7 @@ import org.betterx.bclib.config.ConfigKeeper.StringArrayEntry;
|
|||
import org.betterx.bclib.config.Configs;
|
||||
import org.betterx.bclib.interfaces.BiomeMap;
|
||||
import org.betterx.bclib.interfaces.TheEndBiomeDataAccessor;
|
||||
import org.betterx.bclib.presets.worldgen.BCLWorldPresetSettings;
|
||||
import org.betterx.worlds.together.biomesource.BiomeSourceWithConfig;
|
||||
import org.betterx.worlds.together.levelgen.WorldGenUtil;
|
||||
|
||||
import com.mojang.serialization.Codec;
|
||||
import com.mojang.serialization.codecs.RecordCodecBuilder;
|
||||
|
@ -158,12 +156,7 @@ public class BCLibEndBiomeSource extends BCLBiomeSource implements BiomeSourceWi
|
|||
this.centerBiome = biomeRegistry.getOrCreateHolderOrThrow(Biomes.THE_END);
|
||||
this.barrens = biomeRegistry.getOrCreateHolderOrThrow(Biomes.END_BARRENS);
|
||||
|
||||
if (WorldGenUtil.getWorldSettings() instanceof BCLWorldPresetSettings settings
|
||||
&& !settings.useEndTerrainGenerator) {
|
||||
this.endLandFunction = null;
|
||||
} else {
|
||||
this.endLandFunction = GeneratorOptions.getEndLandFunction();
|
||||
}
|
||||
this.endLandFunction = GeneratorOptions.getEndLandFunction();
|
||||
this.pos = new Point();
|
||||
|
||||
if (initMaps) {
|
||||
|
|
|
@ -216,7 +216,7 @@ public class BCLibNetherBiomeSource extends BCLBiomeSource implements BiomeSourc
|
|||
|
||||
@Override
|
||||
public void setTogetherConfig(BCLNetherBiomeSourceConfig newConfig) {
|
||||
this.config = config;
|
||||
this.config = newConfig;
|
||||
initMap(currentSeed);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,6 +16,12 @@ import java.util.Objects;
|
|||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class BCLEndBiomeSourceConfig implements BiomeSourceConfig<BCLibEndBiomeSource> {
|
||||
public static final BCLEndBiomeSourceConfig VANILLA = new BCLEndBiomeSourceConfig(
|
||||
EndBiomeMapType.VANILLA,
|
||||
EndBiomeGeneratorType.VANILLA,
|
||||
true,
|
||||
4096
|
||||
);
|
||||
public static final BCLEndBiomeSourceConfig MINECRAFT_17 = new BCLEndBiomeSourceConfig(
|
||||
EndBiomeMapType.SQUARE,
|
||||
EndBiomeGeneratorType.PAULEVS,
|
||||
|
|
|
@ -16,6 +16,9 @@ import java.util.Objects;
|
|||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class BCLNetherBiomeSourceConfig implements BiomeSourceConfig<BCLibNetherBiomeSource> {
|
||||
public static final BCLNetherBiomeSourceConfig VANILLA = new BCLNetherBiomeSourceConfig(
|
||||
NetherBiomeMapType.VANILLA
|
||||
);
|
||||
public static final BCLNetherBiomeSourceConfig MINECRAFT_17 = new BCLNetherBiomeSourceConfig(
|
||||
NetherBiomeMapType.SQUARE
|
||||
);
|
||||
|
|
|
@ -10,16 +10,17 @@ import org.betterx.bclib.api.v2.levelgen.biomes.InternalBiomeAPI;
|
|||
import org.betterx.bclib.registry.PresetsRegistry;
|
||||
import org.betterx.worlds.together.world.event.WorldEvents;
|
||||
import org.betterx.worlds.together.worldPreset.TogetherWorldPreset;
|
||||
import org.betterx.worlds.together.worldPreset.settings.WorldPresetSettings;
|
||||
|
||||
import net.minecraft.core.Holder;
|
||||
import net.minecraft.core.RegistryAccess;
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
import net.minecraft.world.level.chunk.ChunkGenerator;
|
||||
import net.minecraft.world.level.dimension.LevelStem;
|
||||
import net.minecraft.world.level.levelgen.WorldGenSettings;
|
||||
import net.minecraft.world.level.levelgen.presets.WorldPreset;
|
||||
import net.minecraft.world.level.storage.LevelStorageSource;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
|
@ -89,21 +90,20 @@ public class LevelGenEvents {
|
|||
InternalBiomeAPI.initRegistry(a);
|
||||
}
|
||||
|
||||
public static WorldPresetSettings prepareWorld(
|
||||
public static void prepareWorld(
|
||||
LevelStorageSource.LevelStorageAccess storageAccess,
|
||||
WorldPresetSettings settings,
|
||||
Map<ResourceKey<LevelStem>, ChunkGenerator> dimensions,
|
||||
boolean isNewWorld
|
||||
) {
|
||||
setupWorld();
|
||||
if (isNewWorld) {
|
||||
DataFixerAPI.initializePatchData();
|
||||
}
|
||||
return settings;
|
||||
}
|
||||
|
||||
public static WorldPresetSettings prepareServerWorld(
|
||||
public static void prepareServerWorld(
|
||||
LevelStorageSource.LevelStorageAccess storageAccess,
|
||||
WorldPresetSettings settings,
|
||||
Map<ResourceKey<LevelStem>, ChunkGenerator> dimensions,
|
||||
boolean isNewWorld
|
||||
) {
|
||||
setupWorld();
|
||||
|
@ -113,9 +113,6 @@ public class LevelGenEvents {
|
|||
} else {
|
||||
DataFixerAPI.fixData(storageAccess, false, (didFix) -> {/* not called when showUI==false */});
|
||||
}
|
||||
|
||||
|
||||
return settings;
|
||||
}
|
||||
|
||||
public static void onWorldLoad() {
|
||||
|
|
|
@ -7,13 +7,11 @@ import org.betterx.bclib.api.v2.generator.BCLibEndBiomeSource;
|
|||
import org.betterx.bclib.api.v2.generator.BCLibNetherBiomeSource;
|
||||
import org.betterx.bclib.api.v2.generator.config.BCLEndBiomeSourceConfig;
|
||||
import org.betterx.bclib.api.v2.generator.config.BCLNetherBiomeSourceConfig;
|
||||
import org.betterx.bclib.presets.worldgen.BCLWorldPresetSettings;
|
||||
import org.betterx.bclib.registry.PresetsRegistry;
|
||||
import org.betterx.worlds.together.levelgen.WorldGenUtil;
|
||||
import org.betterx.worlds.together.util.ModUtil;
|
||||
import org.betterx.worlds.together.world.WorldConfig;
|
||||
import org.betterx.worlds.together.worldPreset.TogetherWorldPreset;
|
||||
import org.betterx.worlds.together.worldPreset.settings.WorldPresetSettings;
|
||||
|
||||
import com.mojang.serialization.Lifecycle;
|
||||
import net.minecraft.core.Holder;
|
||||
|
@ -26,6 +24,7 @@ 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.WorldGenSettings;
|
||||
import net.minecraft.world.level.levelgen.presets.WorldPreset;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
@ -111,23 +110,23 @@ public class LevelGenUtil {
|
|||
);
|
||||
}
|
||||
|
||||
public static WorldGenSettings replaceStem(
|
||||
ResourceKey<LevelStem> dimensionKey,
|
||||
WorldGenSettings worldGenSettings,
|
||||
LevelStem levelStem
|
||||
) {
|
||||
Registry<LevelStem> newDimensions = withDimension(
|
||||
dimensionKey,
|
||||
worldGenSettings.dimensions(),
|
||||
levelStem
|
||||
);
|
||||
return new WorldGenSettings(
|
||||
worldGenSettings.seed(),
|
||||
worldGenSettings.generateStructures(),
|
||||
worldGenSettings.generateBonusChest(),
|
||||
newDimensions
|
||||
);
|
||||
}
|
||||
// public static WorldGenSettings replaceStem(
|
||||
// ResourceKey<LevelStem> dimensionKey,
|
||||
// WorldGenSettings worldGenSettings,
|
||||
// LevelStem levelStem
|
||||
// ) {
|
||||
// Registry<LevelStem> newDimensions = withDimension(
|
||||
// dimensionKey,
|
||||
// worldGenSettings.dimensions(),
|
||||
// levelStem
|
||||
// );
|
||||
// return new WorldGenSettings(
|
||||
// worldGenSettings.seed(),
|
||||
// worldGenSettings.generateStructures(),
|
||||
// worldGenSettings.generateBonusChest(),
|
||||
// newDimensions
|
||||
// );
|
||||
// }
|
||||
|
||||
public static Registry<LevelStem> withDimension(
|
||||
ResourceKey<LevelStem> dimensionKey,
|
||||
|
@ -211,11 +210,11 @@ public class LevelGenUtil {
|
|||
return referenceSettings.dimensions().getHolder(dimensionKey);
|
||||
}
|
||||
|
||||
public static int getBiomeVersionForCurrentWorld(ResourceKey<LevelStem> key) {
|
||||
final CompoundTag settingsNbt = WorldGenUtil.getSettingsNbt();
|
||||
if (!settingsNbt.contains(key.location().toString())) return BCLBiomeSource.DEFAULT_BIOME_SOURCE_VERSION;
|
||||
return settingsNbt.getInt(key.location().toString());
|
||||
}
|
||||
// public static int getBiomeVersionForCurrentWorld(ResourceKey<LevelStem> key) {
|
||||
// final CompoundTag settingsNbt = WorldGenUtil.getSettingsNbt();
|
||||
// if (!settingsNbt.contains(key.location().toString())) return BCLBiomeSource.DEFAULT_BIOME_SOURCE_VERSION;
|
||||
// return settingsNbt.getInt(key.location().toString());
|
||||
// }
|
||||
|
||||
// private static int getDimensionVersion(
|
||||
// WorldGenSettings settings,
|
||||
|
@ -242,7 +241,7 @@ public class LevelGenUtil {
|
|||
|
||||
if (settingsNbt.size() == 0) {
|
||||
BCLib.LOGGER.info("Found World without generator Settings. Setting up data...");
|
||||
int biomeSourceVersion = BCLBiomeSource.DEFAULT_BIOME_SOURCE_VERSION;
|
||||
ResourceKey<WorldPreset> biomeSourceVersion = PresetsRegistry.BCL_WORLD;
|
||||
|
||||
final CompoundTag bclRoot = WorldConfig.getRootTag(BCLib.MOD_ID);
|
||||
|
||||
|
@ -254,32 +253,32 @@ public class LevelGenUtil {
|
|||
|
||||
if (isPre18) {
|
||||
BCLib.LOGGER.info("World was create pre 1.18!");
|
||||
biomeSourceVersion = BCLBiomeSource.BIOME_SOURCE_VERSION_SQUARE;
|
||||
biomeSourceVersion = PresetsRegistry.BCL_WORLD_17;
|
||||
}
|
||||
|
||||
if (WorldConfig.hasMod("betternether")) {
|
||||
BCLib.LOGGER.info("Found Data from BetterNether, using for migration.");
|
||||
final CompoundTag bnRoot = WorldConfig.getRootTag("betternether");
|
||||
biomeSourceVersion = "1.17".equals(bnRoot.getString(TAG_BN_GEN_VERSION))
|
||||
? BCLBiomeSource.BIOME_SOURCE_VERSION_SQUARE
|
||||
: BCLBiomeSource.BIOME_SOURCE_VERSION_HEX;
|
||||
? PresetsRegistry.BCL_WORLD_17
|
||||
: PresetsRegistry.BCL_WORLD;
|
||||
}
|
||||
|
||||
BCLib.LOGGER.info("Set world to BiomeSource Version " + biomeSourceVersion);
|
||||
TogetherWorldPreset.writeWorldPresetSettings(new BCLWorldPresetSettings(
|
||||
biomeSourceVersion,
|
||||
biomeSourceVersion,
|
||||
true,
|
||||
true
|
||||
));
|
||||
Registry<LevelStem> dimensions = TogetherWorldPreset.getDimensions(biomeSourceVersion);
|
||||
if (dimensions != null) {
|
||||
BCLib.LOGGER.info("Set world to BiomeSource Version " + biomeSourceVersion);
|
||||
TogetherWorldPreset.writeWorldPresetSettings(dimensions);
|
||||
} else {
|
||||
BCLib.LOGGER.error("Failed to set world to BiomeSource Version " + biomeSourceVersion);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Replace by {@link WorldGenUtil#getWorldSettings()}
|
||||
*/
|
||||
@Deprecated(forRemoval = true)
|
||||
public static WorldPresetSettings getWorldSettings() {
|
||||
return WorldGenUtil.getWorldSettings();
|
||||
}
|
||||
// /**
|
||||
// * @deprecated Replace by {@link WorldGenUtil#getWorldSettings()}
|
||||
// */
|
||||
// @Deprecated(forRemoval = true)
|
||||
// public static WorldPresetSettings getWorldSettings() {
|
||||
// return null;
|
||||
// }
|
||||
}
|
||||
|
|
|
@ -1,11 +1,13 @@
|
|||
package org.betterx.bclib.client.gui.screens;
|
||||
|
||||
import org.betterx.bclib.BCLib;
|
||||
import org.betterx.bclib.api.v2.generator.BCLBiomeSource;
|
||||
import org.betterx.bclib.api.v2.generator.BCLibEndBiomeSource;
|
||||
import org.betterx.bclib.api.v2.generator.BCLibNetherBiomeSource;
|
||||
import org.betterx.bclib.api.v2.generator.config.BCLEndBiomeSourceConfig;
|
||||
import org.betterx.bclib.api.v2.generator.config.BCLNetherBiomeSourceConfig;
|
||||
import org.betterx.bclib.api.v2.levelgen.LevelGenUtil;
|
||||
import org.betterx.bclib.client.gui.gridlayout.GridCheckboxCell;
|
||||
import org.betterx.bclib.client.gui.gridlayout.GridLayout;
|
||||
import org.betterx.bclib.presets.worldgen.BCLWorldPresetSettings;
|
||||
import org.betterx.bclib.registry.PresetsRegistry;
|
||||
import org.betterx.worlds.together.worldPreset.TogetherWorldPreset;
|
||||
import org.betterx.worlds.together.worldPreset.WorldGenSettingsComponentAccessor;
|
||||
|
||||
|
@ -15,13 +17,16 @@ import net.minecraft.core.Holder;
|
|||
import net.minecraft.network.chat.CommonComponents;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
import net.minecraft.world.level.chunk.ChunkGenerator;
|
||||
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.presets.WorldPresets;
|
||||
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.api.Environment;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
|
@ -46,24 +51,25 @@ public class WorldSetupScreen extends BCLibScreen {
|
|||
|
||||
@Override
|
||||
protected void initLayout() {
|
||||
final int netherVersion;
|
||||
final int endVersion;
|
||||
final boolean customEndGen;
|
||||
final boolean haveEndVoid;
|
||||
BCLEndBiomeSourceConfig endConfig = BCLEndBiomeSourceConfig.VANILLA;
|
||||
BCLNetherBiomeSourceConfig netherConfig = BCLNetherBiomeSourceConfig.VANILLA;
|
||||
if (createWorldScreen.worldGenSettingsComponent instanceof WorldGenSettingsComponentAccessor acc
|
||||
&& acc.bcl_getPreset()
|
||||
.isPresent() && acc.bcl_getPreset()
|
||||
.get()
|
||||
.value() instanceof TogetherWorldPreset wp
|
||||
&& wp.settings instanceof BCLWorldPresetSettings settings) {
|
||||
netherVersion = settings.netherVersion;
|
||||
endVersion = settings.endVersion;
|
||||
customEndGen = settings.useEndTerrainGenerator;
|
||||
haveEndVoid = settings.generateEndVoid;
|
||||
} else {
|
||||
throw new IllegalStateException("The WorldSetup Screen is only valid for BetterX Presets.");
|
||||
.value() instanceof TogetherWorldPreset wp) {
|
||||
|
||||
LevelStem endStem = wp.getDimension(LevelStem.END);
|
||||
if (endStem != null && endStem.generator().getBiomeSource() instanceof BCLibEndBiomeSource bs) {
|
||||
endConfig = bs.getTogetherConfig();
|
||||
}
|
||||
LevelStem netherStem = wp.getDimension(LevelStem.NETHER);
|
||||
if (netherStem != null && netherStem.generator().getBiomeSource() instanceof BCLibNetherBiomeSource bs) {
|
||||
netherConfig = bs.getTogetherConfig();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
final int BUTTON_HEIGHT = 20;
|
||||
grid.addSpacerRow(20);
|
||||
|
||||
|
@ -82,7 +88,7 @@ public class WorldSetupScreen extends BCLibScreen {
|
|||
row.addSpacer(20);
|
||||
netherLegacy = row.addCheckbox(
|
||||
Component.translatable("title.screen.bclib.worldgen.legacy_square"),
|
||||
endVersion == BCLBiomeSource.BIOME_SOURCE_VERSION_SQUARE,
|
||||
netherConfig.mapVersion == BCLNetherBiomeSourceConfig.NetherBiomeMapType.SQUARE,
|
||||
1.0,
|
||||
GridLayout.GridValueType.PERCENTAGE,
|
||||
(state) -> {
|
||||
|
@ -91,7 +97,7 @@ public class WorldSetupScreen extends BCLibScreen {
|
|||
bclibNether = mainSettingsRow.addCheckbox(
|
||||
Component.translatable(
|
||||
"title.screen.bclib.worldgen.custom_biome_source"),
|
||||
netherVersion != BCLBiomeSource.BIOME_SOURCE_VERSION_VANILLA,
|
||||
netherConfig.mapVersion != BCLNetherBiomeSourceConfig.NetherBiomeMapType.VANILLA,
|
||||
1.0,
|
||||
GridLayout.GridValueType.PERCENTAGE,
|
||||
(state) -> {
|
||||
|
@ -111,7 +117,7 @@ public class WorldSetupScreen extends BCLibScreen {
|
|||
row.addSpacer(20);
|
||||
endCustomTerrain = row.addCheckbox(
|
||||
Component.translatable("title.screen.bclib.worldgen.custom_end_terrain"),
|
||||
customEndGen,
|
||||
endConfig.generatorVersion != BCLEndBiomeSourceConfig.EndBiomeGeneratorType.VANILLA,
|
||||
1.0,
|
||||
GridLayout.GridValueType.PERCENTAGE,
|
||||
(state) -> {
|
||||
|
@ -122,7 +128,7 @@ public class WorldSetupScreen extends BCLibScreen {
|
|||
row.addSpacer(20);
|
||||
generateEndVoid = row.addCheckbox(
|
||||
Component.translatable("title.screen.bclib.worldgen.end_void"),
|
||||
haveEndVoid,
|
||||
endConfig.withVoidBiomes,
|
||||
1.0,
|
||||
GridLayout.GridValueType.PERCENTAGE,
|
||||
(state) -> {
|
||||
|
@ -133,7 +139,7 @@ public class WorldSetupScreen extends BCLibScreen {
|
|||
row.addSpacer(20);
|
||||
endLegacy = row.addCheckbox(
|
||||
Component.translatable("title.screen.bclib.worldgen.legacy_square"),
|
||||
endVersion == BCLBiomeSource.BIOME_SOURCE_VERSION_SQUARE,
|
||||
endConfig.mapVersion == BCLEndBiomeSourceConfig.EndBiomeMapType.SQUARE,
|
||||
1.0,
|
||||
GridLayout.GridValueType.PERCENTAGE,
|
||||
(state) -> {
|
||||
|
@ -143,7 +149,7 @@ public class WorldSetupScreen extends BCLibScreen {
|
|||
bclibEnd = mainSettingsRow.addCheckbox(
|
||||
Component.translatable(
|
||||
"title.screen.bclib.worldgen.custom_biome_source"),
|
||||
endVersion != BCLBiomeSource.BIOME_SOURCE_VERSION_VANILLA,
|
||||
endConfig.mapVersion != BCLEndBiomeSourceConfig.EndBiomeMapType.VANILLA,
|
||||
1.0,
|
||||
GridLayout.GridValueType.PERCENTAGE,
|
||||
(state) -> {
|
||||
|
@ -165,20 +171,48 @@ public class WorldSetupScreen extends BCLibScreen {
|
|||
}
|
||||
|
||||
private void updateSettings() {
|
||||
int endVersion = BCLBiomeSource.DEFAULT_BIOME_SOURCE_VERSION;
|
||||
Map<ResourceKey<LevelStem>, ChunkGenerator> betterxDimensions = TogetherWorldPreset.getDimensionsMap(
|
||||
PresetsRegistry.BCL_WORLD);
|
||||
Map<ResourceKey<LevelStem>, ChunkGenerator> vanillaDimensions = TogetherWorldPreset.getDimensionsMap(
|
||||
WorldPresets.NORMAL);
|
||||
BCLEndBiomeSourceConfig.EndBiomeMapType endVersion = BCLEndBiomeSourceConfig.DEFAULT.mapVersion;
|
||||
|
||||
|
||||
if (bclibEnd.isChecked()) {
|
||||
if (endLegacy.isChecked()) endVersion = BCLBiomeSource.BIOME_SOURCE_VERSION_SQUARE;
|
||||
else endVersion = BCLBiomeSource.BIOME_SOURCE_VERSION_HEX;
|
||||
BCLEndBiomeSourceConfig endConfig = new BCLEndBiomeSourceConfig(
|
||||
endLegacy.isChecked()
|
||||
? BCLEndBiomeSourceConfig.EndBiomeMapType.SQUARE
|
||||
: BCLEndBiomeSourceConfig.EndBiomeMapType.HEX,
|
||||
endCustomTerrain.isChecked()
|
||||
? BCLEndBiomeSourceConfig.EndBiomeGeneratorType.PAULEVS
|
||||
: BCLEndBiomeSourceConfig.EndBiomeGeneratorType.VANILLA,
|
||||
generateEndVoid.isChecked(),
|
||||
BCLEndBiomeSourceConfig.DEFAULT.innerVoidRadiusSquared
|
||||
);
|
||||
|
||||
ChunkGenerator endGenerator = betterxDimensions.get(LevelStem.END);
|
||||
((BCLibEndBiomeSource) endGenerator.getBiomeSource()).setTogetherConfig(endConfig);
|
||||
|
||||
updateConfiguration(LevelStem.END, BuiltinDimensionTypes.END, endGenerator);
|
||||
} else {
|
||||
endVersion = BCLBiomeSource.BIOME_SOURCE_VERSION_VANILLA;
|
||||
ChunkGenerator endGenerator = vanillaDimensions.get(LevelStem.END);
|
||||
updateConfiguration(LevelStem.END, BuiltinDimensionTypes.END, endGenerator);
|
||||
}
|
||||
|
||||
int netherVersion = BCLBiomeSource.DEFAULT_BIOME_SOURCE_VERSION;
|
||||
if (bclibNether.isChecked()) {
|
||||
if (netherLegacy.isChecked()) netherVersion = BCLBiomeSource.BIOME_SOURCE_VERSION_SQUARE;
|
||||
else netherVersion = BCLBiomeSource.BIOME_SOURCE_VERSION_HEX;
|
||||
BCLNetherBiomeSourceConfig netherConfig = new BCLNetherBiomeSourceConfig(
|
||||
netherLegacy.isChecked()
|
||||
? BCLNetherBiomeSourceConfig.NetherBiomeMapType.SQUARE
|
||||
: BCLNetherBiomeSourceConfig.NetherBiomeMapType.HEX
|
||||
);
|
||||
|
||||
ChunkGenerator netherGenerator = betterxDimensions.get(LevelStem.NETHER);
|
||||
((BCLibNetherBiomeSource) netherGenerator.getBiomeSource()).setTogetherConfig(netherConfig);
|
||||
|
||||
updateConfiguration(LevelStem.NETHER, BuiltinDimensionTypes.NETHER, netherGenerator);
|
||||
} else {
|
||||
netherVersion = BCLBiomeSource.BIOME_SOURCE_VERSION_VANILLA;
|
||||
ChunkGenerator endGenerator = vanillaDimensions.get(LevelStem.NETHER);
|
||||
updateConfiguration(LevelStem.NETHER, BuiltinDimensionTypes.NETHER, endGenerator);
|
||||
}
|
||||
|
||||
if (createWorldScreen.worldGenSettingsComponent instanceof WorldGenSettingsComponentAccessor acc
|
||||
|
@ -186,34 +220,31 @@ public class WorldSetupScreen extends BCLibScreen {
|
|||
.isPresent() && acc.bcl_getPreset()
|
||||
.get()
|
||||
.value() instanceof TogetherWorldPreset worldPreset) {
|
||||
acc.bcl_setPreset(Optional.of(Holder.direct(worldPreset.withSettings(new BCLWorldPresetSettings(
|
||||
netherVersion,
|
||||
endVersion,
|
||||
endCustomTerrain.isChecked(),
|
||||
generateEndVoid.isChecked()
|
||||
)))));
|
||||
acc.bcl_setPreset(Optional.of(Holder.direct(
|
||||
worldPreset.withDimensions(
|
||||
createWorldScreen
|
||||
.worldGenSettingsComponent
|
||||
.settings()
|
||||
.worldGenSettings()
|
||||
.dimensions()
|
||||
)
|
||||
)));
|
||||
}
|
||||
|
||||
BCLib.LOGGER.info("Custom World Versions: end=" + endVersion + ", nether=" + netherVersion);
|
||||
updateConfiguration(LevelStem.END, BuiltinDimensionTypes.END, endVersion);
|
||||
updateConfiguration(LevelStem.NETHER, BuiltinDimensionTypes.NETHER, netherVersion);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
private void updateConfiguration(
|
||||
ResourceKey<LevelStem> dimensionKey,
|
||||
ResourceKey<DimensionType> dimensionTypeKey,
|
||||
int biomeSourceVersion
|
||||
ChunkGenerator chunkGenerator
|
||||
) {
|
||||
createWorldScreen.worldGenSettingsComponent.updateSettings(
|
||||
(registryAccess, worldGenSettings) -> LevelGenUtil.replaceGenerator(
|
||||
dimensionKey,
|
||||
dimensionTypeKey,
|
||||
biomeSourceVersion,
|
||||
registryAccess,
|
||||
worldGenSettings
|
||||
worldGenSettings,
|
||||
chunkGenerator
|
||||
)
|
||||
);
|
||||
}
|
||||
|
|
|
@ -13,6 +13,6 @@ public class DedicatedServerPropertiesMixin {
|
|||
//Make sure the default server properties use our Default World Preset
|
||||
@ModifyArg(method = "<init>", index = 3, at = @At(value = "INVOKE", target = "Lnet/minecraft/server/dedicated/DedicatedServerProperties$WorldGenProperties;<init>(Ljava/lang/String;Lcom/google/gson/JsonObject;ZLjava/lang/String;)V"))
|
||||
private String bcl_init(String levelType) {
|
||||
return WorldPresets.DEFAULT.orElseThrow().location().toString();
|
||||
return WorldPresets.DEFAULT.location().toString();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,238 +0,0 @@
|
|||
package org.betterx.bclib.presets.worldgen;
|
||||
|
||||
import org.betterx.bclib.api.v2.generator.BCLBiomeSource;
|
||||
import org.betterx.bclib.api.v2.generator.BCLibEndBiomeSource;
|
||||
import org.betterx.bclib.api.v2.generator.config.BCLEndBiomeSourceConfig;
|
||||
import org.betterx.bclib.api.v2.generator.config.BCLNetherBiomeSourceConfig;
|
||||
import org.betterx.bclib.api.v2.levelgen.LevelGenUtil;
|
||||
import org.betterx.worlds.together.levelgen.WorldGenUtil;
|
||||
import org.betterx.worlds.together.worldPreset.TogetherWorldPreset;
|
||||
import org.betterx.worlds.together.worldPreset.settings.WorldPresetSettings;
|
||||
|
||||
import com.mojang.serialization.Codec;
|
||||
import com.mojang.serialization.codecs.RecordCodecBuilder;
|
||||
import net.minecraft.core.Holder;
|
||||
import net.minecraft.core.RegistryAccess;
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
import net.minecraft.world.level.biome.Biome;
|
||||
import net.minecraft.world.level.biome.BiomeSource;
|
||||
import net.minecraft.world.level.dimension.LevelStem;
|
||||
import net.minecraft.world.level.levelgen.WorldGenSettings;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
public class BCLWorldPresetSettings extends WorldPresetSettings {
|
||||
public final static BCLWorldPresetSettings DEFAULT = new BCLWorldPresetSettings(BCLBiomeSource.DEFAULT_BIOME_SOURCE_VERSION);
|
||||
|
||||
public static final Codec<BCLWorldPresetSettings> CODEC = RecordCodecBuilder
|
||||
.create((RecordCodecBuilder.Instance<BCLWorldPresetSettings> builderInstance) -> builderInstance.group(
|
||||
Codec.INT
|
||||
.fieldOf(LevelStem.NETHER.location().toString())
|
||||
.forGetter(o -> o.netherVersion),
|
||||
Codec.INT
|
||||
.fieldOf(LevelStem.END.location().toString())
|
||||
.forGetter(o -> o.endVersion),
|
||||
Codec.BOOL
|
||||
.fieldOf("custom_end_terrain")
|
||||
.orElse(true)
|
||||
.forGetter(o -> o.useEndTerrainGenerator),
|
||||
Codec.BOOL
|
||||
.fieldOf("generate_end_void")
|
||||
.orElse(false)
|
||||
.forGetter(o -> o.generateEndVoid)
|
||||
)
|
||||
.apply(
|
||||
builderInstance,
|
||||
builderInstance.stable(
|
||||
BCLWorldPresetSettings::new)
|
||||
));
|
||||
public final int netherVersion;
|
||||
public final int endVersion;
|
||||
public final boolean useEndTerrainGenerator;
|
||||
public final boolean generateEndVoid;
|
||||
|
||||
public BCLWorldPresetSettings(int version) {
|
||||
this(version, version, true, false);
|
||||
}
|
||||
|
||||
public BCLWorldPresetSettings(
|
||||
int netherVersion,
|
||||
int endVersion,
|
||||
boolean useEndTerrainGenerator,
|
||||
boolean generateEndVoid
|
||||
) {
|
||||
this.netherVersion = netherVersion;
|
||||
this.endVersion = endVersion;
|
||||
this.useEndTerrainGenerator = endVersion != BCLibEndBiomeSource.BIOME_SOURCE_VERSION_VANILLA && useEndTerrainGenerator;
|
||||
this.generateEndVoid = generateEndVoid;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Codec<? extends WorldPresetSettings> codec() {
|
||||
return CODEC;
|
||||
}
|
||||
|
||||
public TogetherWorldPreset buildPreset(
|
||||
LevelStem overworldStem,
|
||||
WorldGenUtil.Context netherContext,
|
||||
WorldGenUtil.Context endContext
|
||||
) {
|
||||
return new TogetherWorldPreset(buildDimensionMap(overworldStem, netherContext, endContext), 1000, this);
|
||||
}
|
||||
|
||||
private static BCLEndBiomeSourceConfig getEndConfigForVersion(int version) {
|
||||
if (version == BCLBiomeSource.BIOME_SOURCE_VERSION_HEX)
|
||||
return BCLEndBiomeSourceConfig.MINECRAFT_18;
|
||||
if (version == BCLBiomeSource.BIOME_SOURCE_VERSION_SQUARE)
|
||||
return BCLEndBiomeSourceConfig.MINECRAFT_17;
|
||||
|
||||
return BCLEndBiomeSourceConfig.DEFAULT;
|
||||
}
|
||||
|
||||
private static BCLNetherBiomeSourceConfig getNetherConfigForVersion(int version) {
|
||||
if (version == BCLBiomeSource.BIOME_SOURCE_VERSION_HEX)
|
||||
return BCLNetherBiomeSourceConfig.MINECRAFT_18;
|
||||
if (version == BCLBiomeSource.BIOME_SOURCE_VERSION_SQUARE)
|
||||
return BCLNetherBiomeSourceConfig.MINECRAFT_17;
|
||||
|
||||
return BCLNetherBiomeSourceConfig.DEFAULT;
|
||||
}
|
||||
|
||||
public Map<ResourceKey<LevelStem>, LevelStem> buildDimensionMap(
|
||||
LevelStem overworldStem,
|
||||
WorldGenUtil.Context netherContext,
|
||||
WorldGenUtil.Context endContext
|
||||
) {
|
||||
return Map.of(
|
||||
LevelStem.OVERWORLD,
|
||||
overworldStem,
|
||||
LevelStem.NETHER,
|
||||
LevelGenUtil.getBCLNetherLevelStem(netherContext, getNetherConfigForVersion(netherVersion)),
|
||||
LevelStem.END,
|
||||
LevelGenUtil.getBCLEndLevelStem(endContext, getEndConfigForVersion(endVersion))
|
||||
);
|
||||
}
|
||||
|
||||
// public int getVersion(ResourceKey<LevelStem> key) {
|
||||
// if (key == LevelStem.NETHER) return netherVersion;
|
||||
// if (key == LevelStem.END) return endVersion;
|
||||
//
|
||||
// return BCLBiomeSource.BIOME_SOURCE_VERSION_VANILLA;
|
||||
// }
|
||||
|
||||
|
||||
public BiomeSource addDatapackBiomes(BiomeSource biomeSource, Set<Holder<Biome>> datapackBiomes) {
|
||||
if (biomeSource instanceof BCLBiomeSource bs) {
|
||||
return bs.createCopyForDatapack(datapackBiomes);
|
||||
}
|
||||
return biomeSource;
|
||||
}
|
||||
|
||||
|
||||
// private static Holder<NoiseGeneratorSettings> buildGeneratorSettings(
|
||||
// Holder<NoiseGeneratorSettings> reference,
|
||||
// Holder<NoiseGeneratorSettings> settings,
|
||||
// BiomeSource biomeSource
|
||||
// ) {
|
||||
// //SurfaceRuleUtil.injectSurfaceRules(settings.value(), biomeSource);
|
||||
// return settings;
|
||||
//// NoiseGeneratorSettings old = settings.value();
|
||||
//// NoiseGeneratorSettings noise = new NoiseGeneratorSettings(
|
||||
//// old.noiseSettings(),
|
||||
//// old.defaultBlock(),
|
||||
//// old.defaultFluid(),
|
||||
//// old.noiseRouter(),
|
||||
//// SurfaceRuleRegistry.mergeSurfaceRulesFromBiomes(old.surfaceRule(), biomeSource),
|
||||
//// //SurfaceRuleUtil.addRulesForBiomeSource(old.surfaceRule(), biomeSource),
|
||||
//// old.spawnTarget(),
|
||||
//// old.seaLevel(),
|
||||
//// old.disableMobGeneration(),
|
||||
//// old.aquifersEnabled(),
|
||||
//// old.oreVeinsEnabled(),
|
||||
//// old.useLegacyRandomSource()
|
||||
//// );
|
||||
////
|
||||
////
|
||||
//// return Holder.direct(noise);
|
||||
// }
|
||||
|
||||
|
||||
// /**
|
||||
// * Datapacks can change the world's generator. This Method will ensure, that the Generators contain
|
||||
// * the correct BiomeSources for this world
|
||||
// *
|
||||
// * @param dimensionKey
|
||||
// * @param dimensionTypeKey
|
||||
// * @param settings
|
||||
// * @return
|
||||
// */
|
||||
// private WorldGenSettings fixSettingsInCurrentWorld(
|
||||
// RegistryAccess access, ResourceKey<LevelStem> dimensionKey,
|
||||
// ResourceKey<DimensionType> dimensionTypeKey,
|
||||
// WorldGenSettings settings
|
||||
// ) {
|
||||
// Optional<Holder<LevelStem>> loadedStem = settings.dimensions().getHolder(dimensionKey);
|
||||
// final ChunkGenerator loadedChunkGenerator = loadedStem.map(h -> h.value().generator()).orElse(null);
|
||||
// final int loaderVersion = LevelGenUtil.getBiomeVersionForGenerator(loadedStem
|
||||
// .map(h -> h.value().generator())
|
||||
// .orElse(null));
|
||||
//
|
||||
// final int targetVersion = getVersion(dimensionKey);
|
||||
// if (loaderVersion != targetVersion) {
|
||||
// BCLib.LOGGER.info("Enforcing Correct Generator for " + dimensionKey.location().toString() + ".");
|
||||
//
|
||||
// Optional<Holder<LevelStem>> refLevelStem = LevelGenUtil.referenceStemForVersion(
|
||||
// dimensionKey,
|
||||
// targetVersion,
|
||||
// access,
|
||||
// settings.seed(),
|
||||
// settings.generateStructures(),
|
||||
// settings.generateBonusChest()
|
||||
// );
|
||||
//
|
||||
// ChunkGenerator referenceGenerator = refLevelStem.map(h -> h.value().generator()).orElse(null);
|
||||
// if (referenceGenerator == null) {
|
||||
// BCLib.LOGGER.error("Failed to create Generator for " + dimensionKey.location().toString());
|
||||
// return settings;
|
||||
// }
|
||||
//
|
||||
// if (loadedChunkGenerator instanceof ChunkGeneratorAccessor generator) {
|
||||
// if (loadedChunkGenerator instanceof NoiseGeneratorSettingsProvider noiseProvider) {
|
||||
// if (referenceGenerator instanceof NoiseGeneratorSettingsProvider referenceProvider) {
|
||||
// final Set<Holder<Biome>> biomes = loadedChunkGenerator.getBiomeSource().possibleBiomes();
|
||||
// final BiomeSource bs = addDatapackBiomes(referenceGenerator.getBiomeSource(), biomes);
|
||||
// InternalBiomeAPI.applyModifications(bs, dimensionKey);
|
||||
// referenceGenerator = new BCLChunkGenerator(
|
||||
// generator.bclib_getStructureSetsRegistry(),
|
||||
// noiseProvider.bclib_getNoises(),
|
||||
// bs,
|
||||
// buildGeneratorSettings(
|
||||
// referenceProvider.bclib_getNoiseGeneratorSettingHolders(),
|
||||
// noiseProvider.bclib_getNoiseGeneratorSettingHolders(),
|
||||
// bs
|
||||
// )
|
||||
// );
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// return LevelGenUtil.replaceGenerator(
|
||||
// dimensionKey,
|
||||
// dimensionTypeKey,
|
||||
// access,
|
||||
// settings,
|
||||
// referenceGenerator
|
||||
// );
|
||||
// }
|
||||
// return settings;
|
||||
// }
|
||||
|
||||
public WorldGenSettings repairSettingsOnLoad(RegistryAccess registryAccess, WorldGenSettings settings) {
|
||||
// settings = fixSettingsInCurrentWorld(registryAccess, LevelStem.NETHER, BuiltinDimensionTypes.NETHER, settings);
|
||||
// settings = fixSettingsInCurrentWorld(registryAccess, LevelStem.END, BuiltinDimensionTypes.END, settings);
|
||||
return settings;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,15 +1,18 @@
|
|||
package org.betterx.bclib.registry;
|
||||
|
||||
import org.betterx.bclib.BCLib;
|
||||
import org.betterx.bclib.api.v2.generator.BCLBiomeSource;
|
||||
import org.betterx.bclib.presets.worldgen.BCLWorldPresetSettings;
|
||||
import org.betterx.bclib.api.v2.generator.config.BCLEndBiomeSourceConfig;
|
||||
import org.betterx.bclib.api.v2.generator.config.BCLNetherBiomeSourceConfig;
|
||||
import org.betterx.bclib.api.v2.levelgen.LevelGenUtil;
|
||||
import org.betterx.worlds.together.levelgen.WorldGenUtil;
|
||||
import org.betterx.worlds.together.worldPreset.TogetherWorldPreset;
|
||||
import org.betterx.worlds.together.worldPreset.WorldPresets;
|
||||
import org.betterx.worlds.together.worldPreset.settings.WorldPresetSettings;
|
||||
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
import net.minecraft.world.level.dimension.LevelStem;
|
||||
import net.minecraft.world.level.levelgen.presets.WorldPreset;
|
||||
|
||||
import java.util.Optional;
|
||||
import java.util.Map;
|
||||
|
||||
public class PresetsRegistry {
|
||||
public static ResourceKey<WorldPreset> BCL_WORLD;
|
||||
|
@ -18,12 +21,13 @@ public class PresetsRegistry {
|
|||
public static void onLoad() {
|
||||
BCL_WORLD =
|
||||
WorldPresets.register(
|
||||
BCLib.makeID("hex_map"),
|
||||
BCLib.makeID("normal"),
|
||||
(overworldStem, netherContext, endContext) ->
|
||||
new BCLWorldPresetSettings(BCLBiomeSource.BIOME_SOURCE_VERSION_HEX).buildPreset(
|
||||
buildPreset(
|
||||
overworldStem,
|
||||
netherContext,
|
||||
endContext
|
||||
BCLNetherBiomeSourceConfig.DEFAULT, endContext,
|
||||
BCLEndBiomeSourceConfig.DEFAULT
|
||||
),
|
||||
true
|
||||
);
|
||||
|
@ -31,18 +35,47 @@ public class PresetsRegistry {
|
|||
BCL_WORLD_17 = WorldPresets.register(
|
||||
BCLib.makeID("legacy_17"),
|
||||
(overworldStem, netherContext, endContext) ->
|
||||
new BCLWorldPresetSettings(BCLBiomeSource.BIOME_SOURCE_VERSION_SQUARE).buildPreset(
|
||||
buildPreset(
|
||||
overworldStem,
|
||||
netherContext,
|
||||
endContext
|
||||
BCLNetherBiomeSourceConfig.MINECRAFT_17, endContext,
|
||||
BCLEndBiomeSourceConfig.MINECRAFT_17
|
||||
),
|
||||
false
|
||||
);
|
||||
|
||||
WorldPresetSettings.DEFAULT = BCLWorldPresetSettings.DEFAULT;
|
||||
WorldPresets.DEFAULT = Optional.of(BCL_WORLD);
|
||||
|
||||
WorldPresetSettings.register(BCLib.makeID("bcl_world_preset_settings"), BCLWorldPresetSettings.CODEC);
|
||||
WorldPresets.DEFAULT = BCL_WORLD;
|
||||
}
|
||||
|
||||
public static TogetherWorldPreset buildPreset(
|
||||
LevelStem overworldStem,
|
||||
WorldGenUtil.Context netherContext,
|
||||
BCLNetherBiomeSourceConfig netherConfig,
|
||||
WorldGenUtil.Context endContext,
|
||||
BCLEndBiomeSourceConfig endConfig
|
||||
) {
|
||||
return new TogetherWorldPreset(buildDimensionMap(
|
||||
overworldStem,
|
||||
netherContext,
|
||||
netherConfig, endContext,
|
||||
endConfig
|
||||
), 1000);
|
||||
}
|
||||
|
||||
public static Map<ResourceKey<LevelStem>, LevelStem> buildDimensionMap(
|
||||
LevelStem overworldStem,
|
||||
WorldGenUtil.Context netherContext,
|
||||
BCLNetherBiomeSourceConfig netherConfig,
|
||||
WorldGenUtil.Context endContext,
|
||||
BCLEndBiomeSourceConfig endConfig
|
||||
) {
|
||||
return Map.of(
|
||||
LevelStem.OVERWORLD,
|
||||
overworldStem,
|
||||
LevelStem.NETHER,
|
||||
LevelGenUtil.getBCLNetherLevelStem(netherContext, netherConfig),
|
||||
LevelStem.END,
|
||||
LevelGenUtil.getBCLEndLevelStem(endContext, endConfig)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue