From 21c6018e5de41b6d216f2bf2e133374b12aa64c2 Mon Sep 17 00:00:00 2001 From: Tryfle Date: Fri, 26 Jul 2024 11:45:02 -0400 Subject: [PATCH] TwoConfig draft --- build.gradle.kts | 14 ++++++-- settings.gradle.kts | 2 +- .../colorsaturation/ColorSaturation.java | 9 +++-- .../polyfrost/colorsaturation/Saturation.java | 15 +++----- .../command/SaturationCommand.java | 8 ++--- .../config/SaturationConfig.java | 34 +++++++++---------- .../mixin/BlurHandlerImplMixin.java | 2 +- .../colorsaturation/mixin/BlurModMixin.java | 2 +- 8 files changed, 43 insertions(+), 43 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index d1a6c90..1e63d41 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -51,7 +51,8 @@ loom { if (project.platform.isLegacyForge) { runConfigs { "client" { - programArgs("--tweakClass", "cc.polyfrost.oneconfig.loader.stage0.LaunchWrapperTweaker") + programArgs("--tweakClass", "org.polyfrost.oneconfig.internal.legacy.OneConfigTweaker") + programArgs("--tweakClass", "org.spongepowered.asm.launch.MixinTweaker") property("mixin.debug.export", "true") // Outputs all mixin changes to `versions/{mcVersion}/run/.mixin.out/class` } } @@ -86,12 +87,19 @@ sourceSets { // Adds the Polyfrost maven repository so that we can get the libraries necessary to develop the mod. repositories { maven("https://repo.polyfrost.org/releases") + maven("https://repo.polyfrost.org/snapshots") } // Configures the libraries/dependencies for your mod. dependencies { // Adds the OneConfig library, so we can develop with it. - modCompileOnly("cc.polyfrost:oneconfig-$platform:0.2.2-alpha+") + val oneconfig = "1.0.0-alpha.19" + implementation("org.polyfrost.oneconfig:config-impl:$oneconfig") + implementation("org.polyfrost.oneconfig:commands:$oneconfig") + implementation("org.polyfrost.oneconfig:events:$oneconfig") + implementation("org.polyfrost.oneconfig:ui:$oneconfig") + implementation("org.polyfrost.oneconfig:internal:$oneconfig") + modImplementation("org.polyfrost.oneconfig:$platform:$oneconfig") // Adds DevAuth, which we can use to log in to Minecraft in development. modRuntimeOnly("me.djtheredstoner:DevAuth-${if (platform.isFabric) "fabric" else if (platform.isLegacyForge) "forge-legacy" else "forge-latest"}:1.2.0") @@ -99,7 +107,7 @@ dependencies { // If we are building for legacy forge, includes the launch wrapper with `shade` as we configured earlier, as well as mixin 0.7.11 if (platform.isLegacyForge) { compileOnly("org.spongepowered:mixin:0.7.11-SNAPSHOT") - shade("cc.polyfrost:oneconfig-wrapper-launchwrapper:1.0.0-beta+") + // shade("cc.polyfrost:oneconfig-wrapper-launchwrapper:1.0.0-beta+") } } diff --git a/settings.gradle.kts b/settings.gradle.kts index 54f119e..8f6ca95 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -7,7 +7,7 @@ pluginManagement { maven("https://repo.polyfrost.org/releases") // Adds the Polyfrost maven repository to get Polyfrost Gradle Toolkit } plugins { - val pgtVersion = "0.6.2" // Sets the default versions for Polyfrost Gradle Toolkit + val pgtVersion = "0.6.6" // Sets the default versions for Polyfrost Gradle Toolkit id("org.polyfrost.multi-version.root") version pgtVersion } } diff --git a/src/main/java/org/polyfrost/colorsaturation/ColorSaturation.java b/src/main/java/org/polyfrost/colorsaturation/ColorSaturation.java index 86e18b1..a0fc6e8 100644 --- a/src/main/java/org/polyfrost/colorsaturation/ColorSaturation.java +++ b/src/main/java/org/polyfrost/colorsaturation/ColorSaturation.java @@ -1,18 +1,17 @@ package org.polyfrost.colorsaturation; -import cc.polyfrost.oneconfig.events.EventManager; import org.polyfrost.colorsaturation.command.SaturationCommand; import org.polyfrost.colorsaturation.config.SaturationConfig; -import cc.polyfrost.oneconfig.events.event.InitializationEvent; import net.minecraftforge.fml.common.Mod; -import cc.polyfrost.oneconfig.utils.commands.CommandManager; import net.minecraftforge.fml.common.event.FMLInitializationEvent; +import org.polyfrost.oneconfig.api.commands.v1.CommandManager; +import org.polyfrost.oneconfig.api.event.v1.EventManager; /** * The entrypoint of the Example Mod that initializes it. * * @see Mod - * @see InitializationEvent + * @see org.polyfrost.oneconfig.api.event.v1.events.InitializationEvent */ @Mod(modid = ColorSaturation.MODID, name = ColorSaturation.NAME, version = ColorSaturation.VERSION) public class ColorSaturation { @@ -27,7 +26,7 @@ public class ColorSaturation { @Mod.EventHandler public void onInit(FMLInitializationEvent event) { config = new SaturationConfig(); - CommandManager.INSTANCE.registerCommand(new SaturationCommand()); + CommandManager.registerCommand(new SaturationCommand()); EventManager.INSTANCE.register(new Saturation()); } } diff --git a/src/main/java/org/polyfrost/colorsaturation/Saturation.java b/src/main/java/org/polyfrost/colorsaturation/Saturation.java index 0cc3c63..4b0d190 100644 --- a/src/main/java/org/polyfrost/colorsaturation/Saturation.java +++ b/src/main/java/org/polyfrost/colorsaturation/Saturation.java @@ -1,16 +1,15 @@ package org.polyfrost.colorsaturation; -import cc.polyfrost.oneconfig.events.event.RenderEvent; -import cc.polyfrost.oneconfig.events.event.Stage; -import cc.polyfrost.oneconfig.libs.eventbus.Subscribe; -import cc.polyfrost.oneconfig.libs.universal.UMinecraft; -import cc.polyfrost.oneconfig.libs.universal.UResolution; import net.minecraft.client.shader.Shader; import net.minecraft.client.shader.ShaderGroup; import net.minecraft.client.shader.ShaderUniform; import net.minecraft.util.ResourceLocation; import org.polyfrost.colorsaturation.config.SaturationConfig; import org.polyfrost.colorsaturation.mixin.ShaderGroupAccessor; +import org.polyfrost.oneconfig.api.event.v1.events.RenderEvent; +import org.polyfrost.oneconfig.api.event.v1.invoke.impl.Subscribe; +import org.polyfrost.universal.UMinecraft; +import org.polyfrost.universal.UResolution; import java.io.IOException; import java.util.List; @@ -21,11 +20,7 @@ public class Saturation { private static final ResourceLocation phosphorBlur = new ResourceLocation("minecraft:shaders/post/color_convolve.json"); @Subscribe - private void onRenderTick(RenderEvent event) { - if (event.stage != Stage.END) { - return; - } - + private void onRenderTick(RenderEvent.End event) { // Only update the shader if one is active if (!isShaderActive() || lastEnabled != ColorSaturation.config.enabled) { lastEnabled = ColorSaturation.config.enabled; diff --git a/src/main/java/org/polyfrost/colorsaturation/command/SaturationCommand.java b/src/main/java/org/polyfrost/colorsaturation/command/SaturationCommand.java index 41a405f..7cc02f2 100644 --- a/src/main/java/org/polyfrost/colorsaturation/command/SaturationCommand.java +++ b/src/main/java/org/polyfrost/colorsaturation/command/SaturationCommand.java @@ -1,13 +1,13 @@ package org.polyfrost.colorsaturation.command; import org.polyfrost.colorsaturation.ColorSaturation; -import cc.polyfrost.oneconfig.utils.commands.annotations.Command; -import cc.polyfrost.oneconfig.utils.commands.annotations.Main; +import org.polyfrost.oneconfig.api.commands.v1.factories.annotated.Command; @Command(value = ColorSaturation.MODID, description = "Access the " + ColorSaturation.NAME + " GUI.") public class SaturationCommand { - @Main + @Command private void handle() { - ColorSaturation.config.openGui(); + // TODO Implement openGui + // ColorSaturation.config.openGui(); } } \ No newline at end of file diff --git a/src/main/java/org/polyfrost/colorsaturation/config/SaturationConfig.java b/src/main/java/org/polyfrost/colorsaturation/config/SaturationConfig.java index eafce38..3cb1d55 100644 --- a/src/main/java/org/polyfrost/colorsaturation/config/SaturationConfig.java +++ b/src/main/java/org/polyfrost/colorsaturation/config/SaturationConfig.java @@ -1,14 +1,10 @@ package org.polyfrost.colorsaturation.config; -import cc.polyfrost.oneconfig.config.Config; -import cc.polyfrost.oneconfig.config.annotations.Info; -import cc.polyfrost.oneconfig.config.annotations.Slider; -import cc.polyfrost.oneconfig.config.annotations.Switch; -import cc.polyfrost.oneconfig.config.data.InfoType; -import cc.polyfrost.oneconfig.config.data.Mod; -import cc.polyfrost.oneconfig.config.data.ModType; import org.polyfrost.colorsaturation.ColorSaturation; import org.polyfrost.colorsaturation.Saturation; +import org.polyfrost.oneconfig.api.config.v1.Config; +import org.polyfrost.oneconfig.api.config.v1.annotations.Slider; +import org.polyfrost.oneconfig.api.config.v1.annotations.Switch; /** * The main Config entrypoint that extends the Config type and inits the config options. @@ -16,29 +12,31 @@ */ public class SaturationConfig extends Config { - @Info( - text = "This mod will ONLY work if either Fast Render is disabled or Force Disable Fast Render is enabled.", - size = 2, - type = InfoType.WARNING - ) - private boolean agajsjg = false; + // Temporary + public boolean enabled = true; + + // @Info( + // text = "This mod will ONLY work if either Fast Render is disabled or Force Disable Fast Render is enabled.", + // size = 2, + // type = InfoType.WARNING + //) + private Runnable info = () -> { }; @Switch( - name = "Force Disable Fast Render" + title = "Force Disable Fast Render" ) public static boolean forceDisableFastRender = true; @Slider( - name = "Saturation Slider", + title = "Saturation Slider", min = -1f, max = 5 // Minimum and maximum values for the slider. ) public static float saturation = 1; public SaturationConfig() { - super(new Mod(ColorSaturation.NAME, ModType.UTIL_QOL, "/colorsaturation.svg"), ColorSaturation.MODID + ".json"); - initialize(); + super(ColorSaturation.MODID + ".json", "/colorsaturation.svg", ColorSaturation.NAME, Category.QOL); - addListener("saturation", () -> { + addCallback("saturation", () -> { if (enabled) { Saturation.reloadSaturation(); } diff --git a/src/main/java/org/polyfrost/colorsaturation/mixin/BlurHandlerImplMixin.java b/src/main/java/org/polyfrost/colorsaturation/mixin/BlurHandlerImplMixin.java index d937547..2409126 100644 --- a/src/main/java/org/polyfrost/colorsaturation/mixin/BlurHandlerImplMixin.java +++ b/src/main/java/org/polyfrost/colorsaturation/mixin/BlurHandlerImplMixin.java @@ -1,8 +1,8 @@ package org.polyfrost.colorsaturation.mixin; import cc.polyfrost.oneconfig.internal.gui.impl.BlurHandlerImpl; -import cc.polyfrost.oneconfig.libs.universal.UMinecraft; import org.polyfrost.colorsaturation.EntityRendererHook; +import org.polyfrost.universal.UMinecraft; import org.spongepowered.asm.mixin.Dynamic; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Pseudo; diff --git a/src/main/java/org/polyfrost/colorsaturation/mixin/BlurModMixin.java b/src/main/java/org/polyfrost/colorsaturation/mixin/BlurModMixin.java index 831dec8..7cdc29c 100644 --- a/src/main/java/org/polyfrost/colorsaturation/mixin/BlurModMixin.java +++ b/src/main/java/org/polyfrost/colorsaturation/mixin/BlurModMixin.java @@ -1,8 +1,8 @@ package org.polyfrost.colorsaturation.mixin; -import cc.polyfrost.oneconfig.libs.universal.UMinecraft; import net.minecraft.client.renderer.EntityRenderer; import org.polyfrost.colorsaturation.EntityRendererHook; +import org.polyfrost.universal.UMinecraft; import org.spongepowered.asm.mixin.Dynamic; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Pseudo;