
AvalonBase
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.
🏰 AvalonBase
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
✨ 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
- 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
- Themed buttons, radio selectors, toggle switches
- Panel, card, scrollbar and icon rendering
- Hover easing animations and state‑aware colour palettes
2. Base Configuration Screen
- 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
3. TOML Configuration Framework
- 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 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
5. Platform Service Utilities
- Query current runtime loader
- Check whether another mod is loaded
- Distinguish development environment from production
🧩 Project Structure
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
Transitive Dependency Note
- Forge ships night‑config by default, no extra packaging required.
- Fabric requires night‑config to be included within your mod jar.
🚀 Quick Start Example
// 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
🏰 AvalonBase
一款 Forge + Fabric 双端通用 Minecraft 前置支持库,提供主题 GUI、可视化配置、TOML 热加载、跨平台网络、平台工具通用能力,让模组开发无需重复造轮子。
📌 项目简介
✨ 为什么使用 AvalonBase
- 零重复造轮子:内置成熟 GUI 控件、主题系统、TOML 配置、网络通信、平台判断工具
- 双端统一 API:业务层完全无关平台,无需分别适配 Forge、Fabric
- 模组极致精简:通用底层全部前置托管,你的模组只需要写核心业务
- 统一交互体验:所有依赖该前置的模组,拥有一致风格的配置界面与交互逻辑
🎯 可开发的模组类型
- 带可视化配置 GUI的工具模组
- 权限、指令管理类服务端模组
- 需要客户端↔服务端数据同步的功能模组
- 需要双端行为一致的跨平台模组
📚 核心能力一览
1. 主题 GUI 系统
- 主题按钮、单选框、滑动开关
- 面板、卡片、滚动条、图标渲染
- hover 缓动动画、状态配色体系
2. 通用配置屏幕基类
- 一键添加「保存 / 取消」按钮
- 自动权限判断、只读模式适配
- 滚动列表、光标切换、点击音效、底部状态提示
- 统一布局体系
3. TOML 配置框架
- 自动创建默认配置文件
- 支持读写、子列表操作、注释保留
- 文件外部修改检测、配置热加载
- 统一的配置写入与解析规范
4. 跨平台网络框架
- 统一消息注册、编码、解码、处理机制
- 客户端发包、服务端全员发包、指定玩家发包
- 跨平台线程调度封装
5. 平台工具服务
- 获取当前运行平台
- 判断模组是否已加载
- 区分开发 / 生产环境
🧩 模块结构
AvalonBase/
├── common/ 平台无关核心能力(GUI / 配置 / 网络 / 工具)
├── fabric/ Fabric 端适配与入口
├── forge/ Forge 端适配与入口
└── buildSrc/ 统一构建规范
📦 依赖引入方式
1. Jar 本地依赖
- Common 编译期:
compileOnly引入前置开发包 - 对应平台模块:
modImplementation引入运行包 - 模组配置文件声明强制前置依赖
2. Maven 远程依赖
额外依赖说明
- Forge 环境自带,无需额外打包
- Fabric 环境需随模组打包引入
🚀 快速开发示例
// 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
正在加载版本记录…
正在加载评论…
评论在新手盒子客户端中发表,这里同步展示。