diff --git a/build.gradle b/build.gradle index 6049f1e..ad4c299 100644 --- a/build.gradle +++ b/build.gradle @@ -82,7 +82,6 @@ allprojects { // Main project depends on the base & gui module for testing dependencies { implementation project(path: ":omega-config-base", configuration: "namedElements") - implementation project(path: ":omega-config-gui", configuration: "namedElements") afterEvaluate { testmodImplementation sourceSets.main.output diff --git a/gradle.properties b/gradle.properties index 68948e3..1dd2eda 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,15 +1,15 @@ # Done to increase the memory available to gradle. org.gradle.jvmargs=-Xmx2G + # Fabric Properties # check these on https://fabricmc.net/versions.html -minecraft_version=1.19.2 -yarn_mappings=1.19.2+build.28 -loader_version=0.14.14 -fabric_version=0.75.1+1.19.2 +minecraft_version=1.20.1 +yarn_mappings=1.20.1+build.9 +loader_version=0.14.21 +fabric_version=0.84.0+1.20.1 # Mod Properties -mod_version=1.3.0 +mod_version=1.4.0 maven_group=dev.draylar archives_base_name=omega-config - -modmenu_version=3.0.1 +modmenu_version=7.1.0 \ No newline at end of file diff --git a/omega-config-gui/build.gradle b/omega-config-gui/build.gradle deleted file mode 100644 index bb9571c..0000000 --- a/omega-config-gui/build.gradle +++ /dev/null @@ -1,29 +0,0 @@ -repositories { - maven { - name = "Shedaniel's Maven" - url = "https://maven.shedaniel.me/" - } - - maven { - name = "TerraformersMC" - url = "https://maven.terraformersmc.com/releases/" - } -} - -dependencies { - implementation project(":omega-config-base") - - // Mod Menu - modCompileOnly ("com.terraformersmc:modmenu:${project.modmenu_version}") { - transitive(false) - } - modRuntimeOnly ("com.terraformersmc:modmenu:${project.modmenu_version}") { - transitive(false) - } - - // Cloth Config Lite - include "me.shedaniel.cloth:cloth-config-lite-fabric:2.0.6" - modApi ("me.shedaniel.cloth:cloth-config-lite-fabric:2.0.6") { - exclude group: "net.fabricmc.fabric-api" - } -} \ No newline at end of file diff --git a/omega-config-gui/src/main/java/draylar/omegaconfiggui/OmegaConfigGui.java b/omega-config-gui/src/main/java/draylar/omegaconfiggui/OmegaConfigGui.java deleted file mode 100644 index d5be0c6..0000000 --- a/omega-config-gui/src/main/java/draylar/omegaconfiggui/OmegaConfigGui.java +++ /dev/null @@ -1,98 +0,0 @@ -package draylar.omegaconfiggui; - -import draylar.omegaconfig.OmegaConfig; -import draylar.omegaconfig.api.Config; -import draylar.omegaconfiggui.api.screen.OmegaModMenu; -import draylar.omegaconfiggui.api.screen.OmegaScreenFactory; -import me.shedaniel.clothconfiglite.api.ConfigScreen; -import net.fabricmc.api.EnvType; -import net.fabricmc.api.Environment; -import net.fabricmc.loader.api.FabricLoader; -import net.minecraft.client.gui.screen.Screen; -import net.minecraft.text.Text; - -import java.lang.reflect.Field; -import java.lang.reflect.InvocationTargetException; -import java.util.HashMap; -import java.util.Map; - -@Environment(EnvType.CLIENT) -public class OmegaConfigGui { - - private static final Map> REGISTERED_CONFIGURATIONS = new HashMap<>(); - public static boolean modMenuInitialized = false; - - /** - * Registers a ModMenu configuration screen for the given {@link Config} instance. - * - * @param config registered config to create a ModMenu screen for - * @param config type - */ - public static void registerConfigScreen(T config) { - if(FabricLoader.getInstance().isModLoaded("modmenu")) { - // Ensure the config has a valid modid. - if(config.getModid() != null) { - OmegaScreenFactory factory = OmegaConfigGui.getConfigScreenFactory(config); - - if(modMenuInitialized) { - OmegaModMenu.injectScreen(config, factory); - } else { - REGISTERED_CONFIGURATIONS.put(config, factory); - } - } else { - OmegaConfig.LOGGER.warn(String.format("Skipping config screen registration for '%s' - you must implement getModid() in your config class!", config.getName())); - } - } - } - - /** - * Returns a factory which provides new Cloth Config Lite {@link Screen} instances for the given {@link Config}. - * - * @param config Omega Config instance to create the screen factory for - * @return a factory which provides new Cloth Config Lite {@link Screen} instances for the given {@link Config}. - */ - public static OmegaScreenFactory getConfigScreenFactory(Config config) { - return parent -> { - try { - Config defaultConfig = config.getClass().getDeclaredConstructor().newInstance(); - ConfigScreen screen = ConfigScreen.create(Text.translatable(String.format("config.%s.%s", config.getModid(), config.getName())), parent); - - // Fields - for (Field field : config.getClass().getDeclaredFields()) { - try { - screen.add(Text.of(field.getName()), field.get(config), () -> { - try { - return field.get(defaultConfig); - } catch (IllegalAccessException e) { - e.printStackTrace(); - } - - return 0.0d; - }, newValue -> { - try { - field.set(config, newValue); - } catch (IllegalAccessException e) { - e.printStackTrace(); - } - - config.save(); - }); - } catch (IllegalAccessException | IllegalArgumentException exception) { - // ignored - } - } - - return screen.get(); - } catch (NoSuchMethodException | InstantiationException | IllegalAccessException | InvocationTargetException exception) { - OmegaConfig.LOGGER.error(String.format("Configuration class for mod %s must have a no-argument constructor for retrieving default values.", config.getModid())); - } - - // todo: is this a bad idea - return null; - }; - } - - public static Map> getConfigScreenFactories() { - return REGISTERED_CONFIGURATIONS; - } -} diff --git a/omega-config-gui/src/main/java/draylar/omegaconfiggui/api/screen/OmegaModMenu.java b/omega-config-gui/src/main/java/draylar/omegaconfiggui/api/screen/OmegaModMenu.java deleted file mode 100644 index 760a9de..0000000 --- a/omega-config-gui/src/main/java/draylar/omegaconfiggui/api/screen/OmegaModMenu.java +++ /dev/null @@ -1,22 +0,0 @@ -package draylar.omegaconfiggui.api.screen; - -import com.google.common.collect.ImmutableMap; -import com.terraformersmc.modmenu.api.ConfigScreenFactory; -import draylar.omegaconfig.api.Config; -import draylar.omegaconfiggui.mixin.modmenu.ModMenuAccessor; -import net.fabricmc.api.EnvType; -import net.fabricmc.api.Environment; -import net.minecraft.client.gui.screen.Screen; - -@Environment(EnvType.CLIENT) -public class OmegaModMenu { - - public static void injectScreen(T config, OmegaScreenFactory factory) { - // they will suspect nothing - ModMenuAccessor.setConfigScreenFactories( - new ImmutableMap.Builder>() - .putAll(ModMenuAccessor.getConfigScreenFactories()) - .put(config.getModid(), factory::get) - .build()); - } -} diff --git a/omega-config-gui/src/main/java/draylar/omegaconfiggui/api/screen/OmegaScreenFactory.java b/omega-config-gui/src/main/java/draylar/omegaconfiggui/api/screen/OmegaScreenFactory.java deleted file mode 100644 index 83bb0c2..0000000 --- a/omega-config-gui/src/main/java/draylar/omegaconfiggui/api/screen/OmegaScreenFactory.java +++ /dev/null @@ -1,10 +0,0 @@ -package draylar.omegaconfiggui.api.screen; - -import net.fabricmc.api.EnvType; -import net.fabricmc.api.Environment; -import net.minecraft.client.gui.screen.Screen; - -@Environment(EnvType.CLIENT) -public interface OmegaScreenFactory { - T get(Screen parent); -} diff --git a/omega-config-gui/src/main/java/draylar/omegaconfiggui/mixin/ModMenuMixin.java b/omega-config-gui/src/main/java/draylar/omegaconfiggui/mixin/ModMenuMixin.java deleted file mode 100644 index 53b9aec..0000000 --- a/omega-config-gui/src/main/java/draylar/omegaconfiggui/mixin/ModMenuMixin.java +++ /dev/null @@ -1,24 +0,0 @@ -package draylar.omegaconfiggui.mixin; - -import com.terraformersmc.modmenu.ModMenu; -import draylar.omegaconfiggui.OmegaConfigGui; -import draylar.omegaconfiggui.api.screen.OmegaModMenu; -import net.fabricmc.api.EnvType; -import net.fabricmc.api.Environment; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; - -@Environment(EnvType.CLIENT) -@Mixin(ModMenu.class) -public class ModMenuMixin { - - @Inject(method = "onInitializeClient", at = @At("RETURN"), remap = false) - private void addOmegaConfigurationScreens(CallbackInfo ci) { - OmegaConfigGui.modMenuInitialized = true; - - // Add loaded configuration screens to mod menu. - OmegaConfigGui.getConfigScreenFactories().forEach(OmegaModMenu::injectScreen); - } -} diff --git a/omega-config-gui/src/main/java/draylar/omegaconfiggui/mixin/OmegaConfigMixinPlugin.java b/omega-config-gui/src/main/java/draylar/omegaconfiggui/mixin/OmegaConfigMixinPlugin.java deleted file mode 100644 index eb3a83b..0000000 --- a/omega-config-gui/src/main/java/draylar/omegaconfiggui/mixin/OmegaConfigMixinPlugin.java +++ /dev/null @@ -1,51 +0,0 @@ -package draylar.omegaconfiggui.mixin; - -import net.fabricmc.loader.api.FabricLoader; -import org.objectweb.asm.tree.ClassNode; -import org.spongepowered.asm.mixin.extensibility.IMixinConfigPlugin; -import org.spongepowered.asm.mixin.extensibility.IMixinInfo; - -import java.util.List; -import java.util.Set; - -public class OmegaConfigMixinPlugin implements IMixinConfigPlugin { - - @Override - public void onLoad(String mixinPackage) { - - } - - @Override - public String getRefMapperConfig() { - return null; - } - - @Override - public boolean shouldApplyMixin(String targetClassName, String mixinClassName) { - if(targetClassName.contains("ModMenu")) { - return FabricLoader.getInstance().isModLoaded("modmenu"); - } - - return true; - } - - @Override - public void acceptTargets(Set myTargets, Set otherTargets) { - - } - - @Override - public List getMixins() { - return null; - } - - @Override - public void preApply(String targetClassName, ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) { - - } - - @Override - public void postApply(String targetClassName, ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) { - - } -} diff --git a/omega-config-gui/src/main/java/draylar/omegaconfiggui/mixin/modmenu/ModMenuAccessor.java b/omega-config-gui/src/main/java/draylar/omegaconfiggui/mixin/modmenu/ModMenuAccessor.java deleted file mode 100644 index 3f05f94..0000000 --- a/omega-config-gui/src/main/java/draylar/omegaconfiggui/mixin/modmenu/ModMenuAccessor.java +++ /dev/null @@ -1,24 +0,0 @@ -package draylar.omegaconfiggui.mixin.modmenu; - -import com.google.common.collect.ImmutableMap; -import com.terraformersmc.modmenu.ModMenu; -import com.terraformersmc.modmenu.api.ConfigScreenFactory; -import net.fabricmc.api.EnvType; -import net.fabricmc.api.Environment; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.gen.Accessor; - -@Environment(EnvType.CLIENT) -@Mixin(ModMenu.class) -public interface ModMenuAccessor { - - @Accessor - static ImmutableMap> getConfigScreenFactories() { - throw new UnsupportedOperationException(); - } - - @Accessor - static void setConfigScreenFactories(ImmutableMap> factories) { - throw new UnsupportedOperationException(); - } -} diff --git a/omega-config-gui/src/main/resources/assets/omega-config-gui/icon.png b/omega-config-gui/src/main/resources/assets/omega-config-gui/icon.png deleted file mode 100644 index 0b5c7b9..0000000 Binary files a/omega-config-gui/src/main/resources/assets/omega-config-gui/icon.png and /dev/null differ diff --git a/omega-config-gui/src/main/resources/fabric.mod.json b/omega-config-gui/src/main/resources/fabric.mod.json deleted file mode 100644 index 5dc8a42..0000000 --- a/omega-config-gui/src/main/resources/fabric.mod.json +++ /dev/null @@ -1,33 +0,0 @@ -{ - "schemaVersion": 1, - "id": "omega-config-gui", - "version": "${version}", - "name": "Omega Config GUI", - "description": "GUI support for Omega Config.", - "authors": [ - "Draylar" - ], - "contact": { - "homepage": "https://github.com/Draylar/omega-config", - "sources": "https://github.com/Draylar/omega-config", - "issues": "https://github.com/Draylar/omega-config/issues" - }, - "license": "MIT", - "environment": "*", - "mixins": [ - "omega-config-gui.mixins.json" - ], - "depends": { - "fabricloader": "*", - "fabric": "*", - "minecraft": "*" - }, - "recommends": { - "modmenu": "3.0.1" - }, - "custom": { - "modmenu": { - "badges": [ "library" ] - } - } -} diff --git a/omega-config-gui/src/main/resources/omega-config-gui.mixins.json b/omega-config-gui/src/main/resources/omega-config-gui.mixins.json deleted file mode 100644 index 2a0c736..0000000 --- a/omega-config-gui/src/main/resources/omega-config-gui.mixins.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "required": true, - "minVersion": "0.8", - "package": "draylar.omegaconfiggui.mixin", - "compatibilityLevel": "JAVA_17", - "plugin": "draylar.omegaconfiggui.mixin.OmegaConfigMixinPlugin", - "client": [ - "modmenu.ModMenuAccessor", - "ModMenuMixin" - ], - "injectors": { - "defaultRequire": 1 - } -} diff --git a/settings.gradle b/settings.gradle index 3b3d207..5cb940f 100644 --- a/settings.gradle +++ b/settings.gradle @@ -11,5 +11,4 @@ pluginManagement { rootProject.name = 'omega-config' -include 'omega-config-base' -include 'omega-config-gui' \ No newline at end of file +include 'omega-config-base' \ No newline at end of file diff --git a/src/testmod/java/draylar/omegatest/OmegaTestClient.java b/src/testmod/java/draylar/omegatest/OmegaTestClient.java index 91f8ddc..e9d8f5f 100644 --- a/src/testmod/java/draylar/omegatest/OmegaTestClient.java +++ b/src/testmod/java/draylar/omegatest/OmegaTestClient.java @@ -1,20 +1,19 @@ package draylar.omegatest; -import draylar.omegaconfiggui.OmegaConfigGui; import net.fabricmc.api.ClientModInitializer; import net.fabricmc.fabric.api.client.rendering.v1.HudRenderCallback; import net.minecraft.client.MinecraftClient; +import net.minecraft.client.font.TextRenderer; import net.minecraft.text.Text; public class OmegaTestClient implements ClientModInitializer { @Override public void onInitializeClient() { - OmegaConfigGui.registerConfigScreen(OmegaTestMain.CONFIG); - - HudRenderCallback.EVENT.register((stack, delta) -> { - MinecraftClient.getInstance().textRenderer.draw(stack, Text.literal(String.valueOf(OmegaTestMain.CONFIG.v)), 15, 15, 0xffffff); - MinecraftClient.getInstance().textRenderer.draw(stack, Text.literal(String.valueOf(OmegaTestMain.CONFIG.doubleTest)), 15, 30, 0xffffff); + HudRenderCallback.EVENT.register((context, delta) -> { + TextRenderer tr = MinecraftClient.getInstance().textRenderer; + context.drawText(tr, Text.literal(String.valueOf(OmegaTestMain.CONFIG.v)), 15, 15, 0xffffff, true); + context.drawText(tr, Text.literal(String.valueOf(OmegaTestMain.CONFIG.doubleTest)), 15, 25, 0xffffff, true); }); } }