Prepared Custom WorldPreset UI

This commit is contained in:
Frank 2022-05-20 00:54:18 +02:00
parent 375eb09bb9
commit fdc068f6bb
5 changed files with 190 additions and 168 deletions

View file

@ -0,0 +1,23 @@
package org.betterx.bclib.mixin.common;
import net.minecraft.client.gui.screens.worldselection.PresetEditor;
import com.google.common.collect.Maps;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Redirect;
import java.util.Map;
@Mixin(PresetEditor.class)
interface PresetEditorMixin {
@Redirect(method = "<clinit>", at = @At(value = "INVOKE", target = "Ljava/util/Map;of(Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)Ljava/util/Map;"))
private static <K, V> Map<K, V> bcl_foo(K k1, V v1, K k2, V v2) {
Map<K, V> a = Maps.newHashMap();
a.put(k1, v1);
a.put(k2, v2);
return a;
}
}

View file

@ -1,5 +1,6 @@
package org.betterx.bclib.presets;
import net.minecraft.client.gui.screens.worldselection.PresetEditor;
import net.minecraft.core.Registry;
import net.minecraft.data.BuiltinRegistries;
import net.minecraft.resources.ResourceKey;
@ -10,10 +11,13 @@ import net.minecraft.world.level.levelgen.presets.WorldPreset;
import org.betterx.bclib.BCLib;
import org.betterx.bclib.api.tag.TagAPI;
import org.betterx.bclib.api.tag.TagType;
import org.betterx.bclib.gui.modmenu.MainScreen;
import java.util.Optional;
public class WorldPresets {
public static TagType.Simple<WorldPreset> WORLD_PRESETS =
TagAPI.registerType(BuiltinRegistries.WORLD_PRESET, "tag/worldgen/world_preset");
TagAPI.registerType(BuiltinRegistries.WORLD_PRESET, "tags/worldgen/world_preset");
public static ResourceKey<WorldPreset> BCL_WORLD = register(BCLib.makeID("normal"));
@ -21,6 +25,10 @@ public class WorldPresets {
ResourceKey<WorldPreset> key = ResourceKey.create(Registry.WORLD_PRESET_REGISTRY,
loc);
WORLD_PRESETS.addUntyped(WorldPresetTags.NORMAL, key.location());
PresetEditor.EDITORS.put(Optional.of(key),
(createWorldScreen, worldCreationContext) -> new MainScreen(createWorldScreen));
return key;
}

View file

@ -21,25 +21,21 @@
"title.bclib.filesync.progress": "Datenübertragung",
"message.bclib.filesync.progress": "Snychronisiere Dateien und Verzeichnise vom Server",
"message.bclib.filesync.progress.stage.empty": "",
"title.config.bclib.client.auto_sync.enabled": "Auto-Sync Aktivieren",
"title.config.bclib.client.auto_sync.acceptConfigs": "Konfiguration von Server annehmen",
"title.config.bclib.client.auto_sync.acceptFiles": "Dateien von Server annehmen",
"title.config.bclib.client.auto_sync.acceptMods": "Mods von Server annehmen",
"title.config.bclib.client.auto_sync.displayModInfo": "Warnung anzeigen, wenn Mods auf Server/Client unterschiedlich",
"title.config.bclib.client.auto_sync.debugHashes": "Erweiterete Logausgabe für Auto-Sync",
"title.config.bclib.generator.options.useOldBiomeGenerator": "Alten 1.17 Biome Generator verwenden",
"title.config.bclib.main.patches.applyPatches": "Automatisches Anwenden von Patches beim Laden eines Levels",
"title.config.bclib.main.patches.repairBiomesOnLoad": "Biomesource beim Laden eines Levels reparieren",
"title.config.bclib.client.ui.suppressExperimentalDialogOnLoad": "Experimenteller Warnbildschirm beim Laden deaktivieren",
"title.bclib.syncfiles.modInfo": "Mod Info",
"title.bclib.syncfiles.modlist": "Mod Information",
"message.bclib.syncfiles.modlist": "Im Folgenden wird der Status deiner installierten Mods angezeigt.\n\nAlle Mods, die lokal nicht vorhanden sind oder eine andere Version auf dem Server haben, werden synchronisiert.",
"title.bclib.modmissmatch": "Mod-Konflikt",
"message.bclib.modmissmatch": "Einige Mods auf diesem Rechner stimmen nicht mit der Version auf dem Server überein.\n\nNicht übereinstimmende Mods können zu merkwürdigem Spielverhalten oder Abstürzen führen. Bitte stellen Sie sicher, dass Sie die gleichen Mods wie auf dem Server verwenden.",
"message.bclib.datafixer.progress.waitbackup": "Ich warte auf das Ende der Sicherung. Dies kann eine Weile dauern!",
"message.bclib.datafixer.progress.reading": "Lese Daten",
"message.bclib.datafixer.progress.players": "Repariere Spieler",
@ -53,6 +49,6 @@
"message.bclib.datafixer.error": "Es gab Fehler beim Reparieren der Welt. Das bedeutet, dass dieser Level wahrscheinlich in einem inkonsistenten Zustand ist und Sie ihn nicht spielen sollten. Bitte stellen Sie Ihr Backup wieder her und beheben Sie die unten aufgeführten Fehler, bevor Sie es erneut versuchen.",
"title.bclib.datafixer.error.continue": "Continue and Mark as Fixed",
"title.config.bclib.main.ui.suppressExperimentalDialogOnLoad": "Disable Experimental Warning Screen on Load",
"tooltip.bclib.place_on": "Lebt auf: %s"
"tooltip.bclib.place_on": "Lebt auf: %s",
"generator.bclib.normal": "BetterX"
}

