Skip to content

🔌 API 与附加模组集成指南

Agrarian Reform 深度整合了 DasikLibrary,并为第三方模组开发者与数据包创作者提供了开放的拓展接口。


📚 DasikLibrary API 前置依赖

Agrarian Reform 依赖 DasikLibrary (>=1.8.3) 构建底层核心架构:

DasikLibrary API 模块在 Agrarian Reform 中的应用用途
DynamicGameRuleManagerAgrarianGameRules.java, AgrarianCropRules.java干净注册带命名空间的动态游戏规则,具备 GSON 同步与世界实时持久化功能。
ConfigHelperAgrarianConfig.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 注入参考.

Official documentation & web portal for Dasik Igaijinn mods.