From 0e737be16abc1d2c315b5e4cb65210be0d7ea311 Mon Sep 17 00:00:00 2001 From: 3944Realms Date: Tue, 17 Feb 2026 15:18:48 +0800 Subject: [PATCH] =?UTF-8?q?=E9=99=90=E5=AE=9A=E5=8A=A0=E8=BD=BDCompat?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- gradle.properties | 2 +- .../lib39/core/compat/CompatManager.java | 29 ++++++++++--------- 2 files changed, 16 insertions(+), 15 deletions(-) diff --git a/gradle.properties b/gradle.properties index 450d9fc..a1943e1 100644 --- a/gradle.properties +++ b/gradle.properties @@ -33,7 +33,7 @@ mod_name=3944Realms 's Lib Mod # The license of the mod. Review your options at https://choosealicense.com/. All Rights Reserved is the default. mod_license=MIT # The mod version. See https://semver.org/ -mod_version=0.3.4 +mod_version=0.3.5 # The group ID for the mod. It is only important when publishing as an artifact to a Maven repository. # This should match the base package used for the mod sources. # See https://maven.apache.org/guides/mini/guide-naming-conventions.html diff --git a/src/main/java/top/r3944realms/lib39/core/compat/CompatManager.java b/src/main/java/top/r3944realms/lib39/core/compat/CompatManager.java index 9ed16c7..7bea740 100644 --- a/src/main/java/top/r3944realms/lib39/core/compat/CompatManager.java +++ b/src/main/java/top/r3944realms/lib39/core/compat/CompatManager.java @@ -3,6 +3,7 @@ package top.r3944realms.lib39.core.compat; import net.minecraft.resources.ResourceLocation; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.eventbus.api.IEventBus; +import net.minecraftforge.fml.DistExecutor; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent; import net.minecraftforge.fml.event.lifecycle.FMLConstructModEvent; @@ -213,20 +214,20 @@ public abstract class CompatManager { // 根据配置调用对应的 ICompat 方法 if (config.dists != null) { switch (config.dists) { - case CLIENT -> { - if (config.bus == Mod.EventBusSubscriber.Bus.FORGE) { - compat.addClientGameListener(gameEventBus); - } else { - compat.addClientModListener(modEventBus); - } - } - case DEDICATED_SERVER -> { - if (config.bus == Mod.EventBusSubscriber.Bus.FORGE) { - compat.addServerGameListener(gameEventBus); - } else { - compat.addServerModListener(modEventBus); - } - } + case CLIENT -> DistExecutor.unsafeRunWhenOn(Dist.CLIENT,() -> () -> { + if (config.bus == Mod.EventBusSubscriber.Bus.FORGE) { + compat.addClientGameListener(gameEventBus); + } else { + compat.addClientModListener(modEventBus); + } + }); + case DEDICATED_SERVER -> DistExecutor.unsafeRunWhenOn(Dist.DEDICATED_SERVER,() -> () -> { + if (config.bus == Mod.EventBusSubscriber.Bus.FORGE) { + compat.addClientGameListener(gameEventBus); + } else { + compat.addClientModListener(modEventBus); + } + }); } } else { // 通用监听器