模组相容性与跨模组集成 (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);
}