[Change] Removed WorldPresets
This commit is contained in:
parent
ad071b2dd3
commit
6be4140d7e
33 changed files with 11 additions and 2015 deletions
|
@ -1,55 +0,0 @@
|
|||
{
|
||||
"dimensions": {
|
||||
"minecraft:overworld": {
|
||||
"type": "minecraft:overworld",
|
||||
"generator": {
|
||||
"type": "minecraft:noise",
|
||||
"biome_source": {
|
||||
"type": "minecraft:multi_noise",
|
||||
"preset": "minecraft:overworld"
|
||||
},
|
||||
"settings": "minecraft:amplified"
|
||||
}
|
||||
},
|
||||
"minecraft:the_end": {
|
||||
"type": "minecraft:the_end",
|
||||
"generator": {
|
||||
"type": "bclib:betterx",
|
||||
"biome_source": {
|
||||
"type": "bclib:end_biome_source",
|
||||
"config": {
|
||||
"barrens_biomes_size": 256,
|
||||
"center_biomes_size": 256,
|
||||
"generator_version": "vanilla",
|
||||
"inner_void_radius_squared": 1048576,
|
||||
"land_biomes_size": 256,
|
||||
"map_type": "hex",
|
||||
"void_biomes_size": 256,
|
||||
"with_void_biomes": true
|
||||
},
|
||||
"seed": 0
|
||||
},
|
||||
"settings": "minecraft:end"
|
||||
}
|
||||
},
|
||||
"minecraft:the_nether": {
|
||||
"type": "minecraft:the_nether",
|
||||
"generator": {
|
||||
"type": "bclib:betterx",
|
||||
"biome_source": {
|
||||
"type": "bclib:nether_biome_source",
|
||||
"config": {
|
||||
"amplified": true,
|
||||
"biome_size": 256,
|
||||
"biome_size_vertical": 128,
|
||||
"map_type": "hex",
|
||||
"use_vertical_biomes": true
|
||||
},
|
||||
"seed": 0
|
||||
},
|
||||
"settings": "bclib:amplified_nether"
|
||||
}
|
||||
}
|
||||
},
|
||||
"sort_order": 1000
|
||||
}
|
|
@ -1,55 +0,0 @@
|
|||
{
|
||||
"dimensions": {
|
||||
"minecraft:overworld": {
|
||||
"type": "minecraft:overworld",
|
||||
"generator": {
|
||||
"type": "minecraft:noise",
|
||||
"biome_source": {
|
||||
"type": "minecraft:multi_noise",
|
||||
"preset": "minecraft:overworld"
|
||||
},
|
||||
"settings": "minecraft:large_biomes"
|
||||
}
|
||||
},
|
||||
"minecraft:the_end": {
|
||||
"type": "minecraft:the_end",
|
||||
"generator": {
|
||||
"type": "bclib:betterx",
|
||||
"biome_source": {
|
||||
"type": "bclib:end_biome_source",
|
||||
"config": {
|
||||
"barrens_biomes_size": 512,
|
||||
"center_biomes_size": 256,
|
||||
"generator_version": "vanilla",
|
||||
"inner_void_radius_squared": 1048576,
|
||||
"land_biomes_size": 1024,
|
||||
"map_type": "hex",
|
||||
"void_biomes_size": 512,
|
||||
"with_void_biomes": true
|
||||
},
|
||||
"seed": 0
|
||||
},
|
||||
"settings": "minecraft:end"
|
||||
}
|
||||
},
|
||||
"minecraft:the_nether": {
|
||||
"type": "minecraft:the_nether",
|
||||
"generator": {
|
||||
"type": "bclib:betterx",
|
||||
"biome_source": {
|
||||
"type": "bclib:nether_biome_source",
|
||||
"config": {
|
||||
"amplified": false,
|
||||
"biome_size": 1024,
|
||||
"biome_size_vertical": 172,
|
||||
"map_type": "hex",
|
||||
"use_vertical_biomes": true
|
||||
},
|
||||
"seed": 0
|
||||
},
|
||||
"settings": "minecraft:nether"
|
||||
}
|
||||
}
|
||||
},
|
||||
"sort_order": 1000
|
||||
}
|
|
@ -1,55 +0,0 @@
|
|||
{
|
||||
"dimensions": {
|
||||
"minecraft:overworld": {
|
||||
"type": "minecraft:overworld",
|
||||
"generator": {
|
||||
"type": "minecraft:noise",
|
||||
"biome_source": {
|
||||
"type": "minecraft:multi_noise",
|
||||
"preset": "minecraft:overworld"
|
||||
},
|
||||
"settings": "minecraft:overworld"
|
||||
}
|
||||
},
|
||||
"minecraft:the_end": {
|
||||
"type": "minecraft:the_end",
|
||||
"generator": {
|
||||
"type": "bclib:betterx",
|
||||
"biome_source": {
|
||||
"type": "bclib:end_biome_source",
|
||||
"config": {
|
||||
"barrens_biomes_size": 256,
|
||||
"center_biomes_size": 256,
|
||||
"generator_version": "paulevs",
|
||||
"inner_void_radius_squared": 1048576,
|
||||
"land_biomes_size": 256,
|
||||
"map_type": "square",
|
||||
"void_biomes_size": 256,
|
||||
"with_void_biomes": true
|
||||
},
|
||||
"seed": 0
|
||||
},
|
||||
"settings": "minecraft:end"
|
||||
}
|
||||
},
|
||||
"minecraft:the_nether": {
|
||||
"type": "minecraft:the_nether",
|
||||
"generator": {
|
||||
"type": "bclib:betterx",
|
||||
"biome_source": {
|
||||
"type": "bclib:nether_biome_source",
|
||||
"config": {
|
||||
"amplified": false,
|
||||
"biome_size": 256,
|
||||
"biome_size_vertical": 86,
|
||||
"map_type": "square",
|
||||
"use_vertical_biomes": true
|
||||
},
|
||||
"seed": 0
|
||||
},
|
||||
"settings": "minecraft:nether"
|
||||
}
|
||||
}
|
||||
},
|
||||
"sort_order": 1000
|
||||
}
|
|
@ -1,55 +0,0 @@
|
|||
{
|
||||
"dimensions": {
|
||||
"minecraft:overworld": {
|
||||
"type": "minecraft:overworld",
|
||||
"generator": {
|
||||
"type": "minecraft:noise",
|
||||
"biome_source": {
|
||||
"type": "minecraft:multi_noise",
|
||||
"preset": "minecraft:overworld"
|
||||
},
|
||||
"settings": "minecraft:overworld"
|
||||
}
|
||||
},
|
||||
"minecraft:the_end": {
|
||||
"type": "minecraft:the_end",
|
||||
"generator": {
|
||||
"type": "bclib:betterx",
|
||||
"biome_source": {
|
||||
"type": "bclib:end_biome_source",
|
||||
"config": {
|
||||
"barrens_biomes_size": 256,
|
||||
"center_biomes_size": 256,
|
||||
"generator_version": "vanilla",
|
||||
"inner_void_radius_squared": 1048576,
|
||||
"land_biomes_size": 256,
|
||||
"map_type": "hex",
|
||||
"void_biomes_size": 256,
|
||||
"with_void_biomes": true
|
||||
},
|
||||
"seed": 0
|
||||
},
|
||||
"settings": "minecraft:end"
|
||||
}
|
||||
},
|
||||
"minecraft:the_nether": {
|
||||
"type": "minecraft:the_nether",
|
||||
"generator": {
|
||||
"type": "bclib:betterx",
|
||||
"biome_source": {
|
||||
"type": "bclib:nether_biome_source",
|
||||
"config": {
|
||||
"amplified": false,
|
||||
"biome_size": 256,
|
||||
"biome_size_vertical": 86,
|
||||
"map_type": "hex",
|
||||
"use_vertical_biomes": true
|
||||
},
|
||||
"seed": 0
|
||||
},
|
||||
"settings": "minecraft:nether"
|
||||
}
|
||||
}
|
||||
},
|
||||
"sort_order": 1000
|
||||
}
|
|
@ -1,8 +0,0 @@
|
|||
{
|
||||
"replace": false,
|
||||
"values": [
|
||||
"bclib:normal",
|
||||
"bclib:amplified",
|
||||
"bclib:large"
|
||||
]
|
||||
}
|
|
@ -28,7 +28,6 @@ import org.betterx.bclib.recipes.CraftingRecipes;
|
|||
import org.betterx.bclib.registry.BaseBlockEntities;
|
||||
import org.betterx.bclib.registry.BaseRegistry;
|
||||
import org.betterx.bclib.registry.BlockRegistry;
|
||||
import org.betterx.bclib.registry.PresetsRegistry;
|
||||
import org.betterx.datagen.bclib.tests.TestStructure;
|
||||
import org.betterx.worlds.together.WorldsTogether;
|
||||
import org.betterx.worlds.together.util.Logger;
|
||||
|
@ -70,7 +69,6 @@ public class BCLib implements ModInitializer {
|
|||
public void onInitialize() {
|
||||
WorldsTogether.onInitialize();
|
||||
BCLibArguments.register();
|
||||
PresetsRegistry.register();
|
||||
LevelGenEvents.register();
|
||||
BlockPredicates.ensureStaticInitialization();
|
||||
BCLBiomeRegistry.register();
|
||||
|
|
|
@ -1,22 +1,12 @@
|
|||
package org.betterx.bclib;
|
||||
|
||||
import org.betterx.bclib.api.v2.datafixer.DataFixerAPI;
|
||||
import org.betterx.bclib.api.v2.datafixer.ForcedLevelPatch;
|
||||
import org.betterx.bclib.api.v2.datafixer.MigrationProfile;
|
||||
import org.betterx.bclib.api.v2.datafixer.Patch;
|
||||
import org.betterx.bclib.api.v2.generator.GeneratorOptions;
|
||||
import org.betterx.bclib.api.v2.levelgen.LevelGenUtil;
|
||||
import org.betterx.bclib.config.Configs;
|
||||
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public final class BCLibPatch {
|
||||
public static void register() {
|
||||
if (Configs.MAIN_CONFIG.repairBiomes() && (GeneratorOptions.fixEndBiomeSource() || GeneratorOptions.fixNetherBiomeSource())) {
|
||||
DataFixerAPI.registerPatch(BiomeSourcePatch::new);
|
||||
}
|
||||
DataFixerAPI.registerPatch(SignPatch::new);
|
||||
}
|
||||
}
|
||||
|
@ -34,16 +24,4 @@ class SignPatch extends Patch {
|
|||
}
|
||||
}
|
||||
|
||||
final class BiomeSourcePatch extends ForcedLevelPatch {
|
||||
protected BiomeSourcePatch() {
|
||||
super(BCLib.MOD_ID, "1.2.1");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Boolean runLevelDatPatch(CompoundTag root, MigrationProfile profile) {
|
||||
//make sure we have a working generators file before attempting to patch
|
||||
LevelGenUtil.migrateGeneratorSettings();
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,26 +4,18 @@ import org.betterx.bclib.BCLib;
|
|||
import org.betterx.bclib.api.v2.LifeCycleAPI;
|
||||
import org.betterx.bclib.api.v2.dataexchange.DataExchangeAPI;
|
||||
import org.betterx.bclib.api.v2.datafixer.DataFixerAPI;
|
||||
import org.betterx.bclib.api.v2.generator.BCLibEndBiomeSource;
|
||||
import org.betterx.bclib.api.v2.generator.config.BCLEndBiomeSourceConfig;
|
||||
import org.betterx.bclib.api.v2.levelgen.biomes.InternalBiomeAPI;
|
||||
import org.betterx.bclib.api.v2.poi.PoiManager;
|
||||
import org.betterx.bclib.registry.PresetsRegistry;
|
||||
import org.betterx.worlds.together.tag.v3.TagManager;
|
||||
import org.betterx.worlds.together.world.WorldConfig;
|
||||
import org.betterx.worlds.together.world.event.WorldEvents;
|
||||
import org.betterx.worlds.together.worldPreset.TogetherWorldPreset;
|
||||
|
||||
import net.minecraft.core.Holder;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.core.RegistryAccess;
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.tags.TagLoader;
|
||||
import net.minecraft.world.level.chunk.ChunkGenerator;
|
||||
import net.minecraft.world.level.dimension.LevelStem;
|
||||
import net.minecraft.world.level.levelgen.WorldDimensions;
|
||||
import net.minecraft.world.level.levelgen.presets.WorldPreset;
|
||||
import net.minecraft.world.level.storage.LevelResource;
|
||||
import net.minecraft.world.level.storage.LevelStorageSource;
|
||||
|
||||
|
@ -47,7 +39,6 @@ public class LevelGenEvents {
|
|||
WorldEvents.ON_FINALIZED_WORLD_LOAD.on(LevelGenEvents::finalizedWorldLoad);
|
||||
|
||||
WorldEvents.PATCH_WORLD.on(LevelGenEvents::patchExistingWorld);
|
||||
WorldEvents.ADAPT_WORLD_PRESET.on(LevelGenEvents::adaptWorldPreset);
|
||||
|
||||
WorldEvents.BEFORE_ADDING_TAGS.on(LevelGenEvents::applyBiomeTags);
|
||||
}
|
||||
|
@ -72,53 +63,12 @@ public class LevelGenEvents {
|
|||
return DataFixerAPI.fixData(storageAccess, allDone != null && BCLib.isClient(), allDone);
|
||||
}
|
||||
|
||||
private static Holder<WorldPreset> adaptWorldPreset(
|
||||
Holder<WorldPreset> currentPreset,
|
||||
WorldDimensions worldDims
|
||||
) {
|
||||
LevelStem endStem = worldDims.dimensions().get(LevelStem.END);
|
||||
|
||||
//We probably loaded a Datapack for the End
|
||||
if (!(endStem.generator().getBiomeSource() instanceof BCLibEndBiomeSource)) {
|
||||
if (currentPreset != null) {
|
||||
if (currentPreset instanceof TogetherWorldPreset worldPreset) {
|
||||
ResourceKey worldPresetKey = currentPreset.unwrapKey().orElse(null);
|
||||
|
||||
//user did not configure/change the Preset!
|
||||
if (PresetsRegistry.BCL_WORLD.equals(worldPresetKey)
|
||||
|| PresetsRegistry.BCL_WORLD_17.equals(worldPresetKey)) {
|
||||
BCLib.LOGGER.info("Detected Datapack for END.");
|
||||
|
||||
LevelStem configuredEndStem = worldPreset.getDimension(LevelStem.END);
|
||||
if (configuredEndStem.generator().getBiomeSource() instanceof BCLibEndBiomeSource endSource) {
|
||||
BCLib.LOGGER.info("Changing Default WorldPreset Settings for Datapack use.");
|
||||
|
||||
BCLEndBiomeSourceConfig inputConfig = endSource.getTogetherConfig();
|
||||
endSource.setTogetherConfig(new BCLEndBiomeSourceConfig(
|
||||
inputConfig.mapVersion,
|
||||
BCLEndBiomeSourceConfig.EndBiomeGeneratorType.VANILLA,
|
||||
false,
|
||||
inputConfig.innerVoidRadiusSquared,
|
||||
inputConfig.centerBiomesSize,
|
||||
inputConfig.voidBiomesSize,
|
||||
inputConfig.landBiomesSize,
|
||||
inputConfig.barrensBiomesSize
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return currentPreset;
|
||||
}
|
||||
|
||||
private static void worldRegistryReady(RegistryAccess a) {
|
||||
InternalBiomeAPI.initRegistry(a);
|
||||
}
|
||||
|
||||
private static void beforeWorldLoad(
|
||||
LevelStorageSource.LevelStorageAccess storageAccess,
|
||||
Map<ResourceKey<LevelStem>, ChunkGenerator> dimensions,
|
||||
boolean isNewWorld,
|
||||
boolean isServer
|
||||
) {
|
||||
|
@ -126,8 +76,6 @@ public class LevelGenEvents {
|
|||
if (isNewWorld) {
|
||||
WorldConfig.saveFile(BCLib.MOD_ID);
|
||||
DataFixerAPI.initializePatchData();
|
||||
} else {
|
||||
LevelGenUtil.migrateGeneratorSettings();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,16 +1,11 @@
|
|||
package org.betterx.bclib.api.v2.levelgen;
|
||||
|
||||
import org.betterx.bclib.BCLib;
|
||||
import org.betterx.bclib.api.v2.generator.BCLChunkGenerator;
|
||||
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.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 com.mojang.serialization.Lifecycle;
|
||||
import net.minecraft.core.Holder;
|
||||
|
@ -18,16 +13,11 @@ import net.minecraft.core.MappedRegistry;
|
|||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.core.RegistryAccess;
|
||||
import net.minecraft.core.registries.Registries;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
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.presets.WorldPreset;
|
||||
import net.minecraft.world.level.levelgen.presets.WorldPresets;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
|
@ -118,79 +108,4 @@ public class LevelGenUtil {
|
|||
}
|
||||
return writableRegistry;
|
||||
}
|
||||
|
||||
|
||||
public static void migrateGeneratorSettings() {
|
||||
final CompoundTag settingsNbt = WorldGenUtil.getPresetsNbt();
|
||||
|
||||
if (settingsNbt.size() == 0) {
|
||||
CompoundTag oldGen = WorldGenUtil.getGeneratorNbt();
|
||||
if (oldGen != null) {
|
||||
if (oldGen.contains("type")) {
|
||||
BCLib.LOGGER.info("Found World with beta generator Settings.");
|
||||
if ("bclib:bcl_world_preset_settings".equals(oldGen.getString("type"))) {
|
||||
int netherVersion = 18;
|
||||
int endVersion = 18;
|
||||
if (oldGen.contains("minecraft:the_nether"))
|
||||
netherVersion = oldGen.getInt("minecraft:the_nether");
|
||||
if (oldGen.contains("minecraft:the_end"))
|
||||
endVersion = oldGen.getInt("minecraft:the_end");
|
||||
|
||||
if (netherVersion == 18) netherVersion = 0;
|
||||
else if (netherVersion == 17) netherVersion = 1;
|
||||
else netherVersion = 2;
|
||||
|
||||
if (endVersion == 18) endVersion = 0;
|
||||
else if (endVersion == 17) endVersion = 1;
|
||||
else endVersion = 2;
|
||||
|
||||
var presets = List.of(
|
||||
TogetherWorldPreset.getDimensionsMap(PresetsRegistry.BCL_WORLD),
|
||||
TogetherWorldPreset.getDimensionsMap(PresetsRegistry.BCL_WORLD_17),
|
||||
TogetherWorldPreset.getDimensionsMap(WorldPresets.NORMAL)
|
||||
);
|
||||
Map<ResourceKey<LevelStem>, ChunkGenerator> dimensions = new HashMap<>();
|
||||
dimensions.put(LevelStem.OVERWORLD, presets.get(0).get(LevelStem.OVERWORLD));
|
||||
dimensions.put(LevelStem.NETHER, presets.get(netherVersion).get(LevelStem.NETHER));
|
||||
dimensions.put(LevelStem.END, presets.get(endVersion).get(LevelStem.END));
|
||||
|
||||
TogetherWorldPreset.writeWorldPresetSettingsDirect(dimensions);
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
BCLib.LOGGER.info("Found World without generator Settings. Setting up data...");
|
||||
ResourceKey<WorldPreset> biomeSourceVersion = PresetsRegistry.BCL_WORLD;
|
||||
|
||||
final CompoundTag bclRoot = WorldConfig.getRootTag(BCLib.MOD_ID);
|
||||
|
||||
String bclVersion = "0.0.0";
|
||||
if (bclRoot.contains(TAG_VERSION)) {
|
||||
bclVersion = bclRoot.getString(TAG_VERSION);
|
||||
}
|
||||
boolean isPre18 = !ModUtil.isLargerOrEqualVersion(bclVersion, "1.0.0");
|
||||
|
||||
if (isPre18) {
|
||||
BCLib.LOGGER.info("World was create pre 1.18!");
|
||||
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))
|
||||
? PresetsRegistry.BCL_WORLD_17
|
||||
: PresetsRegistry.BCL_WORLD;
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,7 +8,6 @@ import org.betterx.bclib.client.textures.AtlasSetManager;
|
|||
import org.betterx.bclib.client.textures.SpriteLister;
|
||||
import org.betterx.bclib.config.Configs;
|
||||
import org.betterx.bclib.registry.BaseBlockEntityRenders;
|
||||
import org.betterx.bclib.registry.PresetsRegistryClient;
|
||||
import org.betterx.worlds.together.WorldsTogether;
|
||||
import org.betterx.worlds.together.client.WorldsTogetherClient;
|
||||
|
||||
|
@ -43,7 +42,6 @@ public class BCLibClient implements ClientModInitializer, ModelResourceProvider,
|
|||
ModelLoadingRegistry.INSTANCE.registerResourceProvider(rm -> this);
|
||||
ModelLoadingRegistry.INSTANCE.registerVariantProvider(rm -> this);
|
||||
|
||||
PresetsRegistryClient.onLoad();
|
||||
WorldsTogether.SURPRESS_EXPERIMENTAL_DIALOG = Configs.CLIENT_CONFIG.suppressExperimentalDialog();
|
||||
|
||||
AtlasSetManager.addSource(AtlasSetManager.VANILLA_BLOCKS, new SpriteLister("entity/chest"));
|
||||
|
|
|
@ -6,9 +6,7 @@ import de.ambertation.wunderlib.ui.layout.values.Size;
|
|||
import org.betterx.bclib.BCLib;
|
||||
import org.betterx.bclib.config.Configs;
|
||||
import org.betterx.bclib.networking.VersionChecker;
|
||||
import org.betterx.bclib.registry.PresetsRegistry;
|
||||
import org.betterx.worlds.together.WorldsTogether;
|
||||
import org.betterx.worlds.together.worldPreset.WorldPresets;
|
||||
|
||||
import net.minecraft.client.gui.GuiGraphics;
|
||||
import net.minecraft.client.gui.screens.Screen;
|
||||
|
@ -143,10 +141,6 @@ public class WelcomeScreen extends BCLibLayoutScreen {
|
|||
Configs.CLIENT_CONFIG.saveChanges();
|
||||
|
||||
WorldsTogether.SURPRESS_EXPERIMENTAL_DIALOG = Configs.CLIENT_CONFIG.suppressExperimentalDialog();
|
||||
if (Configs.CLIENT_CONFIG.forceBetterXPreset())
|
||||
WorldPresets.setDEFAULT(PresetsRegistry.BCL_WORLD);
|
||||
else
|
||||
WorldPresets.setDEFAULT(net.minecraft.world.level.levelgen.presets.WorldPresets.NORMAL);
|
||||
VersionChecker.startCheck(true);
|
||||
onClose();
|
||||
}).alignRight();
|
||||
|
|
|
@ -1,525 +0,0 @@
|
|||
package org.betterx.bclib.client.gui.screens;
|
||||
|
||||
import de.ambertation.wunderlib.ui.layout.components.*;
|
||||
import de.ambertation.wunderlib.ui.layout.components.render.RenderHelper;
|
||||
import de.ambertation.wunderlib.ui.layout.values.Rectangle;
|
||||
import de.ambertation.wunderlib.ui.layout.values.Size;
|
||||
import de.ambertation.wunderlib.ui.vanilla.LayoutScreen;
|
||||
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.registry.PresetsRegistry;
|
||||
import org.betterx.worlds.together.worldPreset.TogetherWorldPreset;
|
||||
|
||||
import net.minecraft.client.gui.GuiGraphics;
|
||||
import net.minecraft.client.gui.screens.worldselection.CreateWorldScreen;
|
||||
import net.minecraft.client.gui.screens.worldselection.WorldCreationContext;
|
||||
import net.minecraft.client.gui.screens.worldselection.WorldCreationUiState;
|
||||
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.WorldDimensions;
|
||||
import net.minecraft.world.level.levelgen.presets.WorldPreset;
|
||||
import net.minecraft.world.level.levelgen.presets.WorldPresets;
|
||||
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.api.Environment;
|
||||
|
||||
import java.util.Map;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@Environment(EnvType.CLIENT)
|
||||
public class WorldSetupScreen extends LayoutScreen {
|
||||
private final WorldCreationContext context;
|
||||
private final CreateWorldScreen createWorldScreen;
|
||||
private Range<Integer> netherBiomeSize;
|
||||
private Range<Integer> netherVerticalBiomeSize;
|
||||
private Range<Integer> landBiomeSize;
|
||||
private Range<Integer> voidBiomeSize;
|
||||
private Range<Integer> centerBiomeSize;
|
||||
private Range<Integer> barrensBiomeSize;
|
||||
private Range<Integer> innerRadius;
|
||||
|
||||
public WorldSetupScreen(@Nullable CreateWorldScreen parent, WorldCreationContext context) {
|
||||
super(parent, Component.translatable("title.screen.bclib.worldgen.main"), 10, 10, 10);
|
||||
this.context = context;
|
||||
this.createWorldScreen = parent;
|
||||
}
|
||||
|
||||
|
||||
private Checkbox bclibEnd;
|
||||
private Checkbox bclibNether;
|
||||
Checkbox endLegacy;
|
||||
Checkbox endCustomTerrain;
|
||||
Checkbox generateEndVoid;
|
||||
Checkbox netherLegacy;
|
||||
Checkbox netherVertical;
|
||||
Checkbox netherAmplified;
|
||||
|
||||
public LayoutComponent<?, ?> netherPage(BCLNetherBiomeSourceConfig netherConfig) {
|
||||
VerticalStack content = new VerticalStack(fill(), fit()).centerHorizontal();
|
||||
content.addSpacer(8);
|
||||
|
||||
bclibNether = content.addCheckbox(
|
||||
fit(), fit(),
|
||||
Component.translatable("title.screen.bclib.worldgen.custom_nether_biome_source"),
|
||||
netherConfig.mapVersion != BCLNetherBiomeSourceConfig.NetherBiomeMapType.VANILLA
|
||||
);
|
||||
|
||||
netherLegacy = content.indent(20).addCheckbox(
|
||||
fit(), fit(),
|
||||
Component.translatable("title.screen.bclib.worldgen.legacy_square"),
|
||||
netherConfig.mapVersion == BCLNetherBiomeSourceConfig.NetherBiomeMapType.SQUARE
|
||||
);
|
||||
|
||||
netherAmplified = content.indent(20).addCheckbox(
|
||||
fit(), fit(),
|
||||
Component.translatable("title.screen.bclib.worldgen.nether_amplified"),
|
||||
netherConfig.amplified
|
||||
);
|
||||
|
||||
netherVertical = content.indent(20).addCheckbox(
|
||||
fit(), fit(),
|
||||
Component.translatable("title.screen.bclib.worldgen.nether_vertical"),
|
||||
netherConfig.useVerticalBiomes
|
||||
);
|
||||
|
||||
content.addSpacer(12);
|
||||
content.addText(fit(), fit(), Component.translatable("title.screen.bclib.worldgen.avg_biome_size"))
|
||||
.centerHorizontal();
|
||||
content.addHorizontalSeparator(8).alignTop();
|
||||
|
||||
netherBiomeSize = content.addRange(
|
||||
fixed(200),
|
||||
fit(),
|
||||
Component.translatable("title.screen.bclib.worldgen.nether_biome_size"),
|
||||
1,
|
||||
512,
|
||||
netherConfig.biomeSize / 16
|
||||
);
|
||||
|
||||
netherVerticalBiomeSize = content.addRange(
|
||||
fixed(200),
|
||||
fit(),
|
||||
Component.translatable("title.screen.bclib.worldgen.nether_vertical_biome_size"),
|
||||
1,
|
||||
32,
|
||||
netherConfig.biomeSizeVertical / 16
|
||||
);
|
||||
|
||||
bclibNether.onChange((cb, state) -> {
|
||||
netherLegacy.setEnabled(state);
|
||||
netherAmplified.setEnabled(state);
|
||||
netherVertical.setEnabled(state);
|
||||
netherBiomeSize.setEnabled(state);
|
||||
netherVerticalBiomeSize.setEnabled(state && netherVertical.isChecked());
|
||||
});
|
||||
|
||||
netherVertical.onChange((cb, state) -> {
|
||||
netherVerticalBiomeSize.setEnabled(state && bclibNether.isChecked());
|
||||
});
|
||||
|
||||
content.addSpacer(8);
|
||||
return content.setDebugName("Nether page");
|
||||
}
|
||||
|
||||
public LayoutComponent<?, ?> endPage(BCLEndBiomeSourceConfig endConfig) {
|
||||
VerticalStack content = new VerticalStack(fill(), fit()).centerHorizontal();
|
||||
content.addSpacer(8);
|
||||
bclibEnd = content.addCheckbox(
|
||||
fit(), fit(),
|
||||
Component.translatable("title.screen.bclib.worldgen.custom_end_biome_source"),
|
||||
endConfig.mapVersion != BCLEndBiomeSourceConfig.EndBiomeMapType.VANILLA
|
||||
);
|
||||
|
||||
endLegacy = content.indent(20).addCheckbox(
|
||||
fit(), fit(),
|
||||
Component.translatable("title.screen.bclib.worldgen.legacy_square"),
|
||||
endConfig.mapVersion == BCLEndBiomeSourceConfig.EndBiomeMapType.SQUARE
|
||||
);
|
||||
|
||||
endCustomTerrain = content.indent(20).addCheckbox(
|
||||
fit(), fit(),
|
||||
Component.translatable("title.screen.bclib.worldgen.custom_end_terrain"),
|
||||
endConfig.generatorVersion != BCLEndBiomeSourceConfig.EndBiomeGeneratorType.VANILLA
|
||||
);
|
||||
|
||||
generateEndVoid = content.indent(20).addCheckbox(
|
||||
fit(), fit(),
|
||||
Component.translatable("title.screen.bclib.worldgen.end_void"),
|
||||
endConfig.withVoidBiomes
|
||||
);
|
||||
|
||||
content.addSpacer(12);
|
||||
content.addText(fit(), fit(), Component.translatable("title.screen.bclib.worldgen.avg_biome_size"))
|
||||
.centerHorizontal();
|
||||
content.addHorizontalSeparator(8).alignTop();
|
||||
|
||||
landBiomeSize = content.addRange(
|
||||
fixed(200),
|
||||
fit(),
|
||||
Component.translatable("title.screen.bclib.worldgen.land_biome_size"),
|
||||
1,
|
||||
512,
|
||||
endConfig.landBiomesSize / 16
|
||||
);
|
||||
|
||||
voidBiomeSize = content.addRange(
|
||||
fixed(200),
|
||||
fit(),
|
||||
Component.translatable("title.screen.bclib.worldgen.void_biome_size"),
|
||||
1,
|
||||
512,
|
||||
endConfig.voidBiomesSize / 16
|
||||
);
|
||||
|
||||
centerBiomeSize = content.addRange(
|
||||
fixed(200),
|
||||
fit(),
|
||||
Component.translatable("title.screen.bclib.worldgen.center_biome_size"),
|
||||
1,
|
||||
512,
|
||||
endConfig.centerBiomesSize / 16
|
||||
);
|
||||
|
||||
barrensBiomeSize = content.addRange(
|
||||
fixed(200),
|
||||
fit(),
|
||||
Component.translatable("title.screen.bclib.worldgen.barrens_biome_size"),
|
||||
1,
|
||||
512,
|
||||
endConfig.barrensBiomesSize / 16
|
||||
);
|
||||
|
||||
content.addSpacer(12);
|
||||
content.addText(fit(), fit(), Component.translatable("title.screen.bclib.worldgen.other"))
|
||||
.centerHorizontal();
|
||||
content.addHorizontalSeparator(8).alignTop();
|
||||
|
||||
innerRadius = content.addRange(
|
||||
fixed(200),
|
||||
fit(),
|
||||
Component.translatable("title.screen.bclib.worldgen.central_radius"),
|
||||
1,
|
||||
512,
|
||||
(int) Math.sqrt(endConfig.innerVoidRadiusSquared) / 16
|
||||
);
|
||||
|
||||
|
||||
bclibEnd.onChange((cb, state) -> {
|
||||
endLegacy.setEnabled(state);
|
||||
endCustomTerrain.setEnabled(state);
|
||||
generateEndVoid.setEnabled(state);
|
||||
|
||||
landBiomeSize.setEnabled(state && endCustomTerrain.isChecked());
|
||||
voidBiomeSize.setEnabled(state && endCustomTerrain.isChecked() && generateEndVoid.isChecked());
|
||||
centerBiomeSize.setEnabled(state && endCustomTerrain.isChecked());
|
||||
barrensBiomeSize.setEnabled(state && endCustomTerrain.isChecked());
|
||||
});
|
||||
|
||||
endCustomTerrain.onChange((cb, state) -> {
|
||||
landBiomeSize.setEnabled(state);
|
||||
voidBiomeSize.setEnabled(state && generateEndVoid.isChecked());
|
||||
centerBiomeSize.setEnabled(state);
|
||||
barrensBiomeSize.setEnabled(state);
|
||||
});
|
||||
|
||||
generateEndVoid.onChange((cb, state) -> {
|
||||
voidBiomeSize.setEnabled(state && endCustomTerrain.isChecked());
|
||||
});
|
||||
|
||||
content.addSpacer(8);
|
||||
return content.setDebugName("End Page");
|
||||
}
|
||||
|
||||
private void updateSettings() {
|
||||
Map<ResourceKey<LevelStem>, ChunkGenerator> betterxDimensions = TogetherWorldPreset.getDimensionsMap(
|
||||
PresetsRegistry.BCL_WORLD);
|
||||
Map<ResourceKey<LevelStem>, ChunkGenerator> betterxAmplifiedDimensions = TogetherWorldPreset.getDimensionsMap(
|
||||
PresetsRegistry.BCL_WORLD_AMPLIFIED);
|
||||
Map<ResourceKey<LevelStem>, ChunkGenerator> vanillaDimensions = TogetherWorldPreset.getDimensionsMap(
|
||||
WorldPresets.NORMAL);
|
||||
BCLEndBiomeSourceConfig.EndBiomeMapType endVersion = BCLEndBiomeSourceConfig.DEFAULT.mapVersion;
|
||||
|
||||
|
||||
if (bclibEnd.isChecked()) {
|
||||
BCLEndBiomeSourceConfig endConfig = new BCLEndBiomeSourceConfig(
|
||||
endLegacy.isChecked()
|
||||
? BCLEndBiomeSourceConfig.EndBiomeMapType.SQUARE
|
||||
: BCLEndBiomeSourceConfig.EndBiomeMapType.HEX,
|
||||
endCustomTerrain.isChecked()
|
||||
? BCLEndBiomeSourceConfig.EndBiomeGeneratorType.PAULEVS
|
||||
: BCLEndBiomeSourceConfig.EndBiomeGeneratorType.VANILLA,
|
||||
generateEndVoid.isChecked(),
|
||||
(int) Math.pow(innerRadius.getValue() * 16, 2),
|
||||
centerBiomeSize.getValue() * 16,
|
||||
voidBiomeSize.getValue() * 16,
|
||||
landBiomeSize.getValue() * 16,
|
||||
barrensBiomeSize.getValue() * 16
|
||||
);
|
||||
|
||||
ChunkGenerator endGenerator = betterxDimensions.get(LevelStem.END);
|
||||
((BCLibEndBiomeSource) endGenerator.getBiomeSource()).setTogetherConfig(endConfig);
|
||||
|
||||
updateConfiguration(LevelStem.END, BuiltinDimensionTypes.END, endGenerator);
|
||||
} else {
|
||||
ChunkGenerator endGenerator = vanillaDimensions.get(LevelStem.END);
|
||||
updateConfiguration(LevelStem.END, BuiltinDimensionTypes.END, endGenerator);
|
||||
}
|
||||
|
||||
if (bclibNether.isChecked()) {
|
||||
BCLNetherBiomeSourceConfig netherConfig = new BCLNetherBiomeSourceConfig(
|
||||
netherLegacy.isChecked()
|
||||
? BCLNetherBiomeSourceConfig.NetherBiomeMapType.SQUARE
|
||||
: BCLNetherBiomeSourceConfig.NetherBiomeMapType.HEX,
|
||||
netherBiomeSize.getValue() * 16,
|
||||
netherVerticalBiomeSize.getValue() * 16,
|
||||
netherVertical.isChecked(),
|
||||
netherAmplified.isChecked()
|
||||
);
|
||||
|
||||
ChunkGenerator netherGenerator = (
|
||||
netherAmplified.isChecked()
|
||||
? betterxAmplifiedDimensions
|
||||
: betterxDimensions
|
||||
).get(LevelStem.NETHER);
|
||||
((BCLibNetherBiomeSource) netherGenerator.getBiomeSource()).setTogetherConfig(netherConfig);
|
||||
|
||||
updateConfiguration(LevelStem.NETHER, BuiltinDimensionTypes.NETHER, netherGenerator);
|
||||
} else {
|
||||
ChunkGenerator endGenerator = vanillaDimensions.get(LevelStem.NETHER);
|
||||
updateConfiguration(LevelStem.NETHER, BuiltinDimensionTypes.NETHER, endGenerator);
|
||||
}
|
||||
|
||||
final WorldCreationUiState acc = createWorldScreen.getUiState();
|
||||
final Holder<WorldPreset> configuredPreset = acc.getWorldType().preset();
|
||||
if (configuredPreset != null && configuredPreset.value() instanceof TogetherWorldPreset worldPreset) {
|
||||
ResourceKey<WorldPreset> key = configuredPreset.unwrapKey().orElse(null);
|
||||
if (key == null) key = worldPreset.parentKey;
|
||||
|
||||
acc.setWorldType(new WorldCreationUiState.WorldTypeEntry(Holder.direct(
|
||||
worldPreset.withDimensions(
|
||||
createWorldScreen
|
||||
.getUiState()
|
||||
.getSettings()
|
||||
.selectedDimensions()
|
||||
.dimensions(),
|
||||
key
|
||||
)
|
||||
)));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void updateConfiguration(
|
||||
ResourceKey<LevelStem> dimensionKey,
|
||||
ResourceKey<DimensionType> dimensionTypeKey,
|
||||
ChunkGenerator chunkGenerator
|
||||
) {
|
||||
createWorldScreen.getUiState().updateDimensions(
|
||||
(registryAccess, worldDimensions) -> new WorldDimensions(LevelGenUtil.replaceGenerator(
|
||||
dimensionKey,
|
||||
dimensionTypeKey,
|
||||
registryAccess,
|
||||
worldDimensions.dimensions(),
|
||||
chunkGenerator
|
||||
))
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected LayoutComponent<?, ?> createScreen(LayoutComponent<?, ?> content) {
|
||||
VerticalStack rows = new VerticalStack(fill(), fill()).setDebugName("title stack");
|
||||
|
||||
if (topPadding > 0) rows.addSpacer(topPadding);
|
||||
rows.add(content);
|
||||
if (bottomPadding > 0) rows.addSpacer(bottomPadding);
|
||||
|
||||
if (sidePadding <= 0) return rows;
|
||||
|
||||
HorizontalStack cols = new HorizontalStack(fill(), fill()).setDebugName("padded side");
|
||||
cols.addSpacer(sidePadding);
|
||||
cols.add(rows);
|
||||
cols.addSpacer(sidePadding);
|
||||
return cols;
|
||||
}
|
||||
|
||||
Button netherButton, endButton;
|
||||
VerticalScroll<?> scroller;
|
||||
HorizontalStack title;
|
||||
|
||||
@Override
|
||||
protected LayoutComponent<?, ?> initContent() {
|
||||
BCLEndBiomeSourceConfig endConfig = BCLEndBiomeSourceConfig.VANILLA;
|
||||
BCLNetherBiomeSourceConfig netherConfig = BCLNetherBiomeSourceConfig.VANILLA;
|
||||
|
||||
final WorldCreationUiState acc = createWorldScreen.getUiState();
|
||||
final Holder<WorldPreset> configuredPreset = acc.getWorldType().preset();
|
||||
if (configuredPreset.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();
|
||||
}
|
||||
}
|
||||
|
||||
LayoutComponent<?, ? extends LayoutComponent<?, ?>> netherPage = netherPage(netherConfig);
|
||||
LayoutComponent<?, ? extends LayoutComponent<?, ?>> endPage = endPage(endConfig);
|
||||
|
||||
Tabs main = new Tabs(fill(), fill()).setPadding(8, 0, 0, 0);
|
||||
main.addPage(Component.translatable("title.bclib.the_nether"), VerticalScroll.create(netherPage));
|
||||
main.addSpacer(8);
|
||||
main.addPage(Component.translatable("title.bclib.the_end"), scroller = VerticalScroll.create(endPage));
|
||||
netherButton = main.getButton(0);
|
||||
endButton = main.getButton(1);
|
||||
|
||||
title = new HorizontalStack(fit(), fit()).setDebugName("title bar").alignBottom();
|
||||
title.addImage(fixed(22), fixed(22), BCLibLayoutScreen.BCLIB_LOGO_WHITE_LOCATION, Size.of(256))
|
||||
.setDebugName("icon");
|
||||
title.addSpacer(4);
|
||||
VerticalStack logos = title.addColumn(fit(), fit());
|
||||
logos.addImage(fixed(178 / 3), fixed(40 / 3), WelcomeScreen.BETTERX_LOCATION, Size.of(178, 40));
|
||||
logos.add(super.createTitle());
|
||||
logos.addSpacer(2);
|
||||
|
||||
main.addFiller();
|
||||
main.addComponent(title);
|
||||
|
||||
|
||||
VerticalStack rows = new VerticalStack(fill(), fill());
|
||||
rows.add(main);
|
||||
rows.addSpacer(4);
|
||||
rows.addButton(fit(), fit(), CommonComponents.GUI_DONE).onPress((bt) -> {
|
||||
updateSettings();
|
||||
onClose();
|
||||
}).alignRight();
|
||||
|
||||
main.onPageChange((tabs, idx) -> {
|
||||
targetT = 1 - idx;
|
||||
});
|
||||
|
||||
return rows;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void renderBackgroundLayer(GuiGraphics guiGraphics, int i, int j, float f) {
|
||||
guiGraphics.fill(0, 0, width, height, 0xBD343444);
|
||||
}
|
||||
|
||||
record IconState(int left, int top, int size) {
|
||||
//easing curves from https://easings.net/de
|
||||
static double easeInOutQuint(double t) {
|
||||
return t < 0.5 ? 16 * t * t * t * t * t : 1 - Math.pow(-2 * t + 2, 5) / 2;
|
||||
}
|
||||
|
||||
static double easeOutBounce(double x) {
|
||||
final double n1 = 7.5625;
|
||||
final double d1 = 2.75;
|
||||
|
||||
if (x < 1 / d1) {
|
||||
return n1 * x * x;
|
||||
} else if (x < 2 / d1) {
|
||||
return n1 * (x -= 1.5 / d1) * x + 0.75;
|
||||
} else if (x < 2.5 / d1) {
|
||||
return n1 * (x -= 2.25 / d1) * x + 0.9375;
|
||||
} else {
|
||||
return n1 * (x -= 2.625 / d1) * x + 0.984375;
|
||||
}
|
||||
}
|
||||
|
||||
static int lerp(double t, int x0, int x1) {
|
||||
return (int) ((1 - t) * x0 + t * x1);
|
||||
}
|
||||
}
|
||||
|
||||
IconState netherOff, netherOn, endOff, endOn;
|
||||
double iconT = 0.5;
|
||||
double targetT = 1;
|
||||
|
||||
@Override
|
||||
public void render(GuiGraphics guiGraphics, int i, int j, float f) {
|
||||
super.render(guiGraphics, i, j, f);
|
||||
final double SPEED = 0.05;
|
||||
if (targetT < iconT && iconT > 0) iconT = Math.max(0, iconT - f * SPEED);
|
||||
else if (targetT > iconT && iconT < 1) iconT = Math.min(1, iconT + f * SPEED);
|
||||
|
||||
final double t;
|
||||
if (iconT > 0 && iconT < 1) {
|
||||
if (targetT > iconT) {
|
||||
t = IconState.easeOutBounce(iconT);
|
||||
} else {
|
||||
t = 1 - IconState.easeOutBounce(1 - iconT);
|
||||
}
|
||||
} else t = iconT;
|
||||
|
||||
if (endButton != null) {
|
||||
if (endOff == null) {
|
||||
endOff = new IconState(
|
||||
endButton.getScreenBounds().right() - 12,
|
||||
endButton.getScreenBounds().top - 7,
|
||||
16
|
||||
);
|
||||
endOn = new IconState(
|
||||
(title.getScreenBounds().left - endButton.getScreenBounds().right()) / 2
|
||||
+ endButton.getScreenBounds().right()
|
||||
- 14,
|
||||
scroller.getScreenBounds().top - 16,
|
||||
32
|
||||
);
|
||||
}
|
||||
guiGraphics.pose().pushPose();
|
||||
guiGraphics.pose().translate(
|
||||
IconState.lerp(t, endOn.left, endOff.left),
|
||||
IconState.lerp(t, endOn.top, endOff.top),
|
||||
0
|
||||
);
|
||||
int size = IconState.lerp(t, endOn.size, endOff.size);
|
||||
RenderHelper.renderImage(
|
||||
guiGraphics, 0, 0,
|
||||
size,
|
||||
size,
|
||||
WelcomeScreen.ICON_BETTEREND,
|
||||
Size.of(32), new Rectangle(0, 0, 32, 32),
|
||||
(float) 1
|
||||
);
|
||||
guiGraphics.pose().popPose();
|
||||
}
|
||||
|
||||
if (netherButton != null) {
|
||||
if (netherOff == null) {
|
||||
netherOff = new IconState(
|
||||
netherButton.getScreenBounds().right() - 12,
|
||||
netherButton.getScreenBounds().top - 7,
|
||||
16
|
||||
);
|
||||
netherOn = endOn;
|
||||
}
|
||||
guiGraphics.pose().pushPose();
|
||||
guiGraphics.pose().translate(
|
||||
IconState.lerp(t, netherOff.left, netherOn.left),
|
||||
IconState.lerp(t, netherOff.top, netherOn.top),
|
||||
0
|
||||
);
|
||||
int size = IconState.lerp(t, netherOff.size, netherOn.size);
|
||||
RenderHelper.renderImage(
|
||||
guiGraphics, 0, 0,
|
||||
size,
|
||||
size,
|
||||
WelcomeScreen.ICON_BETTERNETHER,
|
||||
Size.of(32), new Rectangle(0, 0, 32, 32),
|
||||
(float) 1
|
||||
);
|
||||
guiGraphics.pose().popPose();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,28 +0,0 @@
|
|||
package org.betterx.bclib.mixin.client;
|
||||
|
||||
import org.betterx.worlds.together.worldPreset.client.WorldPresetsClient;
|
||||
|
||||
import net.minecraft.client.gui.screens.worldselection.PresetEditor;
|
||||
import net.minecraft.client.gui.screens.worldselection.WorldCreationUiState;
|
||||
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.api.Environment;
|
||||
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
@Environment(EnvType.CLIENT)
|
||||
@Mixin(WorldCreationUiState.class)
|
||||
public abstract class WorldCreationUIStateMixin {
|
||||
@Shadow
|
||||
public abstract WorldCreationUiState.WorldTypeEntry getWorldType();
|
||||
|
||||
@Inject(method = "getPresetEditor", at = @At("HEAD"), cancellable = true)
|
||||
private void bclib_getPresetEditor(CallbackInfoReturnable<PresetEditor> cir) {
|
||||
final PresetEditor editor = WorldPresetsClient.getSetupScreenForPreset(this.getWorldType().preset());
|
||||
if (editor != null) cir.setReturnValue(editor);
|
||||
}
|
||||
}
|
|
@ -1,22 +0,0 @@
|
|||
package org.betterx.bclib.registry;
|
||||
|
||||
import org.betterx.bclib.BCLib;
|
||||
import org.betterx.bclib.config.Configs;
|
||||
import org.betterx.worlds.together.worldPreset.WorldPresets;
|
||||
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
import net.minecraft.world.level.levelgen.presets.WorldPreset;
|
||||
|
||||
public class PresetsRegistry {
|
||||
public static ResourceKey<WorldPreset> BCL_WORLD = WorldPresets.createKey(BCLib.makeID("normal"));
|
||||
public static ResourceKey<WorldPreset> BCL_WORLD_LARGE = WorldPresets.createKey(BCLib.makeID("large"));
|
||||
public static ResourceKey<WorldPreset> BCL_WORLD_AMPLIFIED = WorldPresets.createKey(BCLib.makeID("amplified"));
|
||||
public static ResourceKey<WorldPreset> BCL_WORLD_17 = WorldPresets.createKey(BCLib.makeID("legacy_17"));
|
||||
|
||||
public static void register() {
|
||||
if (Configs.CLIENT_CONFIG.forceBetterXPreset())
|
||||
WorldPresets.setDEFAULT(BCL_WORLD);
|
||||
else
|
||||
WorldPresets.setDEFAULT(net.minecraft.world.level.levelgen.presets.WorldPresets.NORMAL);
|
||||
}
|
||||
}
|
|
@ -1,24 +0,0 @@
|
|||
package org.betterx.bclib.registry;
|
||||
|
||||
import org.betterx.bclib.client.gui.screens.WorldSetupScreen;
|
||||
import org.betterx.worlds.together.worldPreset.client.WorldPresetsClient;
|
||||
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.api.Environment;
|
||||
|
||||
@Environment(EnvType.CLIENT)
|
||||
public class PresetsRegistryClient {
|
||||
public static void onLoad() {
|
||||
WorldPresetsClient.registerCustomizeUI(PresetsRegistry.BCL_WORLD, WorldSetupScreen::new);
|
||||
|
||||
WorldPresetsClient.registerCustomizeUI(
|
||||
PresetsRegistry.BCL_WORLD_LARGE,
|
||||
WorldSetupScreen::new
|
||||
);
|
||||
|
||||
WorldPresetsClient.registerCustomizeUI(
|
||||
PresetsRegistry.BCL_WORLD_AMPLIFIED,
|
||||
WorldSetupScreen::new
|
||||
);
|
||||
}
|
||||
}
|
|
@ -4,7 +4,6 @@ import org.betterx.bclib.BCLib;
|
|||
import org.betterx.bclib.api.v2.levelgen.biomes.BCLBiomeRegistry;
|
||||
import org.betterx.bclib.api.v2.levelgen.biomes.BiomeData;
|
||||
import org.betterx.bclib.api.v3.datagen.RegistrySupplier;
|
||||
import org.betterx.datagen.bclib.preset.WorldPresetDataProvider;
|
||||
import org.betterx.datagen.bclib.tests.TestBiomes;
|
||||
import org.betterx.datagen.bclib.tests.TestConfiguredFeatures;
|
||||
import org.betterx.datagen.bclib.tests.TestPlacedFeatures;
|
||||
|
@ -21,7 +20,6 @@ import net.minecraft.world.level.biome.Biome;
|
|||
import net.minecraft.world.level.levelgen.NoiseGeneratorSettings;
|
||||
import net.minecraft.world.level.levelgen.feature.ConfiguredFeature;
|
||||
import net.minecraft.world.level.levelgen.placement.PlacedFeature;
|
||||
import net.minecraft.world.level.levelgen.presets.WorldPreset;
|
||||
import net.minecraft.world.level.levelgen.structure.Structure;
|
||||
import net.minecraft.world.level.levelgen.structure.StructureSet;
|
||||
|
||||
|
@ -68,7 +66,6 @@ public class BCLRegistrySupplier extends RegistrySupplier {
|
|||
NoiseGeneratorSettings.DIRECT_CODEC,
|
||||
NoiseTypesDataProvider::bootstrap
|
||||
);
|
||||
registries.add(Registries.WORLD_PRESET, WorldPreset.DIRECT_CODEC, WorldPresetDataProvider::bootstrap);
|
||||
|
||||
return registries;
|
||||
}
|
||||
|
|
|
@ -4,7 +4,6 @@ import org.betterx.bclib.BCLib;
|
|||
import org.betterx.datagen.bclib.advancement.BCLAdvancementDataProvider;
|
||||
import org.betterx.datagen.bclib.advancement.RecipeDataProvider;
|
||||
import org.betterx.datagen.bclib.integrations.NullscapeBiomes;
|
||||
import org.betterx.datagen.bclib.preset.WorldPresetDataProvider;
|
||||
import org.betterx.datagen.bclib.tests.TestBiomes;
|
||||
import org.betterx.datagen.bclib.tests.TestWorldgenProvider;
|
||||
import org.betterx.datagen.bclib.worldgen.BCLibRegistriesDataProvider;
|
||||
|
@ -38,7 +37,6 @@ public class BCLibDatagen implements DataGeneratorEntrypoint {
|
|||
pack.addProvider(BlockTagProvider::new);
|
||||
pack.addProvider(ItemTagProvider::new);
|
||||
pack.addProvider(RecipeDataProvider::new);
|
||||
pack.addProvider(WorldPresetDataProvider::new);
|
||||
pack.addProvider(BCLibRegistriesDataProvider::new);
|
||||
pack.addProvider(BCLAdvancementDataProvider::new);
|
||||
}
|
||||
|
|
|
@ -1,141 +0,0 @@
|
|||
package org.betterx.datagen.bclib.preset;
|
||||
|
||||
import org.betterx.bclib.api.v2.generator.BCLChunkGenerator;
|
||||
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.registry.PresetsRegistry;
|
||||
import org.betterx.worlds.together.levelgen.WorldGenUtil;
|
||||
import org.betterx.worlds.together.worldPreset.TogetherWorldPreset;
|
||||
import org.betterx.worlds.together.worldPreset.WorldPresets;
|
||||
|
||||
import net.minecraft.core.Holder;
|
||||
import net.minecraft.core.HolderLookup;
|
||||
import net.minecraft.core.registries.Registries;
|
||||
import net.minecraft.data.worldgen.BootstapContext;
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
import net.minecraft.tags.WorldPresetTags;
|
||||
import net.minecraft.world.level.dimension.LevelStem;
|
||||
import net.minecraft.world.level.levelgen.NoiseGeneratorSettings;
|
||||
import net.minecraft.world.level.levelgen.presets.WorldPreset;
|
||||
|
||||
import net.fabricmc.fabric.api.datagen.v1.FabricDataOutput;
|
||||
import net.fabricmc.fabric.api.datagen.v1.provider.FabricTagProvider;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
public class WorldPresetDataProvider extends FabricTagProvider<WorldPreset> {
|
||||
|
||||
|
||||
/**
|
||||
* Constructs a new {@link FabricTagProvider} with the default computed path.
|
||||
*
|
||||
* <p>Common implementations of this class are provided.
|
||||
*
|
||||
* @param output the {@link FabricDataOutput} instance
|
||||
* @param registriesFuture the backing registry for the tag type
|
||||
*/
|
||||
public WorldPresetDataProvider(
|
||||
FabricDataOutput output,
|
||||
CompletableFuture<HolderLookup.Provider> registriesFuture
|
||||
) {
|
||||
super(output, Registries.WORLD_PRESET, registriesFuture);
|
||||
}
|
||||
|
||||
public static void bootstrap(BootstapContext<WorldPreset> bootstrapContext) {
|
||||
final WorldPresets.BootstrapData ctx = new WorldPresets.BootstrapData(bootstrapContext);
|
||||
|
||||
bootstrapContext.register(PresetsRegistry.BCL_WORLD, createNormal(ctx));
|
||||
bootstrapContext.register(PresetsRegistry.BCL_WORLD_LARGE, createLarge(ctx));
|
||||
bootstrapContext.register(PresetsRegistry.BCL_WORLD_AMPLIFIED, createAmplified(ctx));
|
||||
bootstrapContext.register(PresetsRegistry.BCL_WORLD_17, createLegacy(ctx));
|
||||
}
|
||||
|
||||
private static WorldPreset createLegacy(WorldPresets.BootstrapData ctx) {
|
||||
return buildPreset(
|
||||
ctx.overworldStem,
|
||||
ctx.netherContext,
|
||||
BCLNetherBiomeSourceConfig.MINECRAFT_17, ctx.endContext,
|
||||
BCLEndBiomeSourceConfig.MINECRAFT_17
|
||||
);
|
||||
}
|
||||
|
||||
private static WorldPreset createAmplified(WorldPresets.BootstrapData ctx) {
|
||||
Holder<NoiseGeneratorSettings> amplifiedBiomeGenerator = ctx.noiseSettings
|
||||
.getOrThrow(NoiseGeneratorSettings.AMPLIFIED);
|
||||
|
||||
WorldGenUtil.Context amplifiedNetherContext = new WorldGenUtil.Context(
|
||||
ctx.netherContext.dimension,
|
||||
ctx.netherContext.structureSets,
|
||||
ctx.noiseSettings.getOrThrow(BCLChunkGenerator.AMPLIFIED_NETHER)
|
||||
);
|
||||
|
||||
return buildPreset(
|
||||
ctx.makeNoiseBasedOverworld(
|
||||
ctx.overworldStem.generator().getBiomeSource(),
|
||||
amplifiedBiomeGenerator
|
||||
),
|
||||
amplifiedNetherContext, BCLNetherBiomeSourceConfig.MINECRAFT_18_AMPLIFIED,
|
||||
ctx.endContext, BCLEndBiomeSourceConfig.MINECRAFT_20_AMPLIFIED
|
||||
);
|
||||
}
|
||||
|
||||
private static WorldPreset createLarge(WorldPresets.BootstrapData ctx) {
|
||||
Holder<NoiseGeneratorSettings> largeBiomeGenerator = ctx.noiseSettings
|
||||
.getOrThrow(NoiseGeneratorSettings.LARGE_BIOMES);
|
||||
return buildPreset(
|
||||
ctx.makeNoiseBasedOverworld(
|
||||
ctx.overworldStem.generator().getBiomeSource(),
|
||||
largeBiomeGenerator
|
||||
),
|
||||
ctx.netherContext, BCLNetherBiomeSourceConfig.MINECRAFT_18_LARGE,
|
||||
ctx.endContext, BCLEndBiomeSourceConfig.MINECRAFT_20_LARGE
|
||||
);
|
||||
}
|
||||
|
||||
private static WorldPreset createNormal(WorldPresets.BootstrapData ctx) {
|
||||
return buildPreset(
|
||||
ctx.overworldStem,
|
||||
ctx.netherContext, BCLNetherBiomeSourceConfig.DEFAULT,
|
||||
ctx.endContext, BCLEndBiomeSourceConfig.DEFAULT
|
||||
);
|
||||
}
|
||||
|
||||
private 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)
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void addTags(HolderLookup.Provider arg) {
|
||||
final FabricTagProvider<WorldPreset>.FabricTagBuilder builder = getOrCreateTagBuilder(WorldPresetTags.NORMAL);
|
||||
builder.add(PresetsRegistry.BCL_WORLD);
|
||||
builder.add(PresetsRegistry.BCL_WORLD_AMPLIFIED);
|
||||
builder.add(PresetsRegistry.BCL_WORLD_LARGE);
|
||||
}
|
||||
}
|
|
@ -4,7 +4,6 @@ import org.betterx.worlds.together.surfaceRules.SurfaceRuleRegistry;
|
|||
import org.betterx.worlds.together.tag.v3.TagManager;
|
||||
import org.betterx.worlds.together.util.Logger;
|
||||
import org.betterx.worlds.together.world.WorldConfig;
|
||||
import org.betterx.worlds.together.worldPreset.WorldPresets;
|
||||
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
|
||||
|
@ -27,9 +26,7 @@ public class WorldsTogether {
|
|||
TagManager.ensureStaticallyLoaded();
|
||||
SurfaceRuleRegistry.ensureStaticallyLoaded();
|
||||
|
||||
|
||||
WorldConfig.registerModCache(WorldsTogether.MOD_ID);
|
||||
WorldPresets.ensureStaticallyLoaded();
|
||||
}
|
||||
|
||||
public static ResourceLocation makeID(String s) {
|
||||
|
|
|
@ -1,9 +1,7 @@
|
|||
package org.betterx.worlds.together.client;
|
||||
|
||||
import org.betterx.worlds.together.worldPreset.client.WorldPresetsClient;
|
||||
|
||||
public class WorldsTogetherClient {
|
||||
public static void onInitializeClient() {
|
||||
WorldPresetsClient.setupClientside();
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,127 +0,0 @@
|
|||
package org.betterx.worlds.together.levelgen;
|
||||
|
||||
import org.betterx.bclib.api.v2.levelgen.biomes.BCLBiomeRegistry;
|
||||
import org.betterx.bclib.api.v2.levelgen.biomes.BiomeAPI;
|
||||
import org.betterx.worlds.together.biomesource.BiomeSourceWithConfig;
|
||||
import org.betterx.worlds.together.biomesource.ReloadableBiomeSource;
|
||||
import org.betterx.worlds.together.chunkgenerator.EnforceableChunkGenerator;
|
||||
import org.betterx.worlds.together.tag.v3.CommonBiomeTags;
|
||||
import org.betterx.worlds.together.world.event.WorldBootstrap;
|
||||
import org.betterx.worlds.together.worldPreset.TogetherWorldPreset;
|
||||
|
||||
import net.minecraft.core.Holder;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.core.RegistryAccess;
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
import net.minecraft.tags.BiomeTags;
|
||||
import net.minecraft.tags.TagKey;
|
||||
import net.minecraft.world.level.biome.Biome;
|
||||
import net.minecraft.world.level.chunk.ChunkGenerator;
|
||||
import net.minecraft.world.level.dimension.LevelStem;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
class BiomeRepairHelper {
|
||||
private Map<ResourceKey<LevelStem>, ChunkGenerator> vanillaDimensions = null;
|
||||
|
||||
public Registry<LevelStem> repairBiomeSourceInAllDimensions(
|
||||
RegistryAccess registryAccess,
|
||||
Registry<LevelStem> dimensionRegistry
|
||||
) {
|
||||
Map<ResourceKey<LevelStem>, ChunkGenerator> dimensions = TogetherWorldPreset.loadWorldDimensions();
|
||||
for (var entry : dimensionRegistry.entrySet()) {
|
||||
boolean didRepair = false;
|
||||
ResourceKey<LevelStem> key = entry.getKey();
|
||||
LevelStem loadedStem = entry.getValue();
|
||||
|
||||
ChunkGenerator referenceGenerator = dimensions.get(key);
|
||||
if (referenceGenerator instanceof EnforceableChunkGenerator enforcer) {
|
||||
final ChunkGenerator loadedChunkGenerator = loadedStem.generator();
|
||||
|
||||
// we ensure that all biomes with a dimensional Tag are properly added to the correct biome source
|
||||
// using the correct type
|
||||
processBiomeTagsForDimension(key);
|
||||
|
||||
// if the loaded ChunkGenerator is not the one we expect from vanilla, we will load the vanilla
|
||||
// ones and mark all modded biomes with the respective dimension
|
||||
registerAllBiomesFromVanillaDimension(key);
|
||||
|
||||
// now compare the reference world settings (the ones that were created when the world was
|
||||
// started) with the settings that were loaded by the game.
|
||||
// If those do not match, we will create a new ChunkGenerator / BiomeSources with appropriate
|
||||
// settings
|
||||
if (enforcer.togetherShouldRepair(loadedChunkGenerator)) {
|
||||
dimensionRegistry = enforcer.enforceGeneratorInWorldGenSettings(
|
||||
registryAccess,
|
||||
key,
|
||||
loadedStem.type().unwrapKey().orElseThrow(),
|
||||
loadedChunkGenerator,
|
||||
dimensionRegistry
|
||||
);
|
||||
didRepair = true;
|
||||
} else if (loadedChunkGenerator.getBiomeSource() instanceof BiomeSourceWithConfig lodedSource) {
|
||||
if (referenceGenerator.getBiomeSource() instanceof BiomeSourceWithConfig refSource) {
|
||||
if (!refSource.getTogetherConfig().sameConfig(lodedSource.getTogetherConfig())) {
|
||||
lodedSource.setTogetherConfig(refSource.getTogetherConfig());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (!didRepair) {
|
||||
if (loadedStem.generator().getBiomeSource() instanceof ReloadableBiomeSource reload) {
|
||||
reload.reloadBiomes();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
return dimensionRegistry;
|
||||
}
|
||||
|
||||
private void processBiomeTagsForDimension(ResourceKey<LevelStem> key) {
|
||||
if (key.equals(LevelStem.NETHER)) {
|
||||
preprocessBiomeTags(BiomeTags.IS_NETHER, BiomeAPI.BiomeType.NETHER);
|
||||
} else if (key.equals(LevelStem.END)) {
|
||||
preprocessBiomeTags(CommonBiomeTags.IS_END_HIGHLAND, BiomeAPI.BiomeType.END_LAND);
|
||||
preprocessBiomeTags(CommonBiomeTags.IS_END_MIDLAND, BiomeAPI.BiomeType.END_LAND);
|
||||
preprocessBiomeTags(CommonBiomeTags.IS_END_BARRENS, BiomeAPI.BiomeType.END_BARRENS);
|
||||
preprocessBiomeTags(CommonBiomeTags.IS_SMALL_END_ISLAND, BiomeAPI.BiomeType.END_VOID);
|
||||
preprocessBiomeTags(CommonBiomeTags.IS_END_CENTER, BiomeAPI.BiomeType.END_CENTER);
|
||||
preprocessBiomeTags(BiomeTags.IS_END, BiomeAPI.BiomeType.END_LAND);
|
||||
}
|
||||
}
|
||||
|
||||
private void preprocessBiomeTags(TagKey<Biome> tag, BiomeAPI.BiomeType targetType) {
|
||||
if (WorldBootstrap.getLastRegistryAccess() != null) {
|
||||
WorldBootstrap.getLastRegistryAccess()
|
||||
.registry(tag.registry())
|
||||
.map(r -> r.getTagOrEmpty(tag))
|
||||
.ifPresent(iter -> {
|
||||
for (Holder<Biome> biomeHolder : iter) {
|
||||
BCLBiomeRegistry.registerIfUnknown(biomeHolder, targetType);
|
||||
}
|
||||
});
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
private void registerAllBiomesFromVanillaDimension(
|
||||
ResourceKey<LevelStem> key
|
||||
) {
|
||||
BiomeAPI.BiomeType type = BiomeAPI.BiomeType.getMainBiomeTypeForDimension(key);
|
||||
|
||||
if (type != null) {
|
||||
if (vanillaDimensions == null) {
|
||||
vanillaDimensions = TogetherWorldPreset.getDimensionsMap(net.minecraft.world.level.levelgen.presets.WorldPresets.NORMAL);
|
||||
}
|
||||
|
||||
final ChunkGenerator vanillaDim = vanillaDimensions.getOrDefault(key, null);
|
||||
if (vanillaDim != null && vanillaDim.getBiomeSource() != null) {
|
||||
for (Holder<Biome> biomeHolder : vanillaDim.getBiomeSource().possibleBiomes()) {
|
||||
BCLBiomeRegistry.registerIfUnknown(biomeHolder, type);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,97 +1,19 @@
|
|||
package org.betterx.worlds.together.levelgen;
|
||||
|
||||
import org.betterx.worlds.together.WorldsTogether;
|
||||
import org.betterx.worlds.together.world.BiomeSourceWithNoiseRelatedSettings;
|
||||
import org.betterx.worlds.together.world.BiomeSourceWithSeed;
|
||||
import org.betterx.worlds.together.world.WorldConfig;
|
||||
import org.betterx.worlds.together.world.event.WorldBootstrap;
|
||||
import org.betterx.worlds.together.worldPreset.WorldPresets;
|
||||
|
||||
import net.minecraft.core.Holder;
|
||||
import net.minecraft.core.HolderGetter;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.core.RegistryAccess;
|
||||
import net.minecraft.core.registries.Registries;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.util.RandomSource;
|
||||
import net.minecraft.world.level.biome.Biome;
|
||||
import net.minecraft.world.level.dimension.DimensionType;
|
||||
import net.minecraft.world.level.dimension.LevelStem;
|
||||
import net.minecraft.world.level.levelgen.NoiseBasedChunkGenerator;
|
||||
import net.minecraft.world.level.levelgen.NoiseGeneratorSettings;
|
||||
import net.minecraft.world.level.levelgen.WorldDimensions;
|
||||
import net.minecraft.world.level.levelgen.presets.WorldPreset;
|
||||
import net.minecraft.world.level.levelgen.structure.StructureSet;
|
||||
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
|
||||
public class WorldGenUtil {
|
||||
public static final String TAG_PRESET = "preset";
|
||||
public static final String TAG_GENERATOR = "generator";
|
||||
|
||||
public static WorldDimensions createWorldFromPreset(
|
||||
ResourceKey<WorldPreset> preset,
|
||||
RegistryAccess registryAccess,
|
||||
long seed,
|
||||
boolean generateStructures,
|
||||
boolean generateBonusChest
|
||||
) {
|
||||
WorldDimensions settings = registryAccess
|
||||
.registryOrThrow(Registries.WORLD_PRESET)
|
||||
.getHolderOrThrow(preset)
|
||||
.value()
|
||||
.createWorldDimensions();
|
||||
|
||||
for (LevelStem stem : settings.dimensions()) {
|
||||
if (stem.generator().getBiomeSource() instanceof BiomeSourceWithSeed bcl) {
|
||||
bcl.setSeed(seed);
|
||||
}
|
||||
|
||||
if (stem.generator().getBiomeSource() instanceof BiomeSourceWithNoiseRelatedSettings bcl
|
||||
&& stem.generator() instanceof NoiseBasedChunkGenerator noiseGenerator) {
|
||||
bcl.onLoadGeneratorSettings(noiseGenerator.generatorSettings().value());
|
||||
}
|
||||
}
|
||||
|
||||
return settings;
|
||||
}
|
||||
|
||||
public static WorldDimensions createDefaultWorldFromPreset(
|
||||
RegistryAccess registryAccess,
|
||||
long seed,
|
||||
boolean generateStructures,
|
||||
boolean generateBonusChest
|
||||
) {
|
||||
return createWorldFromPreset(
|
||||
WorldPresets.getDEFAULT(),
|
||||
registryAccess,
|
||||
seed,
|
||||
generateStructures,
|
||||
generateBonusChest
|
||||
);
|
||||
}
|
||||
|
||||
public static WorldDimensions createDefaultWorldFromPreset(RegistryAccess registryAccess, long seed) {
|
||||
return createDefaultWorldFromPreset(registryAccess, seed, true, false);
|
||||
}
|
||||
|
||||
public static WorldDimensions createDefaultWorldFromPreset(RegistryAccess registryAccess) {
|
||||
return createDefaultWorldFromPreset(registryAccess, RandomSource.create().nextLong());
|
||||
}
|
||||
|
||||
public static CompoundTag getPresetsNbt() {
|
||||
return WorldConfig.getCompoundTag(WorldsTogether.MOD_ID, TAG_PRESET);
|
||||
}
|
||||
|
||||
public static CompoundTag getGeneratorNbt() {
|
||||
CompoundTag root = WorldConfig.getRootTag(WorldsTogether.MOD_ID);
|
||||
if (root.contains(TAG_GENERATOR))
|
||||
return WorldConfig.getCompoundTag(WorldsTogether.MOD_ID, TAG_GENERATOR);
|
||||
return null;
|
||||
}
|
||||
|
||||
public static class Context extends StemContext {
|
||||
public Context(
|
||||
Holder<DimensionType> dimension,
|
||||
|
@ -118,16 +40,6 @@ public class WorldGenUtil {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@ApiStatus.Internal
|
||||
public static Registry<LevelStem> repairBiomeSourceInAllDimensions(
|
||||
RegistryAccess registryAccess,
|
||||
Registry<LevelStem> dimensionRegistry
|
||||
) {
|
||||
return new BiomeRepairHelper().repairBiomeSourceInAllDimensions(registryAccess, dimensionRegistry);
|
||||
}
|
||||
|
||||
public static ResourceLocation getBiomeID(Biome biome) {
|
||||
ResourceLocation id = null;
|
||||
RegistryAccess access = WorldBootstrap.getLastRegistryAccessOrElseBuiltin();
|
||||
|
|
|
@ -1,22 +1,18 @@
|
|||
package org.betterx.worlds.together.mixin.client;
|
||||
|
||||
import org.betterx.worlds.together.world.event.WorldBootstrap;
|
||||
import org.betterx.worlds.together.worldPreset.WorldPresets;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
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.WorldCreationUiState;
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
import net.minecraft.world.level.levelgen.presets.WorldPreset;
|
||||
import net.minecraft.world.level.storage.LevelStorageSource;
|
||||
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.ModifyArg;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
|
@ -43,12 +39,6 @@ public abstract class CreateWorldScreen_Mixin {
|
|||
//WorldBootstrap.InGUI.registryReadyOnNewWorld(worldGenSettingsComponent);
|
||||
}
|
||||
|
||||
//Change the WorldPreset that is selected by default on the Create World Screen
|
||||
@ModifyArg(method = "openFresh", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/screens/worldselection/CreateWorldScreen;<init>(Lnet/minecraft/client/Minecraft;Lnet/minecraft/client/gui/screens/Screen;Lnet/minecraft/client/gui/screens/worldselection/WorldCreationContext;Ljava/util/Optional;Ljava/util/OptionalLong;)V"))
|
||||
private static Optional<ResourceKey<WorldPreset>> wt_NewDefault(Optional<ResourceKey<WorldPreset>> preset) {
|
||||
return Optional.of(WorldPresets.getDEFAULT());
|
||||
}
|
||||
|
||||
//this is called when a new world is first created
|
||||
@Inject(method = "createNewWorldDirectory", at = @At("RETURN"))
|
||||
void wt_createNewWorld(CallbackInfoReturnable<Optional<LevelStorageSource.LevelStorageAccess>> cir) {
|
||||
|
|
|
@ -1,35 +0,0 @@
|
|||
package org.betterx.worlds.together.mixin.common;
|
||||
|
||||
import org.betterx.worlds.together.WorldsTogether;
|
||||
import org.betterx.worlds.together.worldPreset.WorldPresets;
|
||||
|
||||
import net.minecraft.server.dedicated.DedicatedServerProperties;
|
||||
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.ModifyArg;
|
||||
|
||||
import java.util.Properties;
|
||||
|
||||
@Mixin(DedicatedServerProperties.class)
|
||||
public class DedicatedServerPropertiesMixin {
|
||||
//Make sure the default server properties use our Default World Preset by default (read from "level-type")
|
||||
@ModifyArg(method = "<init>", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/dedicated/DedicatedServerProperties$WorldDimensionData;<init>(Lcom/google/gson/JsonObject;Ljava/lang/String;)V"))
|
||||
protected String wt_defaultPreset(String string) {
|
||||
if (WorldsTogether.FORCE_SERVER_TO_BETTERX_PRESET) {
|
||||
return WorldPresets.getDEFAULT().location().toString();
|
||||
}
|
||||
|
||||
return string;
|
||||
}
|
||||
|
||||
@ModifyArg(method = "<init>", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/dedicated/Settings;<init>(Ljava/util/Properties;)V"))
|
||||
private static Properties wt_defaultPreset(Properties property) {
|
||||
//init default value level preset in server.properties
|
||||
property.setProperty(
|
||||
"level-type",
|
||||
property.getProperty("level-type", WorldPresets.getDEFAULT().location().toString())
|
||||
);
|
||||
return property;
|
||||
}
|
||||
}
|
|
@ -1,25 +0,0 @@
|
|||
package org.betterx.worlds.together.mixin.common;
|
||||
|
||||
import org.betterx.worlds.together.worldPreset.WorldPresets;
|
||||
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
import net.minecraft.server.dedicated.DedicatedServerProperties;
|
||||
import net.minecraft.world.level.levelgen.presets.WorldPreset;
|
||||
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.ModifyArg;
|
||||
|
||||
@Mixin(DedicatedServerProperties.WorldDimensionData.class)
|
||||
public class WorldGenPropertiesMixin {
|
||||
// @ModifyArg(method = "create", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/levelgen/presets/WorldPreset;createWorldGenSettings(JZZ)Lnet/minecraft/world/level/levelgen/WorldGenSettings;"))
|
||||
// public long wt_getSeed(long seed) {
|
||||
// return seed;
|
||||
// }
|
||||
|
||||
//Make sure Servers use our Default World Preset
|
||||
@ModifyArg(method = "create", at = @At(value = "INVOKE", ordinal = 0, target = "Lnet/minecraft/core/Registry;getHolder(Lnet/minecraft/resources/ResourceKey;)Ljava/util/Optional;"))
|
||||
private ResourceKey<WorldPreset> wt_returnDefault(ResourceKey<WorldPreset> resourceKey) {
|
||||
return WorldPresets.getDEFAULT();
|
||||
}
|
||||
}
|
|
@ -1,51 +0,0 @@
|
|||
package org.betterx.worlds.together.mixin.common;
|
||||
|
||||
import org.betterx.worlds.together.worldPreset.TogetherWorldPreset;
|
||||
|
||||
import com.mojang.datafixers.kinds.App;
|
||||
import com.mojang.serialization.Codec;
|
||||
import com.mojang.serialization.codecs.RecordCodecBuilder;
|
||||
import net.minecraft.core.registries.Registries;
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
import net.minecraft.world.level.dimension.LevelStem;
|
||||
import net.minecraft.world.level.levelgen.presets.WorldPreset;
|
||||
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.ModifyArg;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.function.Function;
|
||||
|
||||
@Mixin(WorldPreset.class)
|
||||
public class WorldPresetMixin {
|
||||
@ModifyArg(method = "<clinit>", at = @At(value = "INVOKE", target = "Lcom/mojang/serialization/codecs/RecordCodecBuilder;create(Ljava/util/function/Function;)Lcom/mojang/serialization/Codec;"))
|
||||
private static Function<RecordCodecBuilder.Instance<WorldPreset>, ? extends App<RecordCodecBuilder.Mu<WorldPreset>, WorldPreset>> wt_injectCodec(
|
||||
Function<RecordCodecBuilder.Instance<WorldPreset>, ? extends App<RecordCodecBuilder.Mu<WorldPreset>, WorldPreset>> builder
|
||||
) {
|
||||
final Function<RecordCodecBuilder.Instance<WorldPreset>, App<RecordCodecBuilder.Mu<WorldPreset>, WorldPreset>> CODEC_FUNCTION = builderInstance -> {
|
||||
RecordCodecBuilder<WorldPreset, Map<ResourceKey<LevelStem>, LevelStem>> dimensionsBuilder = Codec
|
||||
.unboundedMap(
|
||||
ResourceKey.codec(Registries.LEVEL_STEM),
|
||||
LevelStem.CODEC
|
||||
)
|
||||
.fieldOf("dimensions")
|
||||
.forGetter((wp) -> (wp instanceof WorldPresetAccessor)
|
||||
? ((WorldPresetAccessor) wp).bcl_getDimensions()
|
||||
: null);
|
||||
|
||||
RecordCodecBuilder<WorldPreset, Optional<Integer>> sortBuilder = Codec.INT
|
||||
.optionalFieldOf("sort_order")
|
||||
.forGetter(wp -> (wp instanceof TogetherWorldPreset)
|
||||
? Optional.of(((TogetherWorldPreset) wp).sortOrder)
|
||||
: Optional.empty());
|
||||
|
||||
return builderInstance
|
||||
.group(dimensionsBuilder, sortBuilder)
|
||||
.apply(builderInstance, TogetherWorldPreset::new);
|
||||
};
|
||||
|
||||
return CODEC_FUNCTION;
|
||||
}
|
||||
}
|
|
@ -1,16 +1,10 @@
|
|||
package org.betterx.worlds.together.world.event;
|
||||
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
import net.minecraft.world.level.chunk.ChunkGenerator;
|
||||
import net.minecraft.world.level.dimension.LevelStem;
|
||||
import net.minecraft.world.level.storage.LevelStorageSource;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public interface BeforeWorldLoad {
|
||||
void prepareWorld(
|
||||
LevelStorageSource.LevelStorageAccess storageAccess,
|
||||
Map<ResourceKey<LevelStem>, ChunkGenerator> settings,
|
||||
boolean isNewWorld,
|
||||
boolean isServer
|
||||
);
|
||||
|
|
|
@ -3,12 +3,8 @@ package org.betterx.worlds.together.world.event;
|
|||
import org.betterx.bclib.BCLib;
|
||||
import org.betterx.bclib.config.Configs;
|
||||
import org.betterx.worlds.together.WorldsTogether;
|
||||
import org.betterx.worlds.together.levelgen.WorldGenUtil;
|
||||
import org.betterx.worlds.together.mixin.common.WorldPresetAccessor;
|
||||
import org.betterx.worlds.together.surfaceRules.SurfaceRuleUtil;
|
||||
import org.betterx.worlds.together.world.WorldConfig;
|
||||
import org.betterx.worlds.together.worldPreset.TogetherWorldPreset;
|
||||
import org.betterx.worlds.together.worldPreset.WorldPresets;
|
||||
|
||||
import net.minecraft.client.gui.screens.worldselection.WorldCreationContext;
|
||||
import net.minecraft.client.gui.screens.worldselection.WorldCreationUiState;
|
||||
|
@ -19,7 +15,6 @@ import net.minecraft.core.RegistryAccess;
|
|||
import net.minecraft.core.registries.Registries;
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
import net.minecraft.server.RegistryLayer;
|
||||
import net.minecraft.world.level.chunk.ChunkGenerator;
|
||||
import net.minecraft.world.level.dimension.LevelStem;
|
||||
import net.minecraft.world.level.levelgen.WorldDimensions;
|
||||
import net.minecraft.world.level.levelgen.presets.WorldPreset;
|
||||
|
@ -27,8 +22,6 @@ import net.minecraft.world.level.storage.LevelResource;
|
|||
import net.minecraft.world.level.storage.LevelStorageSource;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.function.Consumer;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
|
@ -72,27 +65,6 @@ public class WorldBootstrap {
|
|||
}
|
||||
}
|
||||
|
||||
private static Holder<WorldPreset> defaultServerPreset() {
|
||||
return WorldPresets.get(
|
||||
LAST_REGISTRY_ACCESS,
|
||||
WorldPresets.getDEFAULT()
|
||||
);
|
||||
}
|
||||
|
||||
private static WorldDimensions defaultServerDimensions() {
|
||||
final Holder<WorldPreset> defaultPreset = defaultServerPreset();
|
||||
return defaultServerDimensions(defaultPreset);
|
||||
}
|
||||
|
||||
private static WorldDimensions defaultServerDimensions(Holder<WorldPreset> defaultPreset) {
|
||||
final WorldDimensions dimensions;
|
||||
if (defaultPreset.value() instanceof TogetherWorldPreset t) {
|
||||
dimensions = t.getWorldDimensions();
|
||||
} else {
|
||||
dimensions = TogetherWorldPreset.getWorldDimensions(net.minecraft.world.level.levelgen.presets.WorldPresets.NORMAL);
|
||||
}
|
||||
return dimensions;
|
||||
}
|
||||
|
||||
private static Holder<WorldPreset> presetFromDatapack(Holder<WorldPreset> currentPreset) {
|
||||
if (currentPreset != null && LAST_REGISTRY_ACCESS != null) {
|
||||
|
@ -117,21 +89,11 @@ public class WorldBootstrap {
|
|||
File levelDat = levelStorageAccess.getLevelPath(LevelResource.LEVEL_DATA_FILE).toFile();
|
||||
if (!levelDat.exists()) {
|
||||
WorldsTogether.LOGGER.info("Creating a new World, no fixes needed");
|
||||
final WorldDimensions dimensions = Helpers.defaultServerDimensions();
|
||||
|
||||
WorldBootstrap.setupWorld(
|
||||
levelStorageAccess, TogetherWorldPreset.getDimensionMap(dimensions),
|
||||
true, true
|
||||
);
|
||||
|
||||
Holder<WorldPreset> currentPreset = Helpers.defaultServerPreset();
|
||||
writeWorldPresets(dimensions, currentPreset);
|
||||
WorldBootstrap.setupWorld(levelStorageAccess, true, true);
|
||||
finishedWorldLoad();
|
||||
} else {
|
||||
WorldBootstrap.setupWorld(
|
||||
levelStorageAccess, TogetherWorldPreset.loadWorldDimensions(),
|
||||
false, true
|
||||
);
|
||||
WorldBootstrap.setupWorld(levelStorageAccess, false, true);
|
||||
finishedWorldLoad();
|
||||
}
|
||||
}
|
||||
|
@ -172,9 +134,7 @@ public class WorldBootstrap {
|
|||
currentPreset = Helpers.presetFromDatapack(currentPreset);
|
||||
Holder<WorldPreset> newPreset = setupNewWorldCommon(
|
||||
levelStorageAccess.get(),
|
||||
currentPreset,
|
||||
uiState.getSettings().selectedDimensions(),
|
||||
recreated
|
||||
currentPreset
|
||||
);
|
||||
if (newPreset != null && newPreset != currentPreset) {
|
||||
uiState.setWorldType(new WorldCreationUiState.WorldTypeEntry(newPreset));
|
||||
|
@ -187,21 +147,9 @@ public class WorldBootstrap {
|
|||
|
||||
static Holder<WorldPreset> setupNewWorldCommon(
|
||||
LevelStorageSource.LevelStorageAccess levelStorageAccess,
|
||||
Holder<WorldPreset> currentPreset,
|
||||
WorldDimensions worldDims,
|
||||
boolean recreated
|
||||
Holder<WorldPreset> currentPreset
|
||||
) {
|
||||
final WorldDimensions dimensions;
|
||||
if (currentPreset != null && currentPreset.value() instanceof TogetherWorldPreset t) {
|
||||
dimensions = t.getWorldDimensions();
|
||||
} else if (recreated) {
|
||||
dimensions = worldDims;
|
||||
} else {
|
||||
dimensions = TogetherWorldPreset.getWorldDimensions(net.minecraft.world.level.levelgen.presets.WorldPresets.NORMAL);
|
||||
}
|
||||
|
||||
setupWorld(levelStorageAccess, TogetherWorldPreset.getDimensionMap(dimensions), true, false);
|
||||
writeWorldPresets(worldDims, currentPreset);
|
||||
setupWorld(levelStorageAccess, true, false);
|
||||
finishedWorldLoad();
|
||||
|
||||
return currentPreset;
|
||||
|
@ -218,7 +166,6 @@ public class WorldBootstrap {
|
|||
var levelStorageAccess = levelSource.createAccess(levelID);
|
||||
WorldBootstrap.setupWorld(
|
||||
levelStorageAccess,
|
||||
TogetherWorldPreset.loadWorldDimensions(),
|
||||
false, false
|
||||
);
|
||||
levelStorageAccess.close();
|
||||
|
@ -255,7 +202,7 @@ public class WorldBootstrap {
|
|||
) {
|
||||
try {
|
||||
var levelStorageAccess = levelSource.createAccess(levelID);
|
||||
InGUI.setupNewWorldCommon(levelStorageAccess, worldPreset, worldDims, false);
|
||||
InGUI.setupNewWorldCommon(levelStorageAccess, worldPreset);
|
||||
levelStorageAccess.close();
|
||||
} catch (Exception e) {
|
||||
WorldsTogether.LOGGER.error("Failed to initialize data in world", e);
|
||||
|
@ -265,14 +212,12 @@ public class WorldBootstrap {
|
|||
|
||||
private static void setupWorld(
|
||||
LevelStorageSource.LevelStorageAccess levelStorageAccess,
|
||||
Map<ResourceKey<LevelStem>, ChunkGenerator> dimensions,
|
||||
boolean newWorld, boolean isServer
|
||||
) {
|
||||
try {
|
||||
Helpers.initializeWorldConfig(levelStorageAccess, newWorld);
|
||||
WorldEventsImpl.BEFORE_WORLD_LOAD.emit(e -> e.prepareWorld(
|
||||
levelStorageAccess,
|
||||
dimensions,
|
||||
newWorld, isServer
|
||||
));
|
||||
} catch (Exception e) {
|
||||
|
@ -280,17 +225,6 @@ public class WorldBootstrap {
|
|||
}
|
||||
}
|
||||
|
||||
private static void writeWorldPresets(WorldDimensions dimensions, Holder<WorldPreset> currentPreset) {
|
||||
currentPreset = WorldEventsImpl.ADAPT_WORLD_PRESET.emit(currentPreset, dimensions);
|
||||
|
||||
if (currentPreset != null && currentPreset.value() instanceof WorldPresetAccessor acc) {
|
||||
TogetherWorldPreset.writeWorldPresetSettings(acc.bcl_getDimensions());
|
||||
} else {
|
||||
WorldsTogether.LOGGER.error("Failed writing together File");
|
||||
TogetherWorldPreset.writeWorldPresetSettings(dimensions);
|
||||
}
|
||||
}
|
||||
|
||||
public static void finishedWorldLoad() {
|
||||
WorldEventsImpl.ON_WORLD_LOAD.emit(OnWorldLoad::onLoad);
|
||||
}
|
||||
|
@ -323,19 +257,6 @@ public class WorldBootstrap {
|
|||
public static LayeredRegistryAccess<RegistryLayer> enforceInLayeredRegistry(LayeredRegistryAccess<RegistryLayer> registries) {
|
||||
RegistryAccess access = registries.compositeAccess();
|
||||
Helpers.onRegistryReady(access);
|
||||
final Registry<LevelStem> dimensions = access.registryOrThrow(Registries.LEVEL_STEM);
|
||||
final Registry<LevelStem> changedDimensions = WorldGenUtil.repairBiomeSourceInAllDimensions(access, dimensions);
|
||||
if (dimensions != changedDimensions) {
|
||||
if (Configs.MAIN_CONFIG.verboseLogging()) {
|
||||
WorldsTogether.LOGGER.info("Loading originally configured Dimensions in World.");
|
||||
}
|
||||
registries = registries.replaceFrom(
|
||||
RegistryLayer.DIMENSIONS,
|
||||
new RegistryAccess.ImmutableRegistryAccess(List.of(changedDimensions)).freeze()
|
||||
);
|
||||
//this will generate a new access object we have to use from now on...
|
||||
Helpers.onRegistryReady(registries.compositeAccess());
|
||||
}
|
||||
return registries;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,247 +0,0 @@
|
|||
package org.betterx.worlds.together.worldPreset;
|
||||
|
||||
import org.betterx.bclib.BCLib;
|
||||
import org.betterx.worlds.together.WorldsTogether;
|
||||
import org.betterx.worlds.together.levelgen.WorldGenUtil;
|
||||
import org.betterx.worlds.together.mixin.common.WorldPresetAccessor;
|
||||
import org.betterx.worlds.together.world.WorldConfig;
|
||||
import org.betterx.worlds.together.world.event.WorldBootstrap;
|
||||
|
||||
import com.mojang.serialization.Codec;
|
||||
import com.mojang.serialization.Dynamic;
|
||||
import com.mojang.serialization.Lifecycle;
|
||||
import com.mojang.serialization.codecs.RecordCodecBuilder;
|
||||
import net.minecraft.core.MappedRegistry;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.core.RegistryAccess;
|
||||
import net.minecraft.core.registries.Registries;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.nbt.NbtOps;
|
||||
import net.minecraft.nbt.Tag;
|
||||
import net.minecraft.resources.RegistryOps;
|
||||
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.WorldDimensions;
|
||||
import net.minecraft.world.level.levelgen.presets.WorldPreset;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class TogetherWorldPreset extends WorldPreset {
|
||||
public final int sortOrder;
|
||||
|
||||
private static int NEXT_IN_SORT_ORDER = 1000;
|
||||
private final WorldDimensions worldDimensions;
|
||||
@Nullable
|
||||
public final ResourceKey<WorldPreset> parentKey;
|
||||
|
||||
public TogetherWorldPreset(
|
||||
Map<ResourceKey<LevelStem>, LevelStem> map,
|
||||
Optional<Integer> sortOrder
|
||||
) {
|
||||
this(map, sortOrder.orElse(NEXT_IN_SORT_ORDER++), null);
|
||||
}
|
||||
|
||||
public TogetherWorldPreset(
|
||||
Map<ResourceKey<LevelStem>, LevelStem> map,
|
||||
Optional<Integer> sortOrder,
|
||||
@Nullable ResourceKey<WorldPreset> parentKey
|
||||
) {
|
||||
this(map, sortOrder.orElse(NEXT_IN_SORT_ORDER++), parentKey);
|
||||
}
|
||||
|
||||
public TogetherWorldPreset(
|
||||
Map<ResourceKey<LevelStem>, LevelStem> map,
|
||||
int sortOrder
|
||||
) {
|
||||
this(map, sortOrder, null);
|
||||
}
|
||||
|
||||
public TogetherWorldPreset(
|
||||
Map<ResourceKey<LevelStem>, LevelStem> map,
|
||||
int sortOrder,
|
||||
@Nullable ResourceKey<WorldPreset> parentKey
|
||||
) {
|
||||
super(map);
|
||||
this.sortOrder = sortOrder;
|
||||
this.worldDimensions = buildWorldDimensions(map);
|
||||
this.parentKey = parentKey;
|
||||
}
|
||||
|
||||
public static WorldDimensions buildWorldDimensions(Map<ResourceKey<LevelStem>, LevelStem> map) {
|
||||
Registry<LevelStem> registry = new MappedRegistry<>(Registries.LEVEL_STEM, Lifecycle.experimental());
|
||||
for (var entry : map.entrySet()) {
|
||||
Registry.register(registry, entry.getKey(), entry.getValue());
|
||||
}
|
||||
|
||||
return new WorldDimensions(registry);
|
||||
}
|
||||
|
||||
public WorldDimensions getWorldDimensions() {
|
||||
return this.worldDimensions;
|
||||
}
|
||||
|
||||
public TogetherWorldPreset withDimensions(
|
||||
Registry<LevelStem> dimensions,
|
||||
@Nullable ResourceKey<WorldPreset> parentKey
|
||||
) {
|
||||
Map<ResourceKey<LevelStem>, LevelStem> map = new HashMap<>();
|
||||
for (var entry : dimensions.entrySet()) {
|
||||
ResourceKey<LevelStem> key = entry.getKey();
|
||||
LevelStem stem = entry.getValue();
|
||||
map.put(key, stem);
|
||||
}
|
||||
return new TogetherWorldPreset(map, sortOrder, parentKey);
|
||||
}
|
||||
|
||||
private Map<ResourceKey<LevelStem>, LevelStem> getDimensions() {
|
||||
return ((WorldPresetAccessor) this).bcl_getDimensions();
|
||||
}
|
||||
|
||||
public Map<ResourceKey<LevelStem>, ChunkGenerator> getDimensionsMap() {
|
||||
return DimensionsWrapper.build(getDimensions());
|
||||
}
|
||||
|
||||
public LevelStem getDimension(ResourceKey<LevelStem> key) {
|
||||
return getDimensions().get(key);
|
||||
}
|
||||
|
||||
public static void writeWorldPresetSettings(WorldDimensions dimensions) {
|
||||
writeWorldPresetSettings(dimensions.dimensions());
|
||||
}
|
||||
|
||||
public static void writeWorldPresetSettings(Registry<LevelStem> dimensions) {
|
||||
DimensionsWrapper wrapper = new DimensionsWrapper(dimensions);
|
||||
writeWorldPresetSettings(wrapper);
|
||||
}
|
||||
|
||||
public static void writeWorldPresetSettings(Map<ResourceKey<LevelStem>, LevelStem> settings) {
|
||||
DimensionsWrapper wrapper = new DimensionsWrapper(DimensionsWrapper.build(settings));
|
||||
writeWorldPresetSettings(wrapper);
|
||||
}
|
||||
|
||||
public static void writeWorldPresetSettingsDirect(Map<ResourceKey<LevelStem>, ChunkGenerator> settings) {
|
||||
DimensionsWrapper wrapper = new DimensionsWrapper(settings);
|
||||
writeWorldPresetSettings(wrapper);
|
||||
}
|
||||
|
||||
private static void writeWorldPresetSettings(DimensionsWrapper wrapper) {
|
||||
final RegistryOps<Tag> registryOps = RegistryOps.create(
|
||||
NbtOps.INSTANCE,
|
||||
WorldBootstrap.getLastRegistryAccessOrElseBuiltin()
|
||||
);
|
||||
final var encodeResult = DimensionsWrapper.CODEC.encodeStart(registryOps, wrapper);
|
||||
|
||||
if (encodeResult.result().isPresent()) {
|
||||
final CompoundTag settingsNbt = WorldConfig.getRootTag(WorldsTogether.MOD_ID);
|
||||
settingsNbt.put(WorldGenUtil.TAG_PRESET, encodeResult.result().get());
|
||||
} else {
|
||||
WorldsTogether.LOGGER.error("Unable to encode world generator settings for level.dat.");
|
||||
}
|
||||
|
||||
WorldConfig.saveFile(WorldsTogether.MOD_ID);
|
||||
}
|
||||
|
||||
private static DimensionsWrapper DEFAULT_DIMENSIONS_WRAPPER = null;
|
||||
|
||||
public static @NotNull Map<ResourceKey<LevelStem>, ChunkGenerator> loadWorldDimensions() {
|
||||
try {
|
||||
final RegistryAccess registryAccess = WorldBootstrap.getLastRegistryAccessOrElseBuiltin();
|
||||
final RegistryOps<Tag> registryOps = RegistryOps.create(NbtOps.INSTANCE, registryAccess);
|
||||
if (DEFAULT_DIMENSIONS_WRAPPER == null) {
|
||||
DEFAULT_DIMENSIONS_WRAPPER = new DimensionsWrapper(TogetherWorldPreset.getDimensionsMap(WorldPresets.getDEFAULT()));
|
||||
}
|
||||
|
||||
CompoundTag presetNBT = WorldGenUtil.getPresetsNbt();
|
||||
if (!presetNBT.contains("dimensions")) {
|
||||
return DEFAULT_DIMENSIONS_WRAPPER.dimensions;
|
||||
}
|
||||
|
||||
Optional<DimensionsWrapper> oLevelStem = DimensionsWrapper.CODEC
|
||||
.parse(new Dynamic<>(registryOps, presetNBT))
|
||||
.resultOrPartial(WorldsTogether.LOGGER::error);
|
||||
|
||||
|
||||
return oLevelStem.orElse(DEFAULT_DIMENSIONS_WRAPPER).dimensions;
|
||||
} catch (Exception e) {
|
||||
BCLib.LOGGER.error("Failed to load Dimensions", e);
|
||||
return DEFAULT_DIMENSIONS_WRAPPER.dimensions;
|
||||
}
|
||||
}
|
||||
|
||||
public static @Nullable Registry<LevelStem> getDimensions(ResourceKey<WorldPreset> key) {
|
||||
RegistryAccess access = WorldBootstrap.getLastRegistryAccessOrElseBuiltin();
|
||||
if (access == null) {
|
||||
WorldsTogether.LOGGER.error("No valid registry found!");
|
||||
return null;
|
||||
}
|
||||
var preset = access.registryOrThrow(Registries.WORLD_PRESET).getHolder(key);
|
||||
if (preset.isEmpty()) return null;
|
||||
return preset
|
||||
.get()
|
||||
.value()
|
||||
.createWorldDimensions()
|
||||
.dimensions();
|
||||
}
|
||||
|
||||
public static @NotNull Map<ResourceKey<LevelStem>, ChunkGenerator> getDimensionsMap(ResourceKey<WorldPreset> key) {
|
||||
Registry<LevelStem> reg = getDimensions(key);
|
||||
if (reg == null) return new HashMap<>();
|
||||
return DimensionsWrapper.build(reg);
|
||||
}
|
||||
|
||||
public static @NotNull Map<ResourceKey<LevelStem>, ChunkGenerator> getDimensionMap(WorldDimensions worldDims) {
|
||||
return DimensionsWrapper.build(worldDims.dimensions());
|
||||
}
|
||||
|
||||
public static @NotNull WorldDimensions getWorldDimensions(ResourceKey<WorldPreset> key) {
|
||||
Registry<LevelStem> reg = getDimensions(key);
|
||||
return new WorldDimensions(reg);
|
||||
}
|
||||
|
||||
private static class DimensionsWrapper {
|
||||
public static final Codec<DimensionsWrapper> CODEC = RecordCodecBuilder.create(instance -> instance
|
||||
.group(Codec.unboundedMap(
|
||||
ResourceKey.codec(Registries.LEVEL_STEM),
|
||||
ChunkGenerator.CODEC
|
||||
)
|
||||
.fieldOf("dimensions")
|
||||
.orElse(new HashMap<>())
|
||||
.forGetter(o -> o.dimensions))
|
||||
.apply(instance, DimensionsWrapper::new));
|
||||
final Map<ResourceKey<LevelStem>, ChunkGenerator> dimensions;
|
||||
|
||||
static Map<ResourceKey<LevelStem>, ChunkGenerator> build(Registry<LevelStem> dimensions) {
|
||||
Map<ResourceKey<LevelStem>, ChunkGenerator> map = new HashMap<>();
|
||||
for (var entry : dimensions.entrySet()) {
|
||||
ResourceKey<LevelStem> key = entry.getKey();
|
||||
LevelStem stem = entry.getValue();
|
||||
map.put(key, stem.generator());
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
static Map<ResourceKey<LevelStem>, ChunkGenerator> build(Map<ResourceKey<LevelStem>, LevelStem> input) {
|
||||
Map<ResourceKey<LevelStem>, ChunkGenerator> map = new HashMap<>();
|
||||
for (var entry : input.entrySet()) {
|
||||
ResourceKey<LevelStem> key = entry.getKey();
|
||||
LevelStem stem = entry.getValue();
|
||||
map.put(key, stem.generator());
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
|
||||
DimensionsWrapper(Registry<LevelStem> dimensions) {
|
||||
this(build(dimensions));
|
||||
}
|
||||
|
||||
private DimensionsWrapper(Map<ResourceKey<LevelStem>, ChunkGenerator> dimensions) {
|
||||
this.dimensions = dimensions;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,142 +0,0 @@
|
|||
package org.betterx.worlds.together.worldPreset;
|
||||
|
||||
import org.betterx.bclib.api.v2.levelgen.biomes.BCLBiome;
|
||||
import org.betterx.bclib.api.v2.levelgen.biomes.BCLBiomeRegistry;
|
||||
import org.betterx.worlds.together.levelgen.WorldGenUtil;
|
||||
|
||||
import net.minecraft.core.Holder;
|
||||
import net.minecraft.core.HolderGetter;
|
||||
import net.minecraft.core.RegistryAccess;
|
||||
import net.minecraft.core.registries.Registries;
|
||||
import net.minecraft.data.worldgen.BootstapContext;
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.level.biome.*;
|
||||
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.NoiseBasedChunkGenerator;
|
||||
import net.minecraft.world.level.levelgen.NoiseGeneratorSettings;
|
||||
import net.minecraft.world.level.levelgen.placement.PlacedFeature;
|
||||
import net.minecraft.world.level.levelgen.presets.WorldPreset;
|
||||
import net.minecraft.world.level.levelgen.structure.StructureSet;
|
||||
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
|
||||
public class WorldPresets {
|
||||
private static ResourceKey<WorldPreset> DEFAULT = net.minecraft.world.level.levelgen.presets.WorldPresets.NORMAL;
|
||||
|
||||
public static Holder<WorldPreset> get(RegistryAccess access, ResourceKey<WorldPreset> key) {
|
||||
return access
|
||||
.registryOrThrow(Registries.WORLD_PRESET)
|
||||
.getHolderOrThrow(key);
|
||||
}
|
||||
|
||||
public static void ensureStaticallyLoaded() {
|
||||
|
||||
}
|
||||
|
||||
public static ResourceKey<WorldPreset> createKey(ResourceLocation loc) {
|
||||
return ResourceKey.create(Registries.WORLD_PRESET, loc);
|
||||
}
|
||||
|
||||
public static ResourceKey<WorldPreset> getDEFAULT() {
|
||||
return DEFAULT;
|
||||
}
|
||||
|
||||
|
||||
@ApiStatus.Internal
|
||||
public static void setDEFAULT(ResourceKey<WorldPreset> DEFAULT) {
|
||||
WorldPresets.DEFAULT = DEFAULT;
|
||||
}
|
||||
|
||||
public static class BootstrapData {
|
||||
public final HolderGetter<NoiseGeneratorSettings> noiseSettings;
|
||||
public final HolderGetter<Biome> biomes;
|
||||
public final HolderGetter<PlacedFeature> placedFeatures;
|
||||
public final HolderGetter<StructureSet> structureSets;
|
||||
public final LevelStem netherStem;
|
||||
public final LevelStem endStem;
|
||||
public final LevelStem overworldStem;
|
||||
public final Holder<DimensionType> netherDimensionType;
|
||||
public final Holder<DimensionType> endDimensionType;
|
||||
public final Holder<DimensionType> overworldDimensionType;
|
||||
|
||||
public final WorldGenUtil.Context netherContext;
|
||||
public final WorldGenUtil.Context endContext;
|
||||
|
||||
public final HolderGetter<MultiNoiseBiomeSourceParameterList> parameterLists;
|
||||
|
||||
public BootstrapData(BootstapContext<WorldPreset> bootstapContext) {
|
||||
this.parameterLists = bootstapContext.lookup(Registries.MULTI_NOISE_BIOME_SOURCE_PARAMETER_LIST);
|
||||
final HolderGetter<DimensionType> dimensionTypes = bootstapContext.lookup(Registries.DIMENSION_TYPE);
|
||||
|
||||
this.noiseSettings = bootstapContext.lookup(Registries.NOISE_SETTINGS);
|
||||
this.biomes = bootstapContext.lookup(Registries.BIOME);
|
||||
this.placedFeatures = bootstapContext.lookup(Registries.PLACED_FEATURE);
|
||||
this.structureSets = bootstapContext.lookup(Registries.STRUCTURE_SET);
|
||||
|
||||
this.overworldDimensionType = dimensionTypes.getOrThrow(BuiltinDimensionTypes.OVERWORLD);
|
||||
Holder.Reference<MultiNoiseBiomeSourceParameterList> overworldParameters = parameterLists
|
||||
.getOrThrow(MultiNoiseBiomeSourceParameterLists.OVERWORLD);
|
||||
MultiNoiseBiomeSource overworldBiomeSource = MultiNoiseBiomeSource.createFromPreset(overworldParameters);
|
||||
Holder<NoiseGeneratorSettings> defaultOverworldNoise = this.noiseSettings.getOrThrow(NoiseGeneratorSettings.OVERWORLD);
|
||||
this.overworldStem = makeNoiseBasedOverworld(overworldBiomeSource, defaultOverworldNoise);
|
||||
|
||||
this.netherDimensionType = dimensionTypes.getOrThrow(BuiltinDimensionTypes.NETHER);
|
||||
Holder.Reference<MultiNoiseBiomeSourceParameterList> netherParameters = parameterLists
|
||||
.getOrThrow(MultiNoiseBiomeSourceParameterLists.NETHER);
|
||||
Holder<NoiseGeneratorSettings> defaultNetherNoise = this.noiseSettings.getOrThrow(NoiseGeneratorSettings.NETHER);
|
||||
this.netherStem = new LevelStem(
|
||||
netherDimensionType,
|
||||
new NoiseBasedChunkGenerator(
|
||||
MultiNoiseBiomeSource.createFromPreset(netherParameters),
|
||||
defaultNetherNoise
|
||||
)
|
||||
);
|
||||
|
||||
this.endDimensionType = dimensionTypes.getOrThrow(BuiltinDimensionTypes.END);
|
||||
Holder<NoiseGeneratorSettings> defaultEndNoise = this.noiseSettings.getOrThrow(NoiseGeneratorSettings.END);
|
||||
this.endStem = new LevelStem(
|
||||
endDimensionType,
|
||||
new NoiseBasedChunkGenerator(TheEndBiomeSource.create(this.biomes), defaultEndNoise)
|
||||
);
|
||||
|
||||
|
||||
Holder<NoiseGeneratorSettings> netherSettings, endSettings;
|
||||
if (this.netherStem.generator() instanceof NoiseBasedChunkGenerator nether) {
|
||||
netherSettings = nether.generatorSettings();
|
||||
} else {
|
||||
netherSettings = this.noiseSettings.getOrThrow(NoiseGeneratorSettings.NETHER);
|
||||
}
|
||||
|
||||
if (this.endStem.generator() instanceof NoiseBasedChunkGenerator nether) {
|
||||
endSettings = nether.generatorSettings();
|
||||
} else {
|
||||
endSettings = this.noiseSettings.getOrThrow(NoiseGeneratorSettings.END);
|
||||
}
|
||||
|
||||
HolderGetter<BCLBiome> bclBiomes = bootstapContext.lookup(BCLBiomeRegistry.BCL_BIOMES_REGISTRY);
|
||||
this.netherContext = new WorldGenUtil.Context(
|
||||
this.netherStem.type(),
|
||||
this.structureSets,
|
||||
netherSettings
|
||||
);
|
||||
|
||||
this.endContext = new WorldGenUtil.Context(
|
||||
this.endStem.type(),
|
||||
this.structureSets,
|
||||
endSettings
|
||||
);
|
||||
}
|
||||
|
||||
private LevelStem makeOverworld(ChunkGenerator chunkGenerator) {
|
||||
return new LevelStem(this.overworldDimensionType, chunkGenerator);
|
||||
}
|
||||
|
||||
public LevelStem makeNoiseBasedOverworld(BiomeSource biomeSource, Holder<NoiseGeneratorSettings> holder) {
|
||||
return this.makeOverworld(new NoiseBasedChunkGenerator(biomeSource, holder));
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,46 +0,0 @@
|
|||
package org.betterx.worlds.together.worldPreset.client;
|
||||
|
||||
import org.betterx.worlds.together.worldPreset.TogetherWorldPreset;
|
||||
|
||||
import net.minecraft.client.gui.screens.worldselection.PresetEditor;
|
||||
import net.minecraft.core.Holder;
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
import net.minecraft.world.level.levelgen.presets.WorldPreset;
|
||||
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.api.Environment;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
@Environment(EnvType.CLIENT)
|
||||
public class WorldPresetsClient {
|
||||
private static final Map<Optional<ResourceKey<WorldPreset>>, PresetEditor> EDITORS = new HashMap<>();
|
||||
|
||||
public static void registerCustomizeUI(ResourceKey<WorldPreset> key, PresetEditor setupScreen) {
|
||||
if (setupScreen != null) {
|
||||
EDITORS.put(Optional.of(key), setupScreen);
|
||||
}
|
||||
}
|
||||
|
||||
public static PresetEditor getSetupScreenForPreset(Holder<WorldPreset> holder) {
|
||||
if (holder != null) {
|
||||
PresetEditor editor = EDITORS.get(holder.unwrapKey());
|
||||
|
||||
if (editor == null
|
||||
&& holder.isBound()
|
||||
&& holder.value() instanceof TogetherWorldPreset preset
|
||||
&& preset.parentKey != null
|
||||
) {
|
||||
editor = EDITORS.get(Optional.of(preset.parentKey));
|
||||
}
|
||||
|
||||
return editor;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static void setupClientside() {
|
||||
}
|
||||
}
|
|
@ -14,7 +14,6 @@
|
|||
"LevelRendererMixin",
|
||||
"MinecraftMixin",
|
||||
"ModelManagerMixin",
|
||||
"WorldCreationUIStateMixin",
|
||||
"boat.BoatRendererMixin"
|
||||
],
|
||||
"injectors": {
|
||||
|
|
|
@ -4,11 +4,11 @@
|
|||
"package": "org.betterx.worlds.together.mixin.common",
|
||||
"compatibilityLevel": "JAVA_17",
|
||||
"mixins": [
|
||||
"BiomeSourceMixin", "DedicatedServerPropertiesMixin", "DiggerItemAccessor", "MainDataMixin", "MainMixin",
|
||||
"BiomeSourceMixin", "DiggerItemAccessor", "MainDataMixin", "MainMixin",
|
||||
"MinecraftServerMixin", "MinecraftServerMixinLate", "NoiseBasedChunkGeneratorMixin",
|
||||
"NoiseGeneratorSettingsMixin", "RegistryDataLoaderMixin", "RegistryOpsAccessor", "TagLoaderMixin",
|
||||
"VanillaRegistriesMixin", "WorldGenPropertiesMixin", "WorldLoaderMixin", "WorldPresetAccessor",
|
||||
"WorldPresetMixin", "WorldStem_Mixin"
|
||||
"VanillaRegistriesMixin", "WorldLoaderMixin", "WorldPresetAccessor",
|
||||
"WorldStem_Mixin"
|
||||
],
|
||||
"injectors": {
|
||||
"defaultRequire": 1
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue