[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

@@ -14,17 +14,16 @@
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.screens.Screen;
import net.minecraftforge.client.ConfigScreenHandler;
@@ -28,17 +31,22 @@
@@ -28,16 +31,21 @@
*/
@Inject(at = @At("RETURN"), method = "getScreenFactoryFor", 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

@@ -24,7 +24,7 @@
import java.util.Objects;
@@ -48,22 +37,5 @@
@@ -48,21 +37,5 @@
public Connection getClientConnection() {
Objects.requireNonNull(Minecraft.getInstance().getConnection(), "Cannot send packets when not in game!");
return Minecraft.getInstance().getConnection().getConnection();
@@ -34,12 +34,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

@@ -1,6 +1,6 @@
--- /dev/null
+++ b/NeoForge/src/main/java/com/hypherionmc/craterlib/mixin/ConfigScreenHandlerMixin.java
@@ -1,0 +1,44 @@
@@ -1,0 +1,43 @@
+package com.hypherionmc.craterlib.mixin;
+
+import com.hypherionmc.craterlib.client.gui.config.CraterConfigScreen;
@@ -32,9 +32,8 @@
+ */
+ @Inject(at = @At("RETURN"), method = "getScreenFactoryFor", cancellable = true, remap = false)
+ private static void injectConfigScreen(IModInfo selectedMod, CallbackInfoReturnable<Optional<BiFunction<Minecraft, Screen, Screen>>> cir) {
+ ConfigController.getWatchedConfigs().forEach((conf, watcher) -> {
+ ConfigController.getWatchedConfigs().forEach((conf, config) -> {
+ if (!conf.getClass().isAnnotationPresent(NoConfigScreen.class)) {
+ AbstractConfig config = watcher.getLeft();
+ if (config.getModId().equals(selectedMod.getModId())) {
+ cir.setReturnValue(
+ Optional.of((minecraft, screen) -> new CraterConfigScreen(config, screen))

View File

@@ -23,7 +23,7 @@
+neoforge_version=234
# Dependencies
moon_config=1.0.10
moon_config=1.0.11
@@ -29,23 +29,23 @@
adventure=4.17.0
rpc_sdk=1.0