
CraftCoreLIB
跨平台库,为模组开发者提供注册表和实用工具。
CraftCoreLIB
CraftCoreLib 是一个为开发者构建的跨平台库,用于简化多加载器上的注册表以及提供更多功能!
注册表
该库为简单的注册表提供核心代码,例如方块、物品、创造模式标签页到配方类型、配方序列化器、菜单等,还有更多功能即将推出!!
使用示例
public class ModBlocks {
// Simple Block registration
public static final ObjectRegistries<Block> MY_BLOCK = ObjectRegistries.registerBlock(
ResourceLocation.fromNamespaceAndPath("yourmoid", "my_block"),
()-> new Block(BlockBehaviour.Properties.of()));
// It must stay empty, call it on related Init class(for fabric the one implementing ModInitializer for neoforge the class with the @Mod annotation)
public static void init() {}
}
并在我们的设置中初始化所有注册表:
- Fabric -> ModInitializer 类
- NeoForge -> 带有 @Mod 注解的类
// Placeholder
public void init() {
ModBlocks.init();
}
then if Neoforge do this:
private void onRegister(RegisterEvent event) {
ObjectRegistries.createAll("yourmoid", event.getRegistry());
}
if Fabric inside ModInitializer, after all your init add this:
ObjectRegistries.createAll("yourmoid");
配置
CraftCoreLIB 还提供了一个专用的配置系统,带有与其他模组兼容的自定义配置屏幕!!
使用示例
public class ModConfigs {
//Defining all your configs, ConfigValue<> accept all type of configs, Integer, Boolean, Enum, String even your custom one
public static final ConfigValue<Boolean> check;
public static final ConfigValue<Integer> i;
//The config Builder where we build our configs, the constructur needs the modid and the env type: CLIENT, SERVER or COMMON
public static final ConfigBuilder BUILDER = new ConfigBuilder("mod_id", ConfigType.CLIENT);
//Inside a static method we register our configs
static {
//Category 1 creantion, we call start to start a category and end to close it, everything behind them is register into the first category
BUILDER.strart("category1");
//All the configs you desire to insert onto the 1° category should go there.
//The define method accept Integer, Boolean, Enum, String even you custom one!
this.check = BUILDER.comment("allows to check something")
.defineBoolean("check", false);
BUILDER.end();
//Category 2 creation or how many you want
BUILDER.strart("category2");
this.i = BUILDER.comment("allows to check something")
.defineInt("i",MINVALUE 0, MAXVALUE 10, DEFAULT VALUE 5);
BUILDER.end();
//It's also possible to create a main category with each sub category
BUILDER.start("main");
BUILDER.start("category3");
this.check = BUILDER.comment("allows to check something")
.defineBoolean("check", false);
this.i = BUILDER.comment("allows to check something")
.defineInt("i",MINVALUE 0, MAXVALUE 10, DEFAULT VALUE 5);
BUILDER.end();
BUILDER.end();
}
public static void init() {
BUILDER.build();
}
}
配置屏幕
它提供了一个易于访问的专用配置屏幕。 它还会获取所有带有配置的可用模组,它不是模组列表菜单,只显示带有配置的模组!!

网络构建器
它包含以下功能:
- 自定义数据包的创建与处理
- 网络创建
- 网络注册
在 GitHub 上查看更多内容
在 Discord GitHub Issues 上报告问题
我的其他项目
正在加载版本记录…
正在加载评论…
评论在新手盒子客户端中发表,这里同步展示。