Skip to content

Commit

Permalink
setup config screen
Browse files Browse the repository at this point in the history
  • Loading branch information
jpenilla committed Aug 7, 2024
1 parent b6456c4 commit d8f82ec
Show file tree
Hide file tree
Showing 8 changed files with 65 additions and 1 deletion.
4 changes: 4 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -45,6 +47,8 @@ allprojects {
includeModule("ca.spottedleaf", "concurrentutil")
}
}
maven { url "https://maven.shedaniel.me/" }
maven { url "https://maven.terraformersmc.com/releases/" }
}

dependencies {
Expand Down
4 changes: 4 additions & 0 deletions fabric/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
}
}
4 changes: 3 additions & 1 deletion fabric/src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
1 change: 1 addition & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions neoforge/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
@@ -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)
);
});
}
}
Original file line number Diff line number Diff line change
@@ -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();
}
}

0 comments on commit d8f82ec

Please sign in to comment.