Skip to content

Commit

Permalink
feat: change how config screens are registered on neo
Browse files Browse the repository at this point in the history
chore: update versions
  • Loading branch information
Jamalam360 committed Jul 31, 2024
1 parent c7f5fa6 commit 051c1bf
Show file tree
Hide file tree
Showing 12 changed files with 60 additions and 65 deletions.
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
- Port 1.0.9 to Minecraft 1.21
- Update versions.
- Modify how config screens are registered on Neoforge.

2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
plugins {
id "architectury-plugin" version "3.4-SNAPSHOT"
id "dev.architectury.loom" version "1.6-SNAPSHOT" apply false
id "dev.architectury.loom" version "1.7-SNAPSHOT" apply false
id "com.github.breadmoirai.github-release" version "2.4.1"
id "maven-publish"
}
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
org.gradle.jvmargs=-Xmx3G
org.gradle.daemon=false
org.gradle.parallel=true
version=1.0.9+1.21
version=1.0.10+1.21
minecraft_version=1.21
branch=main
group=io.github.jamalam360
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
6 changes: 3 additions & 3 deletions libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
[versions]
# https://modrinth.com/mod/architectury-api/versions
architectury = "13.0.1"
architectury = "13.0.6"

# https://projects.neoforged.net/neoforged/neoforge
neoforge = "21.0.4-beta"
neoforge = "21.0.144"

# https://fabricmc.net/develop
fabric-loader = "0.15.11"
fabric-api = "0.100.1+1.21"

# https://modrinth.com/mod/modmenu/versions
modmenu = "11.0.0-beta.1"
modmenu = "11.0.1"

# https://github.com/falkreon/Jankson/releases/latest
jankson = "1.2.3"
Expand Down
2 changes: 1 addition & 1 deletion neoforge/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ publishing {
}

processResources {
filesMatching("mods.toml") {
filesMatching("neoforge.mods.toml") {
expand "minecraft_version": project.minecraft_version,
"architectury_version": libs.versions.architectury.get()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@

@Mod(JamLib.MOD_ID)
public class JamLibNeoForge {

public JamLibNeoForge() {
JamLib.init();
}
public JamLibNeoForge() {
JamLib.init();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package io.github.jamalam360.jamlib.neoforge;

import io.github.jamalam360.jamlib.JamLib;
import io.github.jamalam360.jamlib.config.ConfigManager;
import io.github.jamalam360.jamlib.config.gui.ConfigScreen;
import io.github.jamalam360.jamlib.config.gui.SelectConfigScreen;
import net.neoforged.api.distmarker.Dist;
import net.neoforged.bus.api.IEventBus;
import net.neoforged.fml.ModList;
import net.neoforged.fml.common.Mod;
import net.neoforged.fml.event.lifecycle.FMLLoadCompleteEvent;
import net.neoforged.neoforge.client.gui.IConfigScreenFactory;

import java.util.List;

@Mod(value = JamLib.MOD_ID, dist = Dist.CLIENT)
public class JamLibNeoForgeClient {

public JamLibNeoForgeClient(IEventBus bus) {
bus.addListener(this::onFmlLoadComplete);
}

private void onFmlLoadComplete(FMLLoadCompleteEvent ev) {
ev.enqueueWork(() -> {
JamLib.LOGGER.info("Registering config screens for mods");
ModList.get().forEachModContainer((modId, mod) -> {
List<ConfigManager<?>> managers = ConfigManager.MANAGERS.values().stream().filter(m -> m.getModId().equals(modId)).toList();

if (mod.getCustomExtension(IConfigScreenFactory.class).isPresent() || managers.isEmpty()) {
return;
}

mod.registerExtensionPoint(IConfigScreenFactory.class, createConfigScreenFactory(modId, managers));
});
});
}

private IConfigScreenFactory createConfigScreenFactory(String modId, List<ConfigManager<?>> managers) {
if (managers.size() == 1) {
return (_mod, parent) -> new ConfigScreen<>(managers.getFirst(), parent);
} else {
return (_mod, parent) -> new SelectConfigScreen(parent, modId);
}
}
}

This file was deleted.

5 changes: 1 addition & 4 deletions neoforge/src/main/resources/META-INF/neoforge.mods.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,10 @@ logoFile = "icon.png"
authors = "Jamalam"
description = '''The platform-agnostic library used in all of JamCore's mods'''

[[mixins]]
config = "jamlib.neoforge.mixins.json"

[[dependencies.jamlib]]
modId = "neoforge"
type = "required"
versionRange = "[20.4,)"
versionRange = "[21,)"
ordering = "NONE"
side = "BOTH"

Expand Down
16 changes: 0 additions & 16 deletions neoforge/src/main/resources/jamlib.neoforge.mixins.json

This file was deleted.

1 change: 1 addition & 0 deletions testmod-neoforge/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ repositories {

dependencies {
neoForge libs.neoforge
modImplementation libs.architectury.neoforge
forgeRuntimeLibrary libs.jankson

implementation project(path: ":neoforge", configuration: "namedElements")
Expand Down

0 comments on commit 051c1bf

Please sign in to comment.