跳到正文

Conditional Proxy Mod Initializers

作者:Feintha

A simple library for running a proxy Fabric initializer if a required mod exists

收藏

截图

介绍

中文介绍正在准备中,下面暂时显示原文。

A simple 5-class mod which adds support for initializing code depending on if a specific mod exists.

This mod will always load last, so there is no need to worry about race conditions due to mod load order.

Code and variables must be available before or during any mod initialization stages
(ie cannot be done on datapack reload for example)

Usage:


// Inside main ModInitializer, ClientModInitializer, or any class that gets called at some point during Fabric init

// For running an instance of a ModInitializer:
ConditionalModInitializer myConditionalModInitializer = new ConditionalModInitializer.Builder().mods("some-mod").initializer(SomeOtherInitializer.class).build();

// For running any unspecified code:

ConditionalModInitializer myConditionalRunner = new ConditionalModInitializer.Builder().mods("some-other-mod").found(() -> {
  // Code goes here
}).build();
    public void onInitialize() {
ConditionalModInitializer.create().mods("some_mod").required_mods("some_other_dependency_mod").initializer(AnotherInitializer.class).build();
}
  • NOTE: new ConditionalModInitializer.Builder() MUST be assigned to a variable, or be called inside a function to work! Static declaration ( static{} will NOT work!)

Docs:

  • ConditionalModInitializer
  • create() -> Returns a new Builder() instance. (Same as running new ConditionalModInitializer.Builder())
  • mods() -> List : Returns the list of any mod that is required for this initializer
  • required_mods() -> List : Returns list of all required mods for this initializer
  • can_run -> Boolean : Whether or not the initializer has ran yet
  • environment() -> ExtendedEnvType : Returns the environment (initializer type) for this initializer
  • ExtendedEnvType.CLIENT : ClientModInitializer
  • ExtendedEnvType.SERVER : ModInitializer
  • ExtendedEnvType.DEDICATED_SERVER: DedicatedServerModInitializer
  • on_found() -> Runnable : Returns the function to call when a required mod is found
  • ConditionalModInitializer.Builder
  • mods(String...) : Appends to the list of mods that will allow this initializer to run
  • required_mods(String...) : Appends to the list of required mods for this initializer
  • environment(ExtendedEnvType) : Sets the environment of the initializer (Default: ExtendedEnvType.SERVER : ModInitializer)
  • found(Runnable) : Code to execute if the mod is found
  • initializer(Class<ModInitializer>) : Initializer to run if the mod is found
  • mainInitializer(Class<ModInitializer>) : Initializer to run if the mod is found
  • clientInitializer(Class<ClientModInitializer>) : Initializer to run if the mod is found
  • serverInitializer(Class<DedicatedServerModInitializer>) : Initializer to run if the mod is found
  • build() : Returns the finalized ConditionalModInitializer

常见问题

Conditional Proxy Mod Initializers 支持哪些 Minecraft 版本?

Conditional Proxy Mod Initializers 支持 Minecraft Java 版 1.14–1.21,共 32 个版本,可用的加载器:Fabric。下载时注意选择和你游戏版本一致的文件。

Conditional Proxy Mod Initializers 怎么安装?

先用 PCL2 或 HMCL 启动器安装对应版本的 Fabric,再把下载的 .jar 文件放进游戏目录的 mods 文件夹,重新启动游戏即可。开启了版本隔离的,mods 文件夹在 versions/版本名 下面。运行环境:客户端和服务端都要装。

评论

登录后评论和评分

Feintha 的其他作品

查看全部 →