🏰 AvalonBase
Author: Huziyang520
A cross‑platform Minecraft prerequisite library for Forge & Fabric. Provides themed GUI, configurable screens, TOML hot‑reloading, cross‑platform networking and platform utilities. Avoid reinventing the wheel for your mods.
📌 About The Project
AvalonBase is a cross‑platform prerequisite support library. It contains zero business‑specific logic, only general‑purpose low‑level utilities.
Mods built against AvalonBase can share one single Common codebase that runs on both Forge and Fabric. It eliminates redundant code, inconsistent GUI implementations and duplicated configuration logic across mod loaders.
It can be used as a required dependency for any functional mod, designed to be lightweight, decoupled and ready‑to‑use.
✨ Why AvalonBase
- No reinventing the wheel: Pre‑built themed GUI widgets, configuration system, networking and platform helper utilities.
- Unified cross‑loader API: Your business code stays loader‑agnostic, no separate implementations for Forge and Fabric.
- Keep your mod lean: All generic low‑level logic lives inside this library; your mod only contains feature‑specific code.
- Consistent UX: All mods depending on AvalonBase share uniform styling and interaction patterns for configuration screens.
🎯 Suitable Mod Types
You can rapidly develop mods with these features:
- Utility mods with visual configuration GUI
- Permission / command management server‑side mods
- Mods requiring client ↔ server data synchronization
- Cross‑platform mods that need identical behaviour on both loaders
📚 Core Features
1. Themed GUI System
Pure code‑based rendering, no texture assets required. Two complete built‑in styles: Vanilla‑style theme and Ender‑purple modern theme.
Unified widgets out‑of‑the‑box:
- Themed buttons, radio selectors, toggle switches
- Panel, card, scrollbar and icon rendering
- Hover easing animations and state‑aware colour palettes
All widgets respect the active theme, giving you polished UI with minimal boilerplate.
2. Base Configuration Screen
Full infrastructure for building config GUIs:
- One‑line helper to add Save / Cancel buttons
- Automatic permission checking and read‑only mode support
- Scrollable item lists, cursor state switching, click sounds, status hint bar
- Consistent layout helpers
Subclasses only need to implement the save logic to get a fully‑working configuration screen.
3. TOML Configuration Framework
Robust config wrapper built upon night‑config:
- Auto‑generate default config files when missing
- Read‑write support, sub‑list operations, comment preservation
- External file change detection with config hot‑reloading
- Standardized parsing and serialization behaviour
4. Cross‑Platform Networking
Unified abstraction over Forge and Fabric networking APIs:
- Unified message registration, encoding, decoding and handler interface
- Send packets to server, broadcast to all players, send to single target player
- Cross‑platform thread scheduling abstraction
Your Common‑side code never needs loader‑specific branches.
5. Platform Service Utilities
Unified platform helper API:
- Query current runtime loader
- Check whether another mod is loaded
- Distinguish development environment from production
All loader‑specific implementation is encapsulated inside AvalonBase, invisible to consuming mods.
🧩 Project Structure
plaintext
AvalonBase/
├── common/ Loader‑agnostic core (GUI / config / network / utilities)
├── fabric/ Fabric entrypoint & loader implementation
├── forge/ Forge entrypoint & loader implementation
└── buildSrc/ Shared build conventions
📦 Adding As Dependency
1. Local Jar Dependency
- Common source set: add dev jar with
compileOnlyfor compile‑time access - Platform‑specific module: use
modImplementationfor runtime jar - Mark AvalonBase as a mandatory required dependency in your mod metadata
2. Maven Repository Dependency
Publish artifacts to your private Maven repository and reference via standard maven coordinates for multi‑mod projects.
Transitive Dependency Note
TOML functionality depends on night‑config:
- Forge ships night‑config by default, no extra packaging required.
- Fabric requires night‑config to be included within your mod jar.
🚀 Quick Start Example
java
运行
// 1. Initialize TOML config
AvalonToml toml = new AvalonToml("mymod", Path.of("config", "mymod.toml"));
toml.ensureExists(Config.inMemory());
// 2. Custom config screen extending base screen
public class ModConfigScreen extends AvalonConfigScreen {
public ModConfigScreen() {
super(Component.translatable("gui.mymod.title"));
setTheme(MODERN_THEME);
addSaveCancelButtons();
}
@Override
protected void saveConfig() {
// Implement your own save business logic
}
}
// 3. Register cross‑network packet
AvalonNetwork.registerMessage(channel, clazz, encode, decode, handler);
// 4. Check runtime environment
if (Services.PLATFORM.isDevelopmentEnvironment()) {
// Development‑only logic
}
📄 License
MIT License
🏰 AvalonBase
作者:Huziyang520
一款 Forge + Fabric 双端通用 Minecraft 前置支持库,提供主题 GUI、可视化配置、TOML 热加载、跨平台网络、平台工具通用能力,让模组开发无需重复造轮子。
📌 项目简介
AvalonBase 是跨平台通用前置核心支持库,完全剥离业务逻辑,只提供与业务无关的公共底层能力。
所有基于本库开发的模组,均可一套 Common 业务代码,双端同时运行,彻底解决 Forge / Fabric 重复开发、代码冗余、GUI 零散、配置不统一的问题。
本库可作为任意功能模组的必需前置依赖,轻量化、高解耦、开箱即用。
✨ 为什么使用 AvalonBase
- 零重复造轮子:内置成熟 GUI 控件、主题系统、TOML 配置、网络通信、平台判断工具
- 双端统一 API:业务层完全无关平台,无需分别适配 Forge、Fabric
- 模组极致精简:通用底层全部前置托管,你的模组只需要写核心业务
- 统一交互体验:所有依赖该前置的模组,拥有一致风格的配置界面与交互逻辑
🎯 可开发的模组类型
依托 AvalonBase 五大核心能力,可快速开发:
- 带可视化配置 GUI的工具模组
- 权限、指令管理类服务端模组
- 需要客户端↔服务端数据同步的功能模组
- 需要双端行为一致的跨平台模组
📚 核心能力一览
1. 主题 GUI 系统
纯代码渲染、无贴图依赖,内置两套完整视觉风格:原版箱式主题 / 末影紫现代主题。
统一封装常用控件:
- 主题按钮、单选框、滑动开关
- 面板、卡片、滚动条、图标渲染
- hover 缓动动画、状态配色体系
所有控件自带主题适配,一行代码即可拥有统一美化界面。
2. 通用配置屏幕基类
封装整套配置页面基础设施:
- 一键添加「保存 / 取消」按钮
- 自动权限判断、只读模式适配
- 滚动列表、光标切换、点击音效、底部状态提示
- 统一布局体系
子类仅需实现保存逻辑,即可生成完整可用的配置界面。
3. TOML 配置框架
基于成熟 night-config 封装的高可用配置工具:
- 自动创建默认配置文件
- 支持读写、子列表操作、注释保留
- 文件外部修改检测、配置热加载
- 统一的配置写入与解析规范
4. 跨平台网络框架
统一 Forge 与 Fabric 网络接口:
- 统一消息注册、编码、解码、处理机制
- 客户端发包、服务端全员发包、指定玩家发包
- 跨平台线程调度封装
业务层完全不需要判断平台,一套网络代码双端通用。
5. 平台工具服务
内置统一平台工具 API:
- 获取当前运行平台
- 判断模组是否已加载
- 区分开发 / 生产环境
平台差异全部由前置内部实现,业务层零感知。
🧩 模块结构
plaintext
AvalonBase/
├── common/ 平台无关核心能力(GUI / 配置 / 网络 / 工具)
├── fabric/ Fabric 端适配与入口
├── forge/ Forge 端适配与入口
└── buildSrc/ 统一构建规范
📦 依赖引入方式
1. Jar 本地依赖
- Common 编译期:
compileOnly引入前置开发包 - 对应平台模块:
modImplementation引入运行包 - 模组配置文件声明强制前置依赖
2. Maven 远程依赖
可发布至私有 Maven,通过标准坐标统一引入,适配多模组项目。
额外依赖说明
本库 TOML 功能依赖 night-config:
- Forge 环境自带,无需额外打包
- Fabric 环境需随模组打包引入
🚀 快速开发示例
java
运行
// 1. 初始化 TOML 配置
AvalonToml toml = new AvalonToml("mymod", Path.of("config", "mymod.toml"));
toml.ensureExists(Config.inMemory());
// 2. 自定义配置界面(继承通用屏幕)
public class ModConfigScreen extends AvalonConfigScreen {
public ModConfigScreen() {
super(Component.translatable("gui.mymod.title"));
setTheme(MODERN_THEME);
addSaveCancelButtons();
}
@Override
protected void saveConfig() {
// 自定义业务保存逻辑
}
}
// 3. 注册跨平台网络包
AvalonNetwork.registerMessage(channel, clazz, encode, decode, handler);
// 4. 平台环境判断
if (Services.PLATFORM.isDevelopmentEnvironment()) {
// 开发环境专属逻辑
}
📄 License
MIT License

