🔌 API 與附加模組整合指南
Agrarian Reform 深度整合了 DasikLibrary,並為第三方模組開發者與資料包創作者提供了開放的拓展介面。
📚 DasikLibrary API 前置相依
Agrarian Reform 依賴 DasikLibrary (>=1.8.3) 構建底層核心架構:
| DasikLibrary API 模組 | 在 Agrarian Reform 中的應用 | 用途 |
|---|---|---|
DynamicGameRuleManager | AgrarianGameRules.java, AgrarianCropRules.java | 乾淨註冊帶命名空間的動態遊戲規則,具備 GSON 同步與世界即時持久化功能。 |
ConfigHelper | AgrarianConfig.java | 載入並儲存帶架構遷移的版本化 JSON 全域設定範本。 |
🌾 AgrarianCropRules 門面方法
第三方模組可以透過程式設計方式直接查詢 Agrarian Reform 的作物快取與生長數學演算法:
java
// Check if a block is recognized as an agricultural crop
boolean isCrop = AgrarianCropRules.isCropBlock(myBlock);
// Query effective growth speed multiplier (respects frozen -1, positive override, global fallback)
int effectiveMultiplier = AgrarianCropRules.getEffectiveGrowthMultiplier(level, myBlock);
// Check if a block state is at its maximum harvestable age
boolean maxAge = AgrarianCropRules.isMaxAge(blockState);🏷️ 自訂資料包標籤整合
1. 軟步護足標籤 (#agrarian_reform:soft_step_boots)
新增自訂護甲或靴子,保護耕地免受踩踏破壞:
data/agrarian_reform/tags/item/soft_step_boots.json:
json
{
"replace": false,
"values": [
"mymod:padded_leather_boots",
"mymod:farmer_shoes"
]
}2. 時空連續體植物標籤 (#agrarian_reform:continuum_plants 與 #c:crops)
顯式將自訂植物註冊至「時空連續體」離線生長模擬系統:
data/agrarian_reform/tags/block/continuum_plants.json:
json
{
"replace": false,
"values": [
"mymod:custom_corn_crop",
"mymod:custom_tomato_bush"
]
}See also: 作物註冊表與通用作物 and 架構設計與 Mixin 注入參考.