View file

@ -21,25 +21,21 @@
"title.bclib.filesync.progress": "File Transfer",
"message.bclib.filesync.progress": "Syncing File-Content with Server",
"message.bclib.filesync.progress.stage.empty": "",
"title.config.bclib.client.auto_sync.enabled": "Enable Auto-Sync",
"title.config.bclib.client.auto_sync.acceptConfigs": "Accept incoming Config Files",
"title.config.bclib.client.auto_sync.acceptFiles": "Accept incoming Files",
"title.config.bclib.client.auto_sync.acceptMods": "Accept incoming Mods",
"title.config.bclib.client.auto_sync.displayModInfo": "Display warning when Serverside Mods differ from Client",
"title.config.bclib.client.auto_sync.debugHashes": "Print Auto-Sync Debug-Hashes to Log",
"title.config.bclib.generator.options.useOldBiomeGenerator": "Use legacy 1.17 Biome Generator",
"title.config.bclib.main.patches.applyPatches": "Automatically apply patches when loading level",
"title.config.bclib.main.patches.repairBiomesOnLoad": "Fix Biomesource on level load",
"title.config.bclib.client.ui.suppressExperimentalDialogOnLoad": "Disable Experimental Warning Screen on Load",
"title.bclib.syncfiles.modInfo": "Mod Info",
"title.bclib.syncfiles.modlist": "Mod Information",
"message.bclib.syncfiles.modlist": "The following shows the state of your installed installed Mods.\n\nAll Mods that do not exist locally, or have a different version on the Server will be synchronized.",
"title.bclib.modmissmatch": "Mod Version Conflict",
"message.bclib.modmissmatch": "Some Mods on this client do not match the version of Mods on the Server.\n\nMismatching Mods can result in odd game behavior or crashes. Please make sue that you use the same mods as the server.",
"message.bclib.datafixer.progress.waitbackup": "Waiting for Backup to finish. This may take a while!",
"message.bclib.datafixer.progress.reading": "Reading Data",
"message.bclib.datafixer.progress.players": "Fixing Players",
@ -52,9 +48,8 @@
"title.bclib.datafixer.error": "Errors while fixing World",
"message.bclib.datafixer.error": "There were errors while repairing the world. This means that this level is probably in an inconsistent state and you should not play it. Please restore your backup and fix the errors below before trying again.",
"title.bclib.datafixer.error.continue": "Proceed and mark as fixed",
"title.config.bclib.client.rendering.customFogRendering": "Custom Fog Rendering",
"title.config.bclib.client.rendering.netherThickFog": "Nether Thick Fog",
"tooltip.bclib.place_on": "Survives on: %s"
"tooltip.bclib.place_on": "Survives on: %s",
"generator.bclib.normal": "BetterX"
}

