Skip to content

Commit

Permalink
TwoConfig draft
Browse files Browse the repository at this point in the history
  • Loading branch information
Tryflle committed Jul 26, 2024
1 parent 6a0d644 commit 21c6018
Show file tree
Hide file tree
Showing 8 changed files with 43 additions and 43 deletions.
14 changes: 11 additions & 3 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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`
}
}
Expand Down Expand Up @@ -86,20 +87,27 @@ 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")

// 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+")
}
}

Expand Down
2 changes: 1 addition & 1 deletion settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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 {
Expand All @@ -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());
}
}
15 changes: 5 additions & 10 deletions src/main/java/org/polyfrost/colorsaturation/Saturation.java
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -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();
}
}
Original file line number Diff line number Diff line change
@@ -1,44 +1,42 @@
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.
* See <a href="https://docs.polyfrost.cc/oneconfig/config/adding-options">this link</a> for more config Options
*/
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();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down

0 comments on commit 21c6018

Please sign in to comment.