跳到正文

QoLib

作者:Quantum8060

Prerequisites for mods created by Quantum8060

收藏

介绍

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

QoLib

Shared utilities for Quantum8060’s Fabric mods.

Client Config API

The first QoLib API is a client-only JSON config store. Its public types do not
expose Minecraft classes, so consumer mods may use either Mojang or Yarn mappings.

private static final ConfigValue<Boolean> ENABLED = ConfigValue.booleanValue("enabled", false);
private static final ClientConfig CONFIG = ClientConfig.builder("viewer-mod")
    .add(ENABLED)
    .build();

// In ClientModInitializer#onInitializeClient:
CONFIG.load();

ENABLED.set(true);
CONFIG.save();

Supported value types are boolean, ranged integer, ranged decimal, string, and enum.
Config files are stored at config/<mod-id>.json. Invalid or missing fields use their
declared defaults. Saving uses a temporary file and atomic replacement when available.

The API keeps persistence separate from the settings screen, so values can also be
changed through key bindings or other client logic.

Settings screen

Use config.screen("Title") to define categories, toggles, sliders, numeric fields,
and action buttons. build(parent) returns a Screen for a Mod Menu config-screen
factory. The screen stages changes until Save; Cancel leaves the config intact.
The search box searches labels and descriptions across every category.

return CONFIG.screen("Viewer Mod")
    .category("general", "General", menu -> menu
        .toggle("Enabled", "Save received chunks", ENABLED)
        .integerSlider("Radius", "Chunks to capture", RADIUS, 1, 16)
        .integerField("Maximum files", "Archive limit", MAX_FILES))
    .category("tools", "Tools", menu -> menu
        .button("Clear cache", "Deletes the local cache", ViewerCache::clear))
    .build(parent);

常见问题

QoLib 支持哪些 Minecraft 版本?

QoLib 支持 Minecraft Java 版 1.21.11–26.2,共 2 个版本,可用的加载器:Fabric。下载时注意选择和你游戏版本一致的文件。

QoLib 怎么安装?

先用 PCL2 或 HMCL 启动器安装对应版本的 Fabric,再把下载的 .jar 文件放进游戏目录的 mods 文件夹,重新启动游戏即可。开启了版本隔离的,mods 文件夹在 versions/版本名 下面。

评论

登录后评论和评分

Quantum8060 的其他作品

查看全部 →