View file

@ -4,50 +4,50 @@
"package": "org.betterx.bclib.mixin.common",
"compatibilityLevel": "JAVA_17",
"mixins": [
"BiomeMixin",
"BiomeGenerationSettingsAccessor",
"shears.DiggingEnchantmentMixin",
"shears.ItemPredicateBuilderMixin",
"LayerLightSectionStorageMixin",
"NoiseBasedChunkGeneratorMixin",
"NoiseGeneratorSettingsMixin",
"SurfaceRulesContextAccessor",
"EnchantingTableBlockMixin",
"shears.TripWireBlockMixin",
"StructuresAccessor",
"MobSpawnSettingsAccessor",
"shears.BeehiveBlockMixin",
"shears.PumpkinBlockMixin",
"shears.MushroomCowMixin",
"ComposterBlockAccessor",
"PotionBrewingAccessor",
"RecipeManagerAccessor",
"shears.SnowGolemMixin",
"MinecraftServerMixin",
"NetherBiomeDataMixin",
"PistonBaseBlockMixin",
"TheEndBiomeDataMixin",
"BlockStateBaseMixin",
"ChunkGeneratorMixin",
"WorldGenRegionMixin",
"DiggerItemAccessor",
"RecipeManagerMixin",
"RecipeManagerMixin",
"ShovelItemAccessor",
"BoneMealItemMixin",
"CraftingMenuMixin",
"shears.SheepMixin",
"PortalShapeMixin",
"ServerLevelMixin",
"BiomeSourceMixin",
"AnvilBlockMixin",
"AnvilMenuMixin",
"BiomeGenerationSettingsAccessor",
"BiomeMixin",
"BiomeSourceMixin",
"BlockStateBaseMixin",
"BoneMealItemMixin",
"ChunkGeneratorMixin",
"ComposterBlockAccessor",
"CraftingMenuMixin",
"DiggerItemAccessor",
"EnchantingTableBlockMixin",
"ItemStackMixin",
"TagLoaderMixin",
"LayerLightSectionStorageMixin",
"MainMixin",
"WorldPresetsBootstrapMixin",
"MinecraftServerMixin",
"MobSpawnSettingsAccessor",
"NetherBiomeDataMixin",
"NoiseBasedChunkGeneratorMixin",
"NoiseGeneratorSettingsMixin",
"PistonBaseBlockMixin",
"PortalShapeMixin",
"PotionBrewingAccessor",
"PresetEditorMixin",
"RecipeManagerAccessor",
"RecipeManagerMixin",
"ServerLevelMixin",
"ShovelItemAccessor",
"StructuresAccessor",
"SurfaceRulesContextAccessor",
"TagLoaderMixin",
"TheEndBiomeDataMixin",
"WorldGenPropertiesMixin",
"WorldGenRegionMixin",
"WorldOpenFlowsMixin",
"WorldGenPropertiesMixin"
"WorldPresetsBootstrapMixin",
"shears.BeehiveBlockMixin",
"shears.DiggingEnchantmentMixin",
"shears.ItemPredicateBuilderMixin",
"shears.MushroomCowMixin",
"shears.PumpkinBlockMixin",
"shears.SheepMixin",
"shears.SnowGolemMixin",
"shears.TripWireBlockMixin"
],
"injectors": {
"defaultRequire": 1