generated from JamCoreModding/template-mod
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: change how config screens are registered on neo
chore: update versions
- Loading branch information
1 parent
c7f5fa6
commit 051c1bf
Showing
12 changed files
with
60 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
neoforge/src/main/java/io/github/jamalam360/jamlib/neoforge/JamLibNeoForgeClient.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} | ||
} |
33 changes: 0 additions & 33 deletions
33
...e/src/main/java/io/github/jamalam360/jamlib/neoforge/mixin/IConfigScreenFactoryMixin.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters