[BUG] Fix Config watcher using too many threads and not detecting changes on Linux systems

This commit is contained in:
2025-03-13 15:01:19 +02:00
parent 1a48fb6d33
commit 23720f6629
65 changed files with 186 additions and 178 deletions

View File

@@ -18,7 +18,7 @@
import net.minecraftforge.forgespi.language.IModInfo;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
@@ -19,24 +22,30 @@
@@ -19,23 +22,29 @@
/**
* @author HypherionSA
*/
@@ -33,13 +33,12 @@
- @Inject(at = @At("RETURN"), method = "getScreenFactoryFor", cancellable = true, remap = false)
+ @Inject(at = @At("RETURN"), method = "getGuiFactoryFor", cancellable = true, remap = false)
private static void injectConfigScreen(IModInfo selectedMod, CallbackInfoReturnable<Optional<BiFunction<Minecraft, Screen, Screen>>> cir) {
- ConfigController.getMonitoredConfigs().forEach((conf, watcher) -> {
- ConfigController.getMonitoredConfigs().forEach((conf, config) -> {
+ ConfigController.getWatchedConfigs().forEach((conf, watcher) -> {
AbstractConfig config = watcher.getLeft();
if (config.getClass().isAnnotationPresent(NoConfigScreen.class))
return;
- if (watcher.getLeft().getClass().isAnnotationPresent(ClothScreen.class) && (ModloaderEnvironment.INSTANCE.isModLoaded("cloth_config") || ModloaderEnvironment.INSTANCE.isModLoaded("cloth-config") || ModloaderEnvironment.INSTANCE.isModLoaded("clothconfig"))) {
- if (config.getClass().isAnnotationPresent(ClothScreen.class) && (ModloaderEnvironment.INSTANCE.isModLoaded("cloth_config") || ModloaderEnvironment.INSTANCE.isModLoaded("cloth-config") || ModloaderEnvironment.INSTANCE.isModLoaded("clothconfig"))) {
- ModList.get().getModContainerById(config.getModId()).ifPresent(c -> c.registerExtensionPoint(IConfigScreenFactory.class, ((minecraft, screen) -> ClothConfigScreenBuilder.buildConfigScreen(config, screen))));
- } else {
- //ModList.get().getModContainerById(config.getModId()).ifPresent(c -> c.registerExtensionPoint(IConfigScreenFactory.class, ((minecraft, screen) -> new CraterConfigScreen(config, screen))));

View File

@@ -1,6 +1,6 @@
--- a/NeoForge/src/main/java/com/hypherionmc/craterlib/client/NeoForgeClientHelper.java
+++ /dev/null
@@ -1,69 +1,0 @@
@@ -1,68 +1,0 @@
-package com.hypherionmc.craterlib.client;
-
-import com.hypherionmc.craterlib.api.events.client.LateInitEvent;
@@ -57,12 +57,11 @@
- LateInitEvent event = new LateInitEvent(new BridgedMinecraft(), BridgedOptions.of(Minecraft.getInstance().options));
- CraterEventBus.INSTANCE.postEvent(event);
-
- ConfigController.getWatchedConfigs().forEach((conf, watcher) -> {
- AbstractConfig config = watcher.getLeft();
- ConfigController.getWatchedConfigs().forEach((conf, config) -> {
- if (config.getClass().isAnnotationPresent(NoConfigScreen.class))
- return;
-
- if (watcher.getLeft().getClass().isAnnotationPresent(ClothScreen.class) && (ModloaderEnvironment.INSTANCE.isModLoaded("cloth_config") || ModloaderEnvironment.INSTANCE.isModLoaded("cloth-config") || ModloaderEnvironment.INSTANCE.isModLoaded("clothconfig"))) {
- if (config.getClass().isAnnotationPresent(ClothScreen.class) && (ModloaderEnvironment.INSTANCE.isModLoaded("cloth_config") || ModloaderEnvironment.INSTANCE.isModLoaded("cloth-config") || ModloaderEnvironment.INSTANCE.isModLoaded("clothconfig"))) {
- ModList.get().getModContainerById(config.getModId()).ifPresent(c -> c.registerExtensionPoint(IConfigScreenFactory.class, ((minecraft, screen) -> ClothConfigScreenBuilder.buildConfigScreen(config, screen))));
- } else {
- //ModList.get().getModContainerById(config.getModId()).ifPresent(c -> c.registerExtensionPoint(IConfigScreenFactory.class, ((minecraft, screen) -> new CraterConfigScreen(config, screen))));

View File

@@ -22,7 +22,7 @@
+forge_version=40.2.0
# Dependencies
moon_config=1.0.10
moon_config=1.0.11
@@ -29,23 +26,22 @@
adventure=4.17.0
rpc_sdk=1.0