更新内容

1. 修正兼容事件
This commit is contained in:
叁玖领域 2026-01-02 03:13:43 +08:00
parent 66d00f1892
commit 33427074fd
3 changed files with 24 additions and 9 deletions

View File

@ -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.0.26
mod_version=0.0.28
# 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

View File

@ -47,6 +47,7 @@ public class CompatManager {
return;
}
compats.put(id, compat);
addListenerForCompat(id);
Lib39.LOGGER.debug("Registered compat: {}", id);
}
@ -81,6 +82,22 @@ public class CompatManager {
public void addListenerForCompat(ResourceLocation compatId, @Nullable Dist dists, Mod.EventBusSubscriber.Bus bus) {
listenerConfigs.add(new ListenerConfig(compatId, dists, bus));
}
/**
* 为特定兼容模块配置事件监听器
*
* @param compatId the compat id
*/
public void addListenerForCompat(ResourceLocation compatId) {
addListenerForCompat(compatId, null, Mod.EventBusSubscriber.Bus.FORGE);
addListenerForCompat(compatId, null, Mod.EventBusSubscriber.Bus.MOD);
addListenerForCompat(compatId, Dist.CLIENT, Mod.EventBusSubscriber.Bus.FORGE);
addListenerForCompat(compatId, Dist.CLIENT, Mod.EventBusSubscriber.Bus.MOD);
addListenerForCompat(compatId, Dist.DEDICATED_SERVER, Mod.EventBusSubscriber.Bus.FORGE);
addListenerForCompat(compatId, Dist.DEDICATED_SERVER, Mod.EventBusSubscriber.Bus.MOD);
}
/**
* 为已加载的兼容模块配置事件监听器

View File

@ -61,6 +61,7 @@ public class CommonEventHandler {
*/
static volatile SyncData2Manager syncData2Manager;
private static boolean isSync2MInitialized = false;
private static boolean isCompatInitialized = false;
/**
* Gets sync data 2 manager.
@ -89,6 +90,11 @@ public class CommonEventHandler {
sl = serverLevel;
Lib39.LOGGER.info("SyncData2Manager initialized on world load");
}
if (!isCompatInitialized) {
MinecraftForge.EVENT_BUS.post(new RegisterCompatEvent(Mod.compatManager));
Mod.compatManager.initializeAll();
isCompatInitialized = true;
}
}
}
@ -210,14 +216,6 @@ public class CommonEventHandler {
});
}
@SubscribeEvent
public static void onFMLComplete(FMLLoadCompleteEvent event) {
event.enqueueWork(() -> {
MinecraftForge.EVENT_BUS.post(new RegisterCompatEvent(compatManager));
compatManager.initializeAll();
});
}
/**
* Add item to tabs.
*