模组兼容性与跨模组集成 (MC 26.2)
本文档详细说明 Minecraft 26.2 下 Item Clumps 的第三方模组集成、动态反射安全机制、Stack Size Adjuster 动态协同及农场兼容性。
📊 特性信息框
| 集成模组 | 类型 | 兼容状态 | 处理机制 |
|---|---|---|---|
| Magnet ("Let me get that!") | 可选模组 | 🟢 100% 无缝协同 | 动态反射检测 (ig_magnet$isMagnetized / ig$isMagnetized) |
| Stack Size Adjuster | 可选模组 | 🟢 动态上限协同 | 将 max_clump_size 注册让渡给 getMaxStackSize() |
| YetAnotherConfigLib (YACL v3) | 可选 GUI | 🟢 完美支持 | 通过 GuiHelper.getOptionalYaclFactory 延迟类加载 |
| ModMenu | 可选 GUI | 🟢 完美支持 | 标准 ModMenu 入口点集成 |
| 原版自动化 / 红石系统 | 核心机制 | 🟢 100% 完全对齐 | 单物品漏斗滴灌抽取与最年轻年龄继承 |
🧲 1. 磁铁模组飞行状态保护
当使用物品真空或磁铁模组(例如 Magnet: Let me get that!)时,地面上的物品会被吸附进入朝向玩家的 3D 飞行抛物线轨道。
┌───────────────────────────────────────────────────────────┐
│ Item In-Flight Magnet Trajectory │
│ │
│ [Item A (In-Flight)] --------> [Player] │
│ │ │
│ (Passes close to Item B on ground) │
│ │ │
│ ❌ WITHOUT MAGNET CHECK: │
│ Item A merges with B; flight velocity resets; │
│ Item snaps to ground. │
│ │
│ ✅ WITH ITEM CLUMPS MAGNET CHECK: │
│ Merge paused while in-flight; │
│ Smooth curve preserved straight to player! │
└───────────────────────────────────────────────────────────┘Item Clumps 通过反射查询磁铁吸附状态,无需硬编码的编译期依赖:
java
if (net.fabricmc.loader.api.FabricLoader.getInstance().isModLoaded("magnet")) {
try {
java.lang.reflect.Method isMagnetizedMethod;
try {
isMagnetizedMethod = this.getClass().getMethod("ig_magnet$isMagnetized");
} catch (NoSuchMethodException e) {
isMagnetizedMethod = this.getClass().getMethod("ig$isMagnetized");
}
if ((boolean) isMagnetizedMethod.invoke(this) || (boolean) isMagnetizedMethod.invoke(other)) {
ci.cancel();
return;
}
} catch (Throwable ignored) {}
}📦 2. Stack Size Adjuster 动态上限同步
当 Stack Size Adjuster 与 Item Clumps 一起安装时:
- 游戏规则自动去重:Item Clumps 会自动取消
item_clumps:max_clump_size规则及其 YACL 配置组件的注册。 - 统一上限协同:地面聚合上限自动查询
itemStack.getMaxStackSize(),由 Stack Size Adjuster 全局或按物品统一掌管地面堆叠上限。
java
int maxClump;
if (net.fabricmc.loader.api.FabricLoader.getInstance().isModLoaded("stack-size-adjuster") ||
ItemClumpsFabric.MAX_CLUMP_SIZE == null) {
maxClump = thisStack.getMaxStackSize();
} else {
maxClump = DynamicGameRuleManager.getInt(this.level(), ItemClumpsFabric.MAX_CLUMP_SIZE);
}