diff --git a/build.gradle b/build.gradle index 1126b4dc..0db7700f 100644 --- a/build.gradle +++ b/build.gradle @@ -21,6 +21,8 @@ dependencies { api("ca.spottedleaf:concurrentutil:${rootProject.concurrentutil_version}") api("org.yaml:snakeyaml:${rootProject.snakeyaml_version}") + + modImplementation "me.shedaniel.cloth:cloth-config:${rootProject.cloth_version}" } File awFile = file("src/main/resources/moonrise.accesswidener") @@ -45,6 +47,8 @@ allprojects { includeModule("ca.spottedleaf", "concurrentutil") } } + maven { url "https://maven.shedaniel.me/" } + maven { url "https://maven.terraformersmc.com/releases/" } } dependencies { diff --git a/fabric/build.gradle b/fabric/build.gradle index c76ef650..f238fce6 100644 --- a/fabric/build.gradle +++ b/fabric/build.gradle @@ -19,6 +19,10 @@ dependencies { libs("ca.spottedleaf:concurrentutil:${rootProject.concurrentutil_version}") libs("org.yaml:snakeyaml:${rootProject.snakeyaml_version}") + + modImplementation "me.shedaniel.cloth:cloth-config-fabric:${rootProject.cloth_version}" + include "me.shedaniel.cloth:cloth-config-fabric:${rootProject.cloth_version}" + modImplementation "com.terraformersmc:modmenu:11.0.1" } processResources { diff --git a/fabric/src/main/java/ca/spottedleaf/moonrise/fabric/MoonriseModMenuHook.java b/fabric/src/main/java/ca/spottedleaf/moonrise/fabric/MoonriseModMenuHook.java new file mode 100644 index 00000000..51379248 --- /dev/null +++ b/fabric/src/main/java/ca/spottedleaf/moonrise/fabric/MoonriseModMenuHook.java @@ -0,0 +1,12 @@ +package ca.spottedleaf.moonrise.fabric; + +import ca.spottedleaf.moonrise.common.config.MoonriseConfigScreen; +import com.terraformersmc.modmenu.api.ConfigScreenFactory; +import com.terraformersmc.modmenu.api.ModMenuApi; + +public final class MoonriseModMenuHook implements ModMenuApi { + @Override + public ConfigScreenFactory getModConfigScreenFactory() { + return MoonriseConfigScreen::create; + } +} diff --git a/fabric/src/main/resources/fabric.mod.json b/fabric/src/main/resources/fabric.mod.json index 28a2bb18..0d7bd141 100644 --- a/fabric/src/main/resources/fabric.mod.json +++ b/fabric/src/main/resources/fabric.mod.json @@ -22,7 +22,9 @@ "license": "GPL-3.0-only", "icon": "assets/moonrise/icon.png", "environment": "*", - "entrypoints": {}, + "entrypoints": { + "modmenu": ["ca.spottedleaf.moonrise.fabric.MoonriseModMenuHook"] + }, "mixins": [ "moonrise.mixins.json", "moonrise-fabric.mixins.json" diff --git a/gradle.properties b/gradle.properties index 19d1a8ec..1efc2202 100644 --- a/gradle.properties +++ b/gradle.properties @@ -9,6 +9,7 @@ loader_version=0.15.11 neoforge_version=21.0.153 snakeyaml_version=2.2 concurrentutil_version=0.0.2-SNAPSHOT +cloth_version=15.0.128 # Mod Properties mod_version=1.0.0 maven_group=ca.spottedleaf.moonrise diff --git a/neoforge/build.gradle b/neoforge/build.gradle index ee7558f7..887cbf76 100644 --- a/neoforge/build.gradle +++ b/neoforge/build.gradle @@ -30,6 +30,9 @@ dependencies { libs("ca.spottedleaf:concurrentutil:${rootProject.concurrentutil_version}") libs("org.yaml:snakeyaml:${rootProject.snakeyaml_version}") + + modImplementation "me.shedaniel.cloth:cloth-config-neoforge:${rootProject.cloth_version}" + include "me.shedaniel.cloth:cloth-config-neoforge:${rootProject.cloth_version}" } processResources { diff --git a/neoforge/src/main/java/ca/spottedleaf/moonrise/neoforge/MoonriseNeoForge.java b/neoforge/src/main/java/ca/spottedleaf/moonrise/neoforge/MoonriseNeoForge.java new file mode 100644 index 00000000..40bb14ce --- /dev/null +++ b/neoforge/src/main/java/ca/spottedleaf/moonrise/neoforge/MoonriseNeoForge.java @@ -0,0 +1,20 @@ +package ca.spottedleaf.moonrise.neoforge; + +import ca.spottedleaf.moonrise.common.config.MoonriseConfigScreen; +import net.neoforged.bus.api.IEventBus; +import net.neoforged.fml.ModLoadingContext; +import net.neoforged.fml.common.Mod; +import net.neoforged.fml.event.lifecycle.FMLClientSetupEvent; +import net.neoforged.neoforge.client.gui.IConfigScreenFactory; + +@Mod("moonrise") +public final class MoonriseNeoForge { + public MoonriseNeoForge(final IEventBus modBus) { + modBus.addListener(FMLClientSetupEvent.class, event -> { + ModLoadingContext.get().registerExtensionPoint( + IConfigScreenFactory.class, + () -> (modContainer, parent) -> MoonriseConfigScreen.create(parent) + ); + }); + } +} diff --git a/src/main/java/ca/spottedleaf/moonrise/common/config/MoonriseConfigScreen.java b/src/main/java/ca/spottedleaf/moonrise/common/config/MoonriseConfigScreen.java new file mode 100644 index 00000000..d0a85a36 --- /dev/null +++ b/src/main/java/ca/spottedleaf/moonrise/common/config/MoonriseConfigScreen.java @@ -0,0 +1,18 @@ +package ca.spottedleaf.moonrise.common.config; + +import me.shedaniel.clothconfig2.api.ConfigBuilder; +import net.minecraft.client.gui.screens.Screen; +import net.minecraft.network.chat.Component; + +public final class MoonriseConfigScreen { + private MoonriseConfigScreen() { + } + + public static Screen create(final Screen parent) { + final ConfigBuilder builder = ConfigBuilder.create() + .setParentScreen(parent) + .setTitle(Component.translatable("title.examplemod.config")); + + return builder.build(); + } +}