ConfigAnytime是一款强大的工具,使开发人员能够在Forge加载阶段的任何时候设置配置。这对于需要在游戏加载过程中动态配置的开发者来说尤其有用。下面将详细介绍ConfigAnytime的使用方法和功能。
开发者使用指南:
首先,您需要将CleanroomMC的仓库添加到项目中,并依赖于ConfigAnytime的Maven条目:
html
repositories {
maven {
url 'https://maven.cleanroommc.com'
}
}
dependencies {
implementation 'com.cleanroommc:configanytime:3.0'
}
已复制!
然后,您可以使用以下示例API来配置您的Mod:
html
@Config(modid = "configanytime")
public class ConfigClass {
public static boolean configBooleanProperty = true;
public static int configIntProperty = 42;
public static final InnerClass INNER_CLASS = new InnerClass(); // Inner access via this member, this is processed automatically by ConfigManager
public static class InnerClass {
public boolean innerProperty = false; // Must be non-static, referenced via the member field in the outer class
}
// Static initializers go after the properties!
// This will run automatically when you retrieve any properties from this config class
static {
ConfigAnytime.register(ConfigClass.class);
}
}
已复制!
上述代码展示了如何使用ConfigAnytime来配置您的Mod。您可以定义各种类型的配置属性,包括布尔值、整数等。同时,您还可以定义内部类来组织您的配置属性。
重要提示:静态初始化器必须在属性之后定义。这将在从配置类检索任何属性时自动运行。
通过ConfigAnytime,您可以轻松地实现动态配置,为您的Mod带来更灵活的功能。
来自Modrinth
3.0
!configanytime-3.0.jar下载3.0#Release
- Fixes configs not being named when annotation name isn't populated
展开
版本: 3.0
支持游戏: 1.12.2
类型: Forge
Release
下载次数: 52,558
2.0
!configanytime-2.0.jar下载2.0#Release
- Delay NO-OP checks so configurations registered in ILateMixinLoader runs properly
展开
版本: 2.0
支持游戏: 1.12.2
类型: Forge
Release
下载次数: 3,640
1.0 - First release
!configanytime-1.0.jar下载1.0#Release
First release.
展开
版本: 1.0
支持游戏: 1.12.2
类型: Forge
Release
下载次数: 10,268
收录