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 { // 通用监听器