diff --git a/build.gradle.kts b/build.gradle.kts index 1f00f7f..400a924 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -20,7 +20,7 @@ preprocess { toolkitLoomHelper { // Adds OneConfig to our project - useOneConfig(mcData.version, mcData.loader, "commands", "config-impl", "events", "hud", "internal", "ui") + useOneConfig("1.1.0-alpha.34", "1.0.0-alpha.43", mcData, "commands", "config-impl", "events", "hud", "internal", "ui") useDevAuth() // Removes the server configs from IntelliJ IDEA, leaving only client runs. @@ -59,5 +59,7 @@ dependencies { // If we are building for legacy forge, includes the launch wrapper with `shade` as we configured earlier. if (mcData.isLegacyForge) { compileOnly("org.spongepowered:mixin:0.7.11-SNAPSHOT") + } else if (mcData.isFabric) { + modImplementation("net.fabricmc:fabric-language-kotlin:${mcData.dependencies.fabric.fabricLanguageKotlinVersion}") } } diff --git a/root.gradle.kts b/root.gradle.kts index 234330e..6ef2f61 100644 --- a/root.gradle.kts +++ b/root.gradle.kts @@ -3,5 +3,7 @@ plugins { } preprocess { - "1.8.9-forge"(10809, "srg") {} + "1.8.9-forge"(10809, "srg") { + "1.8.9-fabric"(10809, "yarn") + } } \ No newline at end of file diff --git a/settings.gradle.kts b/settings.gradle.kts index 70cb3f4..9f3814a 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -22,7 +22,7 @@ pluginManagement { plugins { kotlin("jvm") version("2.0.0") - id("dev.deftu.gradle.multiversion-root") version("2.11.2") + id("dev.deftu.gradle.multiversion-root") version("2.13.0") } } @@ -33,7 +33,8 @@ rootProject.buildFileName = "root.gradle.kts" // Adds all of our build target versions to the classpath if we need to add version-specific code. listOf( - "1.8.9-forge" + "1.8.9-forge", + "1.8.9-fabric" ).forEach { version -> include(":$version") project(":$version").apply { diff --git a/src/main/java/org/polyfrost/colorsaturation/ColorSaturation.java b/src/main/java/org/polyfrost/colorsaturation/ColorSaturation.java deleted file mode 100644 index 78993cb..0000000 --- a/src/main/java/org/polyfrost/colorsaturation/ColorSaturation.java +++ /dev/null @@ -1,32 +0,0 @@ -package org.polyfrost.colorsaturation; - -import org.polyfrost.colorsaturation.command.SaturationCommand; -import org.polyfrost.colorsaturation.config.SaturationConfig; -import net.minecraftforge.fml.common.Mod; -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 org.polyfrost.oneconfig.api.event.v1.events.InitializationEvent - */ -@Mod(modid = ColorSaturation.MODID, name = ColorSaturation.NAME, version = ColorSaturation.VERSION) -public class ColorSaturation { - - // Sets the variables from `gradle.properties`. See the `blossom` config in `build.gradle.kts`. - public static final String MODID = "@MOD_ID@"; - public static final String NAME = "@MOD_NAME@"; - public static final String VERSION = "@MOD_VERSION@"; - public static SaturationConfig config; - - // Register the config and commands. - @Mod.EventHandler - public void onInit(FMLInitializationEvent event) { - config = new SaturationConfig(); - 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 4b0d190..99e54b4 100644 --- a/src/main/java/org/polyfrost/colorsaturation/Saturation.java +++ b/src/main/java/org/polyfrost/colorsaturation/Saturation.java @@ -22,8 +22,8 @@ public class Saturation { @Subscribe private void onRenderTick(RenderEvent.End event) { // Only update the shader if one is active - if (!isShaderActive() || lastEnabled != ColorSaturation.config.enabled) { - lastEnabled = ColorSaturation.config.enabled; + if (!isShaderActive() || lastEnabled != ColorSaturation.getConfig().enabled) { + lastEnabled = ColorSaturation.getConfig().enabled; reloadShader(); } } @@ -33,7 +33,7 @@ public static void reloadShader() { return; } - if (!isShaderActive() && ColorSaturation.config.enabled) { + if (!isShaderActive() && ColorSaturation.getConfig().enabled) { try { final ShaderGroup saturationShader = new ShaderGroup(UMinecraft.getMinecraft().getTextureManager(), UMinecraft.getMinecraft().getResourceManager(), UMinecraft.getMinecraft().getFramebuffer(), phosphorBlur); saturationShader.createBindFramebuffers(UResolution.getWindowWidth(), UResolution.getWindowHeight()); @@ -42,7 +42,7 @@ public static void reloadShader() { } catch (IOException e) { e.printStackTrace(); } - } else if (isShaderActive() && !ColorSaturation.config.enabled) { + } else if (isShaderActive() && !ColorSaturation.getConfig().enabled) { final EntityRendererHook entityRenderer = (EntityRendererHook) UMinecraft.getMinecraft().entityRenderer; if (entityRenderer.colorSaturation$getSaturationShader() != null) { entityRenderer.colorSaturation$getSaturationShader().deleteShaderGroup(); diff --git a/src/main/java/org/polyfrost/colorsaturation/command/SaturationCommand.java b/src/main/java/org/polyfrost/colorsaturation/command/SaturationCommand.java index ec1f15b..c2554c2 100644 --- a/src/main/java/org/polyfrost/colorsaturation/command/SaturationCommand.java +++ b/src/main/java/org/polyfrost/colorsaturation/command/SaturationCommand.java @@ -2,14 +2,14 @@ import org.polyfrost.colorsaturation.ColorSaturation; import org.polyfrost.oneconfig.api.commands.v1.factories.annotated.Command; -import org.polyfrost.utils.v1.dsl.ScreensKt; +import org.polyfrost.oneconfig.utils.v1.dsl.ScreensKt; -@Command(value = ColorSaturation.MODID, description = "Access the " + ColorSaturation.NAME + " GUI.") +@Command(value = ColorSaturation.ID, description = "Access the " + ColorSaturation.NAME + " GUI.") public class SaturationCommand { @Command private void main() { // TODO Implement openGui - // ColorSaturation.config.openGui(); - ScreensKt.openUI(ColorSaturation.config); + // ColorSaturation.getConfig().openGui(); + ScreensKt.openUI(ColorSaturation.getConfig()); } } \ 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 3cb1d55..f19d97b 100644 --- a/src/main/java/org/polyfrost/colorsaturation/config/SaturationConfig.java +++ b/src/main/java/org/polyfrost/colorsaturation/config/SaturationConfig.java @@ -34,7 +34,7 @@ public class SaturationConfig extends Config { public static float saturation = 1; public SaturationConfig() { - super(ColorSaturation.MODID + ".json", "/colorsaturation.svg", ColorSaturation.NAME, Category.QOL); + super(ColorSaturation.ID + ".json", "/colorsaturation.svg", ColorSaturation.NAME, Category.QOL); addCallback("saturation", () -> { if (enabled) { diff --git a/src/main/java/org/polyfrost/colorsaturation/mixin/OptifineConfigMixin.java b/src/main/java/org/polyfrost/colorsaturation/mixin/OptifineConfigMixin.java index 0da0411..09b1023 100644 --- a/src/main/java/org/polyfrost/colorsaturation/mixin/OptifineConfigMixin.java +++ b/src/main/java/org/polyfrost/colorsaturation/mixin/OptifineConfigMixin.java @@ -15,7 +15,7 @@ public class OptifineConfigMixin { @Dynamic("OptiFine") @Inject(method = "isFastRender", at = @At("HEAD"), cancellable = true) private static void cancelFastRender(CallbackInfoReturnable cir) { - if (ColorSaturation.config != null && ColorSaturation.config.enabled && SaturationConfig.forceDisableFastRender) { + if (ColorSaturation.getConfig() != null && ColorSaturation.getConfig().enabled && SaturationConfig.forceDisableFastRender) { cir.setReturnValue(false); } } diff --git a/src/main/kotlin/org/polyfrost/colorsaturation/ColorSaturation.kt b/src/main/kotlin/org/polyfrost/colorsaturation/ColorSaturation.kt new file mode 100644 index 0000000..e87445f --- /dev/null +++ b/src/main/kotlin/org/polyfrost/colorsaturation/ColorSaturation.kt @@ -0,0 +1,49 @@ +package org.polyfrost.colorsaturation + +//#if FORGE +import net.minecraftforge.fml.common.Mod +import net.minecraftforge.fml.common.event.FMLInitializationEvent +//#else +//$$ import net.fabricmc.api.ClientModInitializer +//#endif + +import org.polyfrost.colorsaturation.command.SaturationCommand +import org.polyfrost.colorsaturation.config.SaturationConfig +import org.polyfrost.oneconfig.api.commands.v1.CommandManager +import org.polyfrost.oneconfig.api.event.v1.EventManager + +//#if FORGE +@Mod(modid = ColorSaturation.ID, version = ColorSaturation.VERSION, name = ColorSaturation.NAME, modLanguageAdapter = "org.polyfrost.oneconfig.utils.v1.forge.KotlinLanguageAdapter") +//#endif +object ColorSaturation + //#if FABRIC + //$$ : ClientModInitializer + //#endif +{ + + const val ID = "@MOD_ID@" + const val NAME = "@MOD_NAME@" + const val VERSION = "@MOD_VERSION@" + + @JvmStatic + lateinit var config: SaturationConfig + private set + + fun initialize() { + config = SaturationConfig() + CommandManager.registerCommand(SaturationCommand()) + EventManager.INSTANCE.register(Saturation()) + } + + //#if FORGE + @Mod.EventHandler + fun onInit(e: FMLInitializationEvent) { + initialize() + } + //#else + //$$ override fun onInitializeClient() { + //$$ initialize() + //$$ } + //#endif + +} diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json new file mode 100644 index 0000000..c1dba02 --- /dev/null +++ b/src/main/resources/fabric.mod.json @@ -0,0 +1,30 @@ +{ + "schemaVersion": 1, + "id": "${mod_id}", + "version": "${mod_version}", + "name": "${mod_name}", + "authors": [ + "Polyfrost" + ], + "contact": { + "issues": "https://github.com/Polyfrost/${mod_name}/issues", + "sources": "https://github.com/Polyfrost/${mod_name}" + }, + "license": "GPL-3.0-or-later", + "environment": "*", + "entrypoints": { + "client": [ + { + "adapter": "kotlin", + "value": "org.polyfrost.colorsaturation.ColorSaturation" + } + ] + }, + "mixins": [ + "mixins.${mod_id}.json" + ], + "depends": { + "fabricloader": ">=0.15.11", + "fabric-language-kotlin": "*" + } +} \ No newline at end of file