AStudioLib
由 AttackStudio 构建的轻量级通用 Fabric 模组库。AStudioLib 处理了每个模组都需要的基础代码——配置持久化、GUI 渲染、音效辅助、物品栏查询、任务调度器、按键绑定注册等,让你无需重复编写。
对于玩家: 将 JAR 文件放入 mods 文件夹中,与任何需要它的模组放在一起。AStudioLib 本身不会产生可见效果。
包含内容
配置 (Config)
基于 Gson 的 JSON 配置持久化支持。一行代码即可保存和加载,自动定位文件位置、美化输出并静默处理错误。
GUI 渲染
一套完整的 DrawContext 辅助函数,用于实现 AttackStudio 暗色主题 UI:面板背景、脉冲边框、角标、动画流光扫光、进度条、提示框、滚动条以及可滚动区域的淡入淡出边缘。
缓动函数 (Easing)
帧率无关的缓动函数:ease-out、ease-out-back、ease-in-out、正弦脉冲、ease-out bounce(缓出弹跳)和线性插值 (linear lerp)。所有输入均会自动钳位。
颜色工具 (Color Utilities)
ARGB 颜色打包、Alpha 混合、双色线性插值、healthColor 渐变(红 → 黄 → 绿)、HSV 转 RGB 转换以及动画彩虹色辅助函数。
数学工具 (Math Utilities)
clamp(钳位)、remap(重映射)、approach(逼近)、smoothLerp(平滑插值)、wrap(环绕)和 nearlyEqual(近似相等)——弥补 Java 缺失的数字辅助功能。
文本辅助 (Text Helpers)
Minecraft Text 构建器:十六进制颜色文本、切换标签("Feature: ON/OFF")、带分隔符的连接以及原生 Formatting 应用。
任务调度器 (Tick Scheduler)
客户端延迟和重复任务调度器。在 N 个刻后安排一次性操作,或每隔 N 个刻进行重复脉冲——无需后台线程,无需样板代码。
物品栏工具 (Inventory Utilities)
完整物品栏查询,包括副手:物品数量统计、存在性检查、首个槽位搜索和手持物品检测。
音效工具 (Sound Utilities)
一行代码播放音效——固定音量/音调、自定义音调,或在范围内随机化音调。
Toast 通知
一行代码发送 Minecraft 系统 Toast 通知(右上角),可选择是否包含正文消息。
按键绑定注册
对 Fabric 按键绑定 API 的轻量封装。一行代码注册按键,使用 isHeld() 轮询按住状态或 consumePress() 消费按下事件。每帧客户端自动更新。
/studiolib 命令
共享的客户端命令注册表。任何模组都可以在初始化期间向 /studiolib 下注册子命令——AStudioLib 会自动组装完整的命令树。
供模组开发者使用
1. 发布到本地 Maven:
git clone https://github.com/AttackStudios/AStudioLib.git
cd AStudioLib
./gradlew publishToMavenLocal
2. 添加到 build.gradle:
repositories { mavenLocal() }
dependencies {
modImplementation "net.attackstudioyt:astudiolib:1.1.0"
}
3. 在 fabric.mod.json 中声明依赖:
"depends": { "astudiolib": "*" }
环境要求
|
|
| Minecraft |
1.21.11 或更高版本 |
| Fabric Loader |
≥ 0.18.4 |
| Fabric API |
0.141.3+1.21.11 |
| Java |
21 |
AStudioLib
A lightweight, general-purpose Fabric mod library built by AttackStudio. AStudioLib handles all the boilerplate that every mod needs — config persistence, GUI rendering, sound helpers, inventory queries, a tick scheduler, keybinding registration, and more — so it never has to be written twice.
For players: Drop the JAR in your mods folder alongside any mod that requires it. AStudioLib has no visible effect on its own.
What's Included
Config
JSON config persistence backed by Gson. One-line save and load, automatic file location, pretty-printing, and silent error handling.
GUI Rendering
A full set of DrawContext helpers for the AttackStudio dark-theme UI: panel backgrounds, pulsing borders, corner brackets, animated shimmer sweeps, progress bars, tooltip boxes, scrollbars, and fade edges for scrollable regions.
Easing
Frame-rate-independent easing functions: ease-out, ease-out-back, ease-in-out, sine pulse, ease-out bounce, and linear lerp. All inputs are clamped automatically.
Color Utilities
ARGB color packing, alpha blending, two-color lerp, a healthColor gradient (red → yellow → green), HSV-to-RGB conversion, and an animated rainbow helper.
Math Utilities
clamp, remap, approach, smoothLerp, wrap, and nearlyEqual — the numeric helpers that Java forgot to include.
Text Helpers
Minecraft Text builders: hex-colored text, toggle labels ("Feature: ON/OFF"), join-with-separator, and vanilla Formatting application.
Tick Scheduler
Client-side deferred and repeating task scheduler. Schedule a one-shot action after N ticks or a repeating pulse every N ticks — no background threads, no boilerplate.
Inventory Utilities
Full-inventory queries including offhand: item count, presence checks, first-slot search, and held-item detection.
Sound Utilities
One-liner sound playback — fixed volume/pitch, custom pitch, or randomized pitch within a range.
Toast Notifications
One-liner Minecraft system toast notifications (top-right corner), with or without a body message.
Keybinding Registration
Thin wrapper around Fabric's keybinding API. Register a key in one line, poll with isHeld() or consumePress(). Auto-ticked each client frame.
/studiolib Command
A shared client command registry. Any mod can register subcommands under /studiolib during init — AStudioLib assembles the full tree automatically.
For Mod Developers
1. Publish to Maven local:
git clone https://github.com/AttackStudios/AStudioLib.git
cd AStudioLib
./gradlew publishToMavenLocal
2. Add to build.gradle:
repositories { mavenLocal() }
dependencies {
modImplementation "net.attackstudioyt:astudiolib:1.1.0"
}
3. Declare in fabric.mod.json:
"depends": { "astudiolib": "*" }
Requirements
|
|
| Minecraft |
1.21.11 or higher |
| Fabric Loader |
≥ 0.18.4 |
| Fabric API |
0.141.3+1.21.11 |
| Java |
21 |
评论 0
登录后参与评分
还没有评论,来抢沙发吧