BSCM

BSCM

Ben的S####配置模组——一个旨在同时方便地在服务端与客户端运行的简单配置模组。

基础库

BSCM (Ben's S#### Config Mod)

BSCM 是一个面向 Fabric 模组的轻量级 YAML 配置库。它简化了配置的创建、加载和编辑,让你可以专注于构建功能而不是样板代码。

特性

  • 基于注解的配置

使用简单的注解直接在代码中定义你的配置结构。

  • YAML 支持

人类可读、简洁且被广泛支持的配置格式。

  • 自动加载与保存 无需手动修改配置 YAML(服务端仍需要),BSCM 会为你完成一切。

内置配置界面(支持 Mod Menu) 通过 Mod Menu 轻松在游戏内编辑配置。

  • 极简且对开发者友好

旨在不碍事的同时给予你完全的控制权。

用法

  1. 创建一个配置类

  2. 为你想暴露的字段添加注解

  3. 剩下的交给 BSCM

示例:

Gradle:

repositories{

  maven {

    name = "Modrinth"

    url = "https://api.modrinth.com/maven"
  }
  maven {
    name = "Terraformers"
    url = "https://maven.terraformersmc.com/"
  }
}
dependencies {

  modImplementation "maven.modrinth:bscm:1.0.4"
  modImplementation "com.terraformersmc:modmenu:${project.modmenu_version}"

}

配置类:

public class ExampleConfig {

@Comment("Enable the feature")
public boolean enabled = true:

@Comment("Maximum value")
public int maxValue = 10;
}

主类:


import ca.techgarage.bscm.Bscm;

public void onInitialize() {

Bscm.load(ExampleConfig.class, "ModID");
}

如何设置客户端

要进行设置,你必须依赖你所使用版本的 ModMenu

ModMenu 集成类

public class MyModMenuIntegration extends BSCMModMenuIntegration {
    public MyModMenuIntegration() {
        super(ExampleConfig.class, "ModID");
    }
}

在你的 fabric.mod.json 中

"entrypoints": {
    "modmenu": [
        "com.example.mymod.MyModMenuIntegration"
    ]
}

BSCM 将自动:

  • 生成一个 YAML 文件

  • 在启动时加载值

  • 在更新时保存更改

游戏内配置

如果你安装了 Mod Menu,BSCM 提供一个简单的配置 GUI,让用户无需离开游戏即可编辑设置。

依赖

  • Fabric Loader ≥ 0.15.0

  • (可选)Mod Menu 用于游戏内配置界面

为什么选择 BSCM?

大多数配置系统要么:

过于复杂

过于受限

或者需要大量样板代码

BSCM 旨在找到最佳平衡点:

简单、可读,且足够强大以适用于真实的模组。