Skip to content

Commit 21c6018

Browse files
committed
TwoConfig draft
1 parent 6a0d644 commit 21c6018

File tree

8 files changed

+43
-43
lines changed

8 files changed

+43
-43
lines changed

build.gradle.kts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,8 @@ loom {
5151
if (project.platform.isLegacyForge) {
5252
runConfigs {
5353
"client" {
54-
programArgs("--tweakClass", "cc.polyfrost.oneconfig.loader.stage0.LaunchWrapperTweaker")
54+
programArgs("--tweakClass", "org.polyfrost.oneconfig.internal.legacy.OneConfigTweaker")
55+
programArgs("--tweakClass", "org.spongepowered.asm.launch.MixinTweaker")
5556
property("mixin.debug.export", "true") // Outputs all mixin changes to `versions/{mcVersion}/run/.mixin.out/class`
5657
}
5758
}
@@ -86,20 +87,27 @@ sourceSets {
8687
// Adds the Polyfrost maven repository so that we can get the libraries necessary to develop the mod.
8788
repositories {
8889
maven("https://repo.polyfrost.org/releases")
90+
maven("https://repo.polyfrost.org/snapshots")
8991
}
9092

9193
// Configures the libraries/dependencies for your mod.
9294
dependencies {
9395
// Adds the OneConfig library, so we can develop with it.
94-
modCompileOnly("cc.polyfrost:oneconfig-$platform:0.2.2-alpha+")
96+
val oneconfig = "1.0.0-alpha.19"
97+
implementation("org.polyfrost.oneconfig:config-impl:$oneconfig")
98+
implementation("org.polyfrost.oneconfig:commands:$oneconfig")
99+
implementation("org.polyfrost.oneconfig:events:$oneconfig")
100+
implementation("org.polyfrost.oneconfig:ui:$oneconfig")
101+
implementation("org.polyfrost.oneconfig:internal:$oneconfig")
102+
modImplementation("org.polyfrost.oneconfig:$platform:$oneconfig")
95103

96104
// Adds DevAuth, which we can use to log in to Minecraft in development.
97105
modRuntimeOnly("me.djtheredstoner:DevAuth-${if (platform.isFabric) "fabric" else if (platform.isLegacyForge) "forge-legacy" else "forge-latest"}:1.2.0")
98106

99107
// If we are building for legacy forge, includes the launch wrapper with `shade` as we configured earlier, as well as mixin 0.7.11
100108
if (platform.isLegacyForge) {
101109
compileOnly("org.spongepowered:mixin:0.7.11-SNAPSHOT")
102-
shade("cc.polyfrost:oneconfig-wrapper-launchwrapper:1.0.0-beta+")
110+
// shade("cc.polyfrost:oneconfig-wrapper-launchwrapper:1.0.0-beta+")
103111
}
104112
}
105113

settings.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ pluginManagement {
77
maven("https://repo.polyfrost.org/releases") // Adds the Polyfrost maven repository to get Polyfrost Gradle Toolkit
88
}
99
plugins {
10-
val pgtVersion = "0.6.2" // Sets the default versions for Polyfrost Gradle Toolkit
10+
val pgtVersion = "0.6.6" // Sets the default versions for Polyfrost Gradle Toolkit
1111
id("org.polyfrost.multi-version.root") version pgtVersion
1212
}
1313
}

src/main/java/org/polyfrost/colorsaturation/ColorSaturation.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,17 @@
11
package org.polyfrost.colorsaturation;
22

3-
import cc.polyfrost.oneconfig.events.EventManager;
43
import org.polyfrost.colorsaturation.command.SaturationCommand;
54
import org.polyfrost.colorsaturation.config.SaturationConfig;
6-
import cc.polyfrost.oneconfig.events.event.InitializationEvent;
75
import net.minecraftforge.fml.common.Mod;
8-
import cc.polyfrost.oneconfig.utils.commands.CommandManager;
96
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
7+
import org.polyfrost.oneconfig.api.commands.v1.CommandManager;
8+
import org.polyfrost.oneconfig.api.event.v1.EventManager;
109

1110
/**
1211
* The entrypoint of the Example Mod that initializes it.
1312
*
1413
* @see Mod
15-
* @see InitializationEvent
14+
* @see org.polyfrost.oneconfig.api.event.v1.events.InitializationEvent
1615
*/
1716
@Mod(modid = ColorSaturation.MODID, name = ColorSaturation.NAME, version = ColorSaturation.VERSION)
1817
public class ColorSaturation {
@@ -27,7 +26,7 @@ public class ColorSaturation {
2726
@Mod.EventHandler
2827
public void onInit(FMLInitializationEvent event) {
2928
config = new SaturationConfig();
30-
CommandManager.INSTANCE.registerCommand(new SaturationCommand());
29+
CommandManager.registerCommand(new SaturationCommand());
3130
EventManager.INSTANCE.register(new Saturation());
3231
}
3332
}

src/main/java/org/polyfrost/colorsaturation/Saturation.java

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
11
package org.polyfrost.colorsaturation;
22

3-
import cc.polyfrost.oneconfig.events.event.RenderEvent;
4-
import cc.polyfrost.oneconfig.events.event.Stage;
5-
import cc.polyfrost.oneconfig.libs.eventbus.Subscribe;
6-
import cc.polyfrost.oneconfig.libs.universal.UMinecraft;
7-
import cc.polyfrost.oneconfig.libs.universal.UResolution;
83
import net.minecraft.client.shader.Shader;
94
import net.minecraft.client.shader.ShaderGroup;
105
import net.minecraft.client.shader.ShaderUniform;
116
import net.minecraft.util.ResourceLocation;
127
import org.polyfrost.colorsaturation.config.SaturationConfig;
138
import org.polyfrost.colorsaturation.mixin.ShaderGroupAccessor;
9+
import org.polyfrost.oneconfig.api.event.v1.events.RenderEvent;
10+
import org.polyfrost.oneconfig.api.event.v1.invoke.impl.Subscribe;
11+
import org.polyfrost.universal.UMinecraft;
12+
import org.polyfrost.universal.UResolution;
1413

1514
import java.io.IOException;
1615
import java.util.List;
@@ -21,11 +20,7 @@ public class Saturation {
2120
private static final ResourceLocation phosphorBlur = new ResourceLocation("minecraft:shaders/post/color_convolve.json");
2221

2322
@Subscribe
24-
private void onRenderTick(RenderEvent event) {
25-
if (event.stage != Stage.END) {
26-
return;
27-
}
28-
23+
private void onRenderTick(RenderEvent.End event) {
2924
// Only update the shader if one is active
3025
if (!isShaderActive() || lastEnabled != ColorSaturation.config.enabled) {
3126
lastEnabled = ColorSaturation.config.enabled;
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
package org.polyfrost.colorsaturation.command;
22

33
import org.polyfrost.colorsaturation.ColorSaturation;
4-
import cc.polyfrost.oneconfig.utils.commands.annotations.Command;
5-
import cc.polyfrost.oneconfig.utils.commands.annotations.Main;
4+
import org.polyfrost.oneconfig.api.commands.v1.factories.annotated.Command;
65

76
@Command(value = ColorSaturation.MODID, description = "Access the " + ColorSaturation.NAME + " GUI.")
87
public class SaturationCommand {
9-
@Main
8+
@Command
109
private void handle() {
11-
ColorSaturation.config.openGui();
10+
// TODO Implement openGui
11+
// ColorSaturation.config.openGui();
1212
}
1313
}

src/main/java/org/polyfrost/colorsaturation/config/SaturationConfig.java

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,42 @@
11
package org.polyfrost.colorsaturation.config;
22

3-
import cc.polyfrost.oneconfig.config.Config;
4-
import cc.polyfrost.oneconfig.config.annotations.Info;
5-
import cc.polyfrost.oneconfig.config.annotations.Slider;
6-
import cc.polyfrost.oneconfig.config.annotations.Switch;
7-
import cc.polyfrost.oneconfig.config.data.InfoType;
8-
import cc.polyfrost.oneconfig.config.data.Mod;
9-
import cc.polyfrost.oneconfig.config.data.ModType;
103
import org.polyfrost.colorsaturation.ColorSaturation;
114
import org.polyfrost.colorsaturation.Saturation;
5+
import org.polyfrost.oneconfig.api.config.v1.Config;
6+
import org.polyfrost.oneconfig.api.config.v1.annotations.Slider;
7+
import org.polyfrost.oneconfig.api.config.v1.annotations.Switch;
128

139
/**
1410
* The main Config entrypoint that extends the Config type and inits the config options.
1511
* See <a href="https://docs.polyfrost.cc/oneconfig/config/adding-options">this link</a> for more config Options
1612
*/
1713
public class SaturationConfig extends Config {
1814

19-
@Info(
20-
text = "This mod will ONLY work if either Fast Render is disabled or Force Disable Fast Render is enabled.",
21-
size = 2,
22-
type = InfoType.WARNING
23-
)
24-
private boolean agajsjg = false;
15+
// Temporary
16+
public boolean enabled = true;
17+
18+
// @Info(
19+
// text = "This mod will ONLY work if either Fast Render is disabled or Force Disable Fast Render is enabled.",
20+
// size = 2,
21+
// type = InfoType.WARNING
22+
//)
23+
private Runnable info = () -> { };
2524

2625
@Switch(
27-
name = "Force Disable Fast Render"
26+
title = "Force Disable Fast Render"
2827
)
2928
public static boolean forceDisableFastRender = true;
3029

3130
@Slider(
32-
name = "Saturation Slider",
31+
title = "Saturation Slider",
3332
min = -1f, max = 5 // Minimum and maximum values for the slider.
3433
)
3534
public static float saturation = 1;
3635

3736
public SaturationConfig() {
38-
super(new Mod(ColorSaturation.NAME, ModType.UTIL_QOL, "/colorsaturation.svg"), ColorSaturation.MODID + ".json");
39-
initialize();
37+
super(ColorSaturation.MODID + ".json", "/colorsaturation.svg", ColorSaturation.NAME, Category.QOL);
4038

41-
addListener("saturation", () -> {
39+
addCallback("saturation", () -> {
4240
if (enabled) {
4341
Saturation.reloadSaturation();
4442
}

src/main/java/org/polyfrost/colorsaturation/mixin/BlurHandlerImplMixin.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
package org.polyfrost.colorsaturation.mixin;
22

33
import cc.polyfrost.oneconfig.internal.gui.impl.BlurHandlerImpl;
4-
import cc.polyfrost.oneconfig.libs.universal.UMinecraft;
54
import org.polyfrost.colorsaturation.EntityRendererHook;
5+
import org.polyfrost.universal.UMinecraft;
66
import org.spongepowered.asm.mixin.Dynamic;
77
import org.spongepowered.asm.mixin.Mixin;
88
import org.spongepowered.asm.mixin.Pseudo;

src/main/java/org/polyfrost/colorsaturation/mixin/BlurModMixin.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
package org.polyfrost.colorsaturation.mixin;
22

3-
import cc.polyfrost.oneconfig.libs.universal.UMinecraft;
43
import net.minecraft.client.renderer.EntityRenderer;
54
import org.polyfrost.colorsaturation.EntityRendererHook;
5+
import org.polyfrost.universal.UMinecraft;
66
import org.spongepowered.asm.mixin.Dynamic;
77
import org.spongepowered.asm.mixin.Mixin;
88
import org.spongepowered.asm.mixin.Pseudo;

0 commit comments

Comments
 (0)