? Dasik Library
“为 Minecraft 中自主动物遗传、动态 GameRules 及高性能群体行为提供动力的通用蜂巢思维基础。”
? 简介
开发现代 Minecraft Fabric 模组通常意味着要面对反复出现的架构障碍:在不触发不可变注册表锁定(immutable registry lockouts)的情况下动态注册 GameRules;在世界存档周期内同步动物遗传信息和体型属性;在不大幅降低服务器 TPS 的前提下编排集群与群体 AI;以及在无头专用服务器上集成可选的客户端配置 GUI 而不导致致命的 ClassNotFoundException 崩溃。
Dasik Library 是为解决这些挑战而打造的通用独立基础库。它为 Vanilla Outsider、Delayed Gratification 和 Instant Gratification 系列中的所有模组提供了高性能的架构支撑。该库采用严格的零分配热路径设计,支持 Knot ClassLoader 隔离及模块化 API,为开发者和玩家提供了一个企业级的现代 Minecraft 框架。
[!IMPORTANT]
这是一个独立的通用核心库 / API。
- 通用单 JAR 标准: Dasik Library 发布一个通用的跨版本 JAR 文件(
>=26.1.2-),使用纯语义化版本控制(SemVer)。它可以无缝加载于 Minecraft 26.1.2, 26.2, 26.3 及未来的快照版本。
- 同时适用于客户端与专用服务器: 完全兼容单人游戏客户端和多人专用服务器。
- 零独立玩法膨胀: 它本身不会添加任意游戏玩法物品或世界生成内容。它在后台安静运行,为依赖它的模组提供共享的 AI、遗传系统和注册表基础设施。
✨ 功能特性
? 自主动物遗传与繁殖 API
- 持久化实体遗传: 通过持久的 Fabric 附件(
dasik-library:genetics)将实体无关的遗传数据模型附加到生物实体上,在世界存档中保留血统、UUID 和世代特征。
- 三角形突变与异交恢复: 实现自然的生物学繁殖数学逻辑,包括三角形突变分布、亲本性状平均、多级近交衰退惩罚以及遗传异交恢复机制。
- 体型统计构建器与链接属性: 通过
LinkedAttributeRegistry 轻松将实体的物理体型(minecraft:scale,可自定义范围为 0.1f 至 3.0f)链接到次要属性(最大生命值、移动速度、攻击伤害),支持线性、反比或二次方缩放。
- 基于遗传的战利品修改: 使用
GeneticsLootRegistry 和战利品钩子,根据实体体型和遗传活力动态调整掉落物、肉类产量和资源产出。
⚙️ 动态 GameRule 注册与自动翻译引擎
- 按需解冻注册表: 通过
MappedRegistryAccessor 在运行时安全地解冻 BuiltInRegistries.GAME_RULE,允许消费者模组和插件注册自定义 GameRules,而无需启动竞争条件或注册表锁定。
- 自动注入翻译: 动态生成人类可读的翻译键,并直接将其注入 vanilla 的
Language 映射中(dasik$injectDynamicGameRuleTranslations),消除缺失字符串占位符问题(包含 §l 粗体类别格式)。
- 世界存档持久化: 无缝拦截
SavedData 序列化(GameRuleMapMixin),确保通过 /gamerule 命令进行的动态 GameRule 更改能够可靠地持久化到 level.dat 和 game_rules.dat 中。
- 自动化孤立规则清理: 挂钩
ServerLifecycleEvents.SERVER_STARTING 事件,检测并彻底清除因模组卸载而遗留的孤立动态 GameRules,保持世界存档文件的纯净。
- 数学转换辅助工具: 内置用于百分比、千分比和十分比的计算工具(
getPct, getChance, getProb, getDecileFloat)。
? 高性能集群与群体 AI(缓存版 Boids 算法)
- O(N) 领导者-跟随者模式: 通过仅在群组的 Leader 身上计算并缓存组指标(
FlockState),消除了昂贵的 O(N²) 成对距离检查,使得超过 100 个实体的平滑集群能够在稳定的 20 TPS 下运行。
- 生物力学转向: 为逼真的空中群飞(
AerialFlockingStrategy)和陆地群体移动(TerrestrialFlockingStrategy)提供完整的对齐(Alignment)、凝聚(Cohesion)和分离(Separation)向量转向计算。
- 稳健的跟随机制: 集成了绕过水域导航惩罚的机制以及追赶传送阈值,确保群体成员绝不会在区块边界之间迷失。
? 蜂巢思维与解耦信号总线
- 解耦社交信号: 高吞吐量的
SignalBus 使生物能够在不同物种间发送和接收警报、警告及情绪更新,而无需硬编码的类耦合。
- 范围隔离: 提供目标信号投递(
Scope.SAME_SPECIES、Scope.HERD、Scope.GLOBAL)及安全实例检查。
- 懒加载冻结架构: 通过允许模块在模组初始化期间注册社交事件,并在服务器刻时安全锁定注册表,解决了模组初始化竞争条件问题。
?️ 可选 GUI 集成与服务端 ClassLoader 安全
- ClassLoader 隔离的配置屏幕解析器:
GuiHelper 通过反射和 Knot ClassLoader 隔离,动态发现并调用 YetAnotherConfigLib (YACL) 和 Cloth Config。
- 100% 专用服务端崩溃免疫: 完全阻止客户端 GUI 类在服务端加载,消除服务端启动崩溃。
- 标准化创作者支持: 提供
DasikSupportHelper,以便在配置屏幕各分类页面的索引 0 处嵌入标准化的创作者支持按钮。
?️ 企业级稳定性与零分配热路径
- 原子文件持久化:
ConfigHelper 使用临时文件原子交换和自动备份生成功能来管理 JSON 读写操作。
- 零分配渲染: 在高频率刻和渲染路径上实现零堆内存分配的架构。
? 快速参考与机制矩阵
| 功能维度 |
原版 / 标准模组实现 |
Dasik Library |
| GameRule 注册 |
仅限静态构建时注册 |
动态运行时解冻 + 自动翻译注入 |
| 存档文件持久化 |
仅保存静态原版规则 |
在 game_rules.dat 中动态存储 SavedData |
| 孤立规则处理 |
导致存档损坏或永久残留 |
自动启动清理 (pruneOrphanedRules) |
| 群体 AI 复杂度 |
O(N²) 成对实体距离循环 |
O(N) 基于领导者缓存的 FlockState 计算 |
| 动物遗传引擎 |
扁平的原版繁殖继承 |
谱系追踪、突变、规模链接及掉落缩放 |
| 规模属性范围 |
僵化的原版缩放 |
自定义缩放钳位 [0.1f, 3.0f] 及关联属性 |
| 可选配置 GUI |
容易出现服务端 NoClassDefFoundError |
反射与 Knot 隔离 (GuiHelper),零服务端风险 |
? 开发者快速入门与实施指南
将 Dasik Library 集成到你自己的 Fabric 模组中仅需几行代码:
1. Gradle 设置
在 build.gradle 中添加 Modrinth Maven 仓库并声明依赖:
repositories {
maven {
name = "Modrinth"
url = "https://api.modrinth.com/maven"
}
}
dependencies {
modImplementation "maven.modrinth:dasik-library:<latest-version>"
}
2. 注册动态 GameRule
注册一个带有自动英文翻译和类别加粗效果的 GameRule:
import net.dasik.social.api.gamerule.DynamicGameRuleManager;
// 在 'Gameplay' 类别下注册 'my_mod:drop_multiplier',默认值为 2
DynamicGameRuleManager.registerIntegerRule(
"my_mod:drop_multiplier",
2,
"Drop Multiplier",
"Gameplay"
);
3. 绑定动物规模到生命值和速度
将物理体型与战斗和机动性属性关联:
import net.dasik.social.api.genetics.SizeStatsBuilder;
import net.dasik.social.api.genetics.LinkMode;
import net.minecraft.world.entity.ai.attributes.Attributes;
SizeStatsBuilder.create("my_mod:beast_genetics")
.linkAttribute(Attributes.MAX_HEALTH, LinkMode.PROPORTIONAL, 2.0f)
.linkAttribute(Attributes.MOVEMENT_SPEED, LinkMode.INVERSE, 0.5f)
.register();
4. 动态注册表扫描
安全地观察和处理由其他模组添加的新注册表条目:
import net.dasik.social.api.DynamicRegistryScanner;
import net.minecraft.core.registries.BuiltInRegistries;
DynamicRegistryScanner.subscribe(BuiltInRegistries.ITEM, item -> {
// 在启动和热重载期间动态处理新的模组物品
});
⚙️ 核心配置与存档架构
[!IMPORTANT]
? 配置文件与游戏内 GameRules: 全局配置文件仅定义新创建世界的默认值。在现有世界中,请通过 编辑游戏规则 UI 界面或 /gamerule 命令在游戏内更改设置。
Dasik Library 在世界存档文件中原生管理动态 GameRule 状态:
- 世界存储: 存储在
<world_save>/data/game_rules.dat 和 level.dat 中。
- 零残留杂乱: 当你移除注册了动态规则的模组时,Dasik Library 的启动清理引擎会检测缺失的名称空间并注销孤立条目,防止控制台垃圾信息和存档文件膨胀。
? 深入操作指南与集成手册
1. 生存玩家与服务端管理员
- 下载最新的
dasik-library-*.jar 发布版本。
- 将该 JAR 文件直接放入
.minecraft/mods 文件夹,并与 Fabric API 一起放置。
- 启动 Minecraft。Dasik Library 将在后台静默且高效地运行,为已安装的模组提供基础服务。
- 当通过 编辑游戏规则 界面或
/gamerule 在游戏内配置 GameRules 时,所有由 Dasik 支持的模组注册的规则都会自动翻译、按类别组织,并直接保存到世界文件中。
2. 整合包创作者
- 通用多版本支持: 你不需要为微小的 Minecraft 补丁版本准备不同的 Dasik Library 构建版本——一个构建版本即可兼容 MC 26.1.2、26.2 和 26.3+。
- 服务端安全: 可以将 Dasik Library 包含在客户端和服务端整合包中,无需担心客户端 GUI 崩溃。
- 干净的World升级: 在更新整合包并移除过时模组时,该库会在下次服务端启动时自动清除孤立的 GameRules。
3. 针对模组开发者
- 在你的
fabric.mod.json 中声明 dasik-library:
"depends": {
"fabricloader": ">=0.16.10",
"minecraft": ">=26.1.2-",
"fabric-api": "*",
"dasik-library": ">=1.9.0"
}
- 利用
DynamicGameRuleManager 避免编写重复的游戏规则样板代码和翻译文件。
- 使用
GuiHelper 提供可选的 YACL 或 Cloth Config GUI,可通过 ModMenu 无缝打开,同时保持 100% 的服务器安全性。
? 推荐的姐妹模组与衍生项目
Dasik Library 是众多流行模组的引擎。探索这些由该库直接驱动的项目:
- ? Collapsible Game Rules:将编辑游戏规则屏幕现代化为可折叠的分类,并支持实时搜索,利用 Dasik Library 的动态元数据功能。
- ? Better Dogs:全面的犬类行为重构,包含性格智能、群体聚集效应以及车辆骑乘功能,均由 Dasik Library 的 AI flocking(鸟群/兽群)引擎提供支持。
- ? Natural Reproduction:基于 Dasik Animal Genetics 构建的自主 27 种野生动物繁殖与遗传引擎。
? 浏览我的个人资料以查看更多原版增强、性能优化工具和游戏设计重构内容。
? 加入社区与获取支持
需要帮助?想测试早期 Beta 版本?或者对即将推出的功能进行投票?加入我的官方 Discord!
☕ 支持
如果你喜欢这个生态系统,请考虑为未来的更新提供动力!
[!NOTE]
?? 印尼用户: SocioBuzz 和 Saweria 支持本地支付方式(如 Gopay、OVO、Dana 等),如果你希望在不使用 PayPal/Ko-fi 的情况下支持我,可以使用这些平台!
? 致谢与整合包权限
[!IMPORTANT]
? 整合包权限与分发说明:
你完全可以将此模组包含在任何平台的任何整合包中!但是,模组文件必须通过官方分发渠道(Modrinth 或 CurseForge)直接下载。严禁将原始模组 JAR 文件重新上传、镜像或再分发到第三方镜像站点、抓取门户或未授权的启动器上。
⚖️ 许可证与分支指南(禁止无变更的重新上传):
本项目在 GNU GPLv3 下开源。我们鼓励你检查代码、从中学习,并 Fork 仓库以创建真正的修改、大幅的功能扩展或社区移植版 —— 前提是你的项目必须在 GPLv3 下保持开源并提供适当的署名。
然而,严格禁止直接的 1:1 重新上传、无任何实质性功能变化的克隆分支,或以不同项目名称重新发布相同构建版本(例如为了刷取下载量或奖励)。
为 Minecraft 社区 ❤️ 制作
Universal Core Architecture 的一部分
🧠 Dasik Library
"The universal Hive Mind foundation powering autonomous animal genetics, dynamic GameRules, and high-performance flocking across Minecraft."
📖 Introduction
Developing modern Minecraft Fabric mods often means facing recurring architectural roadblocks: registering dynamic GameRules on the fly without causing immutable registry lockouts, synchronizing animal genetics and scale attributes across world save cycles, orchestrating swarming and flocking AI without decimating server tick rates, and integrating optional client configuration GUIs without causing fatal ClassNotFoundException crashes on headless dedicated servers.
Dasik Library is the universal standalone foundation engineered to solve these challenges. It provides the high-performance architectural backbone powering every mod across the Vanilla Outsider, Delayed Gratification, and Instant Gratification collections. Designed with strict zero-allocation hot paths, Knot ClassLoader isolation, and modular APIs, it equips developers and players with an enterprise-grade framework for modern Minecraft.
[!IMPORTANT]
This is a Standalone Universal Core Library / API.
- Universal Single-JAR Standard: Dasik Library ships a single universal cross-version JAR (
>=26.1.2-) using pure SemVer. It seamlessly loads across Minecraft 26.1.2, 26.2, 26.3, and future snapshots.
- Both Client & Dedicated Server Ready: Fully compatible with singleplayer clients and multiplayer dedicated servers.
- Zero Standalone Gameplay Bloat: Does not add arbitrary gameplay items or world generation on its own. It runs quietly in the background, providing shared AI, genetics, and registry infrastructure for dependent mods.
✨ Features
🧬 Autonomous Animal Genetics & Breeding API
- Persistent Entity Genetics: Attaches an entity-agnostic genetic data model to living entities via persistent Fabric attachments (
dasik-library:genetics), preserving lineage, UUIDs, and generational traits across world saves.
- Triangular Mutation & Outcross Recovery: Implements natural biological breeding math, including triangular mutation distribution, parent trait averaging, multi-tier inbreeding penalties, and genetic outcross recovery.
- Size-Stats Builder & Linked Attributes: Easily bind entity physical scale (
minecraft:scale, customizable from 0.1f to 3.0f) to secondary attributes (Max Health, Movement Speed, Attack Damage) via LinkedAttributeRegistry with linear, inverse, or quadratic scaling.
- Genetics-Driven Loot Modification: Uses
GeneticsLootRegistry and loot hooks to dynamically scale drops, meat yields, and resources based on entity size and genetic vitality.
⚙️ Dynamic GameRule Registration & Auto-Translation Engine
- On-Demand Registry Unfreezing: Safely unfreezes
BuiltInRegistries.GAME_RULE at runtime via MappedRegistryAccessor, allowing consumer mods and addons to register custom GameRules without startup race conditions or registry lockouts.
- Automatic Translation Injection: Dynamically generates human-readable translation keys and injects them directly into vanilla's
Language map (dasik$injectDynamicGameRuleTranslations), eliminating missing string placeholders (§l bold category formatting included).
- World Save Persistence: Seamlessly intercepts
SavedData serialization (GameRuleMapMixin), ensuring dynamic GameRule changes made via /gamerule persist reliably in level.dat and game_rules.dat.
- Automated Orphaned Rule Pruning: Hooks
ServerLifecycleEvents.SERVER_STARTING to detect and cleanly purge orphaned dynamic GameRules left behind when mods are uninstalled, keeping world save files pristine.
- Math Conversion Helpers: Built-in calculation utilities for percentages, permilles, and deciles (
getPct, getChance, getProb, getDecileFloat).
🦅 High-Performance Swarm & Flocking AI (Cached Boids)
- O(N) Leader-Follower Pattern: Eliminates expensive O(N²) pairwise distance checks by computing and caching group metrics (
FlockState) exclusively on the pack Leader, enabling smooth swarms of 100+ entities at a solid 20 TPS.
- Biomechanical Steering: Full Alignment, Cohesion, and Separation vector steering calculations for realistic aerial murmurations (
AerialFlockingStrategy) and terrestrial pack movement (TerrestrialFlockingStrategy).
- Resilient Following: Integrated water navigation penalty bypass and catch-up teleportation thresholds to ensure pack members never get lost across chunk boundaries.
📡 The Hive Mind & Decoupled Signal Bus
- Decoupled Social Signals: High-throughput
SignalBus enables mobs to emit and receive alerts, warnings, and mood updates across species without hard-coded class couplings.
- Scope Isolation: Targeted signal delivery (
Scope.SAME_SPECIES, Scope.HERD, Scope.GLOBAL) with safe instance checks.
- Lazy Freeze Architecture: Solves mod initialization race conditions by allowing modules to register social events during mod init while locking the registry safely at server tick.
🖥️ Optional GUI Integration & Server ClassLoader Safety
- Classloader-Isolated Config Screen Resolver:
GuiHelper dynamically discovers and invokes YetAnotherConfigLib (YACL) and Cloth Config via reflection and Knot ClassLoader isolation.
- 100% Dedicated Server Crash Immunity: Completely prevents client GUI classes from loading on dedicated servers, eliminating server startup crashes.
- Standardized Creator Support: Provides
DasikSupportHelper to embed standardized creator support buttons at index 0 across config screen category pages.
🛡️ Enterprise Stability & Zero-Allocation Hot Paths
- Atomic File Persistence:
ConfigHelper manages JSON read/write operations using temporary file atomic swaps and automatic backup generation.
- Zero-Allocation Rendering: Zero-byte heap allocation architecture across high-frequency tick and render paths.
📊 Quick Reference & Mechanics Matrix
| Feature Dimension |
Vanilla / Standard Mod Implementation |
Dasik Library |
| GameRule Registration |
Static build-time registration only |
Dynamic runtime unfreeze + auto-translation injection |
| Save File Persistence |
Only static vanilla rules saved |
Dynamic SavedData storage in game_rules.dat |
| Orphaned Rule Handling |
Corrupts saves or persists forever |
Automated startup pruning (pruneOrphanedRules) |
| Flocking AI Complexity |
O(N²) pairwise entity distance loops |
O(N) Leader-Cached FlockState computation |
| Animal Genetics Engine |
Flat vanilla breed inheritance |
Lineage tracking, mutations, scale linking & loot scaling |
| Scale Attribute Range |
Rigid vanilla scaling |
Custom scaling clamp [0.1f, 3.0f] with linked stats |
| Optional Config GUI |
Prone to server NoClassDefFoundError |
Reflection & Knot isolation (GuiHelper) with 0 server risk |
🚀 Developer Quick Start & Implementation Guide
Integrating Dasik Library into your own Fabric mod takes only a few lines of code:
1. Gradle Setup
Add the Modrinth Maven repository and declare the dependency in your build.gradle:
repositories {
maven {
name = "Modrinth"
url = "https://api.modrinth.com/maven"
}
}
dependencies {
modImplementation "maven.modrinth:dasik-library:<latest-version>"
}
2. Registering a Dynamic GameRule
Register a GameRule with automatic English translation and category bolding:
import net.dasik.social.api.gamerule.DynamicGameRuleManager;
// Registers 'my_mod:drop_multiplier' with a default value of 2 under the 'Gameplay' category
DynamicGameRuleManager.registerIntegerRule(
"my_mod:drop_multiplier",
2,
"Drop Multiplier",
"Gameplay"
);
3. Binding Animal Scale to Health and Speed
Link physical size to combat and mobility attributes:
import net.dasik.social.api.genetics.SizeStatsBuilder;
import net.dasik.social.api.genetics.LinkMode;
import net.minecraft.world.entity.ai.attributes.Attributes;
SizeStatsBuilder.create("my_mod:beast_genetics")
.linkAttribute(Attributes.MAX_HEALTH, LinkMode.PROPORTIONAL, 2.0f)
.linkAttribute(Attributes.MOVEMENT_SPEED, LinkMode.INVERSE, 0.5f)
.register();
4. Dynamic Registry Scanning
Safely observe and handle new registry entries added by other mods:
import net.dasik.social.api.DynamicRegistryScanner;
import net.minecraft.core.registries.BuiltInRegistries;
DynamicRegistryScanner.subscribe(BuiltInRegistries.ITEM, item -> {
// Process new modded items dynamically on startup and live reload
});
⚙️ Core Configuration & Save Architecture
[!IMPORTANT]
💡 Config vs. In-Game GameRules: The global configuration file only defines default values for newly created worlds. In existing worlds, change settings in-game via the Edit Game Rules UI screen or the /gamerule command.
Dasik Library manages dynamic GameRule states natively within your world save files:
- World Storage: Stored in
<world_save>/data/game_rules.dat and level.dat.
- Zero Residual Clutter: When you remove a mod that registered dynamic rules, Dasik Library's startup pruning engine detects the absent namespace and unregisters orphaned entries, preventing console spam and bloated save files.
📖 In-Depth How-To & Integration Playbook
1. For Survival Players & Server Administrators
- Download the latest
dasik-library-*.jar release.
- Place the JAR directly into your
.minecraft/mods folder along with Fabric API.
- Launch Minecraft. Dasik Library operates silently and efficiently in the background, providing foundational services for your installed mods.
- When configuring GameRules in-game via the Edit Game Rules screen or
/gamerule, all rules registered by Dasik-powered mods are automatically translated, organized into categories, and saved directly to the world file.
2. For Modpack Creators
- Universal Multi-Version Support: You do not need separate builds of Dasik Library for minor Minecraft patches — one build handles MC 26.1.2, 26.2, and 26.3+.
- Server-Safe: Include Dasik Library in both client and server modpacks without fear of client GUI crashes.
- Clean World Upgrades: When updating modpacks and removing deprecated mods, the library automatically purges orphaned GameRules on the next server launch.
3. For Mod Developers
- Declare
dasik-library in your fabric.mod.json:
"depends": {
"fabricloader": ">=0.16.10",
"minecraft": ">=26.1.2-",
"fabric-api": "*",
"dasik-library": ">=1.9.0"
}
- Leverage
DynamicGameRuleManager to avoid writing repetitive GameRule boilerplate and translation files.
- Use
GuiHelper to supply optional YACL or Cloth Config GUIs that open seamlessly via ModMenu while preserving 100% server safety.
🧩 Recommended Sister Mods & Powered Projects
Dasik Library serves as the engine for numerous popular mods. Explore these projects powered directly by the library:
- 📜 Collapsible Game Rules: Modernizes the Edit Game Rules screen into collapsible categories with real-time search, leveraging Dasik Library's dynamic metadata.
- 🐕 Better Dogs: Complete canine behavioral overhaul featuring personality intelligence, pack murmuration, and vehicle riding powered by Dasik Library's AI flocking engine.
- 🌿 Natural Reproduction: Autonomous 27-species wildlife breeding and genetics engine built directly on Dasik Animal Genetics.
🌟 Explore my profile for more vanilla enhancements, performance utilities, and game design overhauls.
💬 Join the Community & Get Support
Looking for help, want to test early beta builds, or vote on upcoming features? Join my official Discord!
☕ Support
If you enjoy the ecosystem, consider fueling future updates!
[!NOTE]
🇮🇩 Indonesian Users: SocioBuzz and Saweria support local payment methods (Gopay, OVO, Dana, etc.) if you want to support me without using PayPal/Ko-fi!
📜 Credits & Modpack Permissions
[!IMPORTANT]
📦 Modpack Permissions & Distribution:
You are fully welcome to include this mod in any modpack on any platform! However, the mod file must be downloaded directly through official distribution channels (Modrinth or CurseForge). Re-uploading, mirroring, or redistributing the original mod JAR to third-party mirror sites, scraper portals, or unauthorized launchers is strictly prohibited.
⚖️ License & Fork Guidelines (No Zero-Change Re-uploads):
This project is open-source under the GNU GPLv3. You are fully encouraged to inspect the code, learn from it, and fork the repository to create genuine modifications, substantial feature expansions, or community ports — provided your project remains open-source under GPLv3 with proper attribution.
However, straight 1:1 re-uploads, clone forks with no meaningful functional changes, or re-publishing identical builds under different project names (e.g. to farm downloads or rewards) are strictly forbidden.
Made with ❤️ for the Minecraft community
Part of the Universal Core Architecture
评论 0
登录后参与评分
还没有评论,来抢沙发吧