Skip to content

Commit bd71ad9

Browse files
committed
Port to Legacy Fabric, update OneConfig, etc.
1 parent 3800a82 commit bd71ad9

File tree

10 files changed

+98
-46
lines changed

10 files changed

+98
-46
lines changed

build.gradle.kts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ preprocess {
2020

2121
toolkitLoomHelper {
2222
// Adds OneConfig to our project
23-
useOneConfig(mcData.version, mcData.loader, "commands", "config-impl", "events", "hud", "internal", "ui")
23+
useOneConfig("1.1.0-alpha.34", "1.0.0-alpha.43", mcData, "commands", "config-impl", "events", "hud", "internal", "ui")
2424
useDevAuth()
2525

2626
// Removes the server configs from IntelliJ IDEA, leaving only client runs.
@@ -59,5 +59,7 @@ dependencies {
5959
// If we are building for legacy forge, includes the launch wrapper with `shade` as we configured earlier.
6060
if (mcData.isLegacyForge) {
6161
compileOnly("org.spongepowered:mixin:0.7.11-SNAPSHOT")
62+
} else if (mcData.isFabric) {
63+
modImplementation("net.fabricmc:fabric-language-kotlin:${mcData.dependencies.fabric.fabricLanguageKotlinVersion}")
6264
}
6365
}

root.gradle.kts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,7 @@ plugins {
33
}
44

55
preprocess {
6-
"1.8.9-forge"(10809, "srg") {}
6+
"1.8.9-forge"(10809, "srg") {
7+
"1.8.9-fabric"(10809, "yarn")
8+
}
79
}

settings.gradle.kts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ pluginManagement {
2222

2323
plugins {
2424
kotlin("jvm") version("2.0.0")
25-
id("dev.deftu.gradle.multiversion-root") version("2.11.2")
25+
id("dev.deftu.gradle.multiversion-root") version("2.13.0")
2626
}
2727
}
2828

@@ -33,7 +33,8 @@ rootProject.buildFileName = "root.gradle.kts"
3333

3434
// Adds all of our build target versions to the classpath if we need to add version-specific code.
3535
listOf(
36-
"1.8.9-forge"
36+
"1.8.9-forge",
37+
"1.8.9-fabric"
3738
).forEach { version ->
3839
include(":$version")
3940
project(":$version").apply {

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

Lines changed: 0 additions & 32 deletions
This file was deleted.

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ public class Saturation {
2222
@Subscribe
2323
private void onRenderTick(RenderEvent.End event) {
2424
// Only update the shader if one is active
25-
if (!isShaderActive() || lastEnabled != ColorSaturation.config.enabled) {
26-
lastEnabled = ColorSaturation.config.enabled;
25+
if (!isShaderActive() || lastEnabled != ColorSaturation.getConfig().enabled) {
26+
lastEnabled = ColorSaturation.getConfig().enabled;
2727
reloadShader();
2828
}
2929
}
@@ -33,7 +33,7 @@ public static void reloadShader() {
3333
return;
3434
}
3535

36-
if (!isShaderActive() && ColorSaturation.config.enabled) {
36+
if (!isShaderActive() && ColorSaturation.getConfig().enabled) {
3737
try {
3838
final ShaderGroup saturationShader = new ShaderGroup(UMinecraft.getMinecraft().getTextureManager(), UMinecraft.getMinecraft().getResourceManager(), UMinecraft.getMinecraft().getFramebuffer(), phosphorBlur);
3939
saturationShader.createBindFramebuffers(UResolution.getWindowWidth(), UResolution.getWindowHeight());
@@ -42,7 +42,7 @@ public static void reloadShader() {
4242
} catch (IOException e) {
4343
e.printStackTrace();
4444
}
45-
} else if (isShaderActive() && !ColorSaturation.config.enabled) {
45+
} else if (isShaderActive() && !ColorSaturation.getConfig().enabled) {
4646
final EntityRendererHook entityRenderer = (EntityRendererHook) UMinecraft.getMinecraft().entityRenderer;
4747
if (entityRenderer.colorSaturation$getSaturationShader() != null) {
4848
entityRenderer.colorSaturation$getSaturationShader().deleteShaderGroup();

src/main/java/org/polyfrost/colorsaturation/command/SaturationCommand.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@
22

33
import org.polyfrost.colorsaturation.ColorSaturation;
44
import org.polyfrost.oneconfig.api.commands.v1.factories.annotated.Command;
5-
import org.polyfrost.utils.v1.dsl.ScreensKt;
5+
import org.polyfrost.oneconfig.utils.v1.dsl.ScreensKt;
66

7-
@Command(value = ColorSaturation.MODID, description = "Access the " + ColorSaturation.NAME + " GUI.")
7+
@Command(value = ColorSaturation.ID, description = "Access the " + ColorSaturation.NAME + " GUI.")
88
public class SaturationCommand {
99
@Command
1010
private void main() {
1111
// TODO Implement openGui
12-
// ColorSaturation.config.openGui();
13-
ScreensKt.openUI(ColorSaturation.config);
12+
// ColorSaturation.getConfig().openGui();
13+
ScreensKt.openUI(ColorSaturation.getConfig());
1414
}
1515
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public class SaturationConfig extends Config {
3434
public static float saturation = 1;
3535

3636
public SaturationConfig() {
37-
super(ColorSaturation.MODID + ".json", "/colorsaturation.svg", ColorSaturation.NAME, Category.QOL);
37+
super(ColorSaturation.ID + ".json", "/colorsaturation.svg", ColorSaturation.NAME, Category.QOL);
3838

3939
addCallback("saturation", () -> {
4040
if (enabled) {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public class OptifineConfigMixin {
1515
@Dynamic("OptiFine")
1616
@Inject(method = "isFastRender", at = @At("HEAD"), cancellable = true)
1717
private static void cancelFastRender(CallbackInfoReturnable<Boolean> cir) {
18-
if (ColorSaturation.config != null && ColorSaturation.config.enabled && SaturationConfig.forceDisableFastRender) {
18+
if (ColorSaturation.getConfig() != null && ColorSaturation.getConfig().enabled && SaturationConfig.forceDisableFastRender) {
1919
cir.setReturnValue(false);
2020
}
2121
}
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
package org.polyfrost.colorsaturation
2+
3+
//#if FORGE
4+
import net.minecraftforge.fml.common.Mod
5+
import net.minecraftforge.fml.common.event.FMLInitializationEvent
6+
//#else
7+
//$$ import net.fabricmc.api.ClientModInitializer
8+
//#endif
9+
10+
import org.polyfrost.colorsaturation.command.SaturationCommand
11+
import org.polyfrost.colorsaturation.config.SaturationConfig
12+
import org.polyfrost.oneconfig.api.commands.v1.CommandManager
13+
import org.polyfrost.oneconfig.api.event.v1.EventManager
14+
15+
//#if FORGE
16+
@Mod(modid = ColorSaturation.ID, version = ColorSaturation.VERSION, name = ColorSaturation.NAME, modLanguageAdapter = "org.polyfrost.oneconfig.utils.v1.forge.KotlinLanguageAdapter")
17+
//#endif
18+
object ColorSaturation
19+
//#if FABRIC
20+
//$$ : ClientModInitializer
21+
//#endif
22+
{
23+
24+
const val ID = "@MOD_ID@"
25+
const val NAME = "@MOD_NAME@"
26+
const val VERSION = "@MOD_VERSION@"
27+
28+
@JvmStatic
29+
lateinit var config: SaturationConfig
30+
private set
31+
32+
fun initialize() {
33+
config = SaturationConfig()
34+
CommandManager.registerCommand(SaturationCommand())
35+
EventManager.INSTANCE.register(Saturation())
36+
}
37+
38+
//#if FORGE
39+
@Mod.EventHandler
40+
fun onInit(e: FMLInitializationEvent) {
41+
initialize()
42+
}
43+
//#else
44+
//$$ override fun onInitializeClient() {
45+
//$$ initialize()
46+
//$$ }
47+
//#endif
48+
49+
}

src/main/resources/fabric.mod.json

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
{
2+
"schemaVersion": 1,
3+
"id": "${mod_id}",
4+
"version": "${mod_version}",
5+
"name": "${mod_name}",
6+
"authors": [
7+
"Polyfrost"
8+
],
9+
"contact": {
10+
"issues": "https://github.com/Polyfrost/${mod_name}/issues",
11+
"sources": "https://github.com/Polyfrost/${mod_name}"
12+
},
13+
"license": "GPL-3.0-or-later",
14+
"environment": "*",
15+
"entrypoints": {
16+
"client": [
17+
{
18+
"adapter": "kotlin",
19+
"value": "org.polyfrost.colorsaturation.ColorSaturation"
20+
}
21+
]
22+
},
23+
"mixins": [
24+
"mixins.${mod_id}.json"
25+
],
26+
"depends": {
27+
"fabricloader": ">=0.15.11",
28+
"fabric-language-kotlin": "*"
29+
}
30+
}

0 commit comments

Comments
 (0)