> For the complete documentation index, see [llms.txt](https://momi.gtemc.cn/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://momi.gtemc.cn/customcrops/cha-jian-wiki/customcrops/ge-shi/zuo-wu.md).

# 🌽 作物

让我们以 `tomato` 为例来配置作物的设置

**你的作物的唯一标识符**：\
首先，给你的作物命名一个唯一标识符，例如 `tomato`。这使得以后引用和自定义变得容易。

**自定义作物类型**：\
将 `type` 设置为 `BLOCK` 或 `FURNITURE`。对于 "tomato"，它被设置为 `BLOCK`。此设置影响整个配置中出现的所有自定义物品类型。但你也可以通过一些额外的配置单独设置物品的类型。

```yaml
# 物品类型
# BLOCK / FURNITURE
type: BLOCK
```

**设置种植限制**：\
使用 `pot-whitelist` 指定允许种植的花盆。"tomato" 作物只能种植在默认花盆中。如果你修改了花盆的配置，请务必同时修改此配置。

```yaml
# 作物只能种植在白名单中的花盆上
pot-whitelist:
  - default
```

**控制作物刻模式**

```yaml
# 有时您可能配置了多个作物，并希望为各个种植盆设置不同的刻模式。
# 你可以在 config.yml 中将刻模式改为 ALL，然后在此处分别进行配置。
ignore-random-tick: false
ignore-scheduled-tick: true
```

**配置种子信息**：\
`seed` 字段标识用于种植作物的物品。这里，`tomato_seeds` 是番茄作物的种子。

```yaml
# 作物的种子
seed: tomato_seeds
```

**管理旋转（仅适用于 FURNITURE 模式）**：\
`random-rotation` 控制作物种植时是否随机旋转。这仅在 `type` 为 `FURNITURE` 时适用。

```yaml
# 仅在 FURNITURE 模式下有效
random-rotation: true
```

**设置基本要求**：\
在 `requirements` 下自定义此作物的条件。例如，"tomato" 只能在春季或秋季种植，如果不满足这些条件，将显示一个动作栏消息。

```yaml
# 破坏/种植/互动要求
requirements:
  interact: {}
  break: {}
  plant:
    requirement_1:
      type: season
      value:
        - Spring
        - Autumn
      not-met-actions:
        message_action:
          type: message
          value: '<red><bold>[X] 现在不是种植番茄的好季节'
```

**配置事件设置**：\
在 `events` 下自定义作物事件，如种植或破坏。例如，当种植 "tomato" 时，会播放一个声音（`minecraft:item.hoe.till`），并出现手部挥动动画。作物的可用事件：`reach_limit`/`plant`/`break`/`interact`/`death`

```yaml
events:
  break: {}
  interact: {}
  death: {}
  reach_limit:
    actionbar_action:
      type: actionbar
      value: '<red><bold>[X] 你不能种植更多的作物'
  plant:
    # 挥动主手
    swing_hand_action:
      type: swing-hand
      value: true
    # 种植时发送声音
    sound_action:
      type: sound
      value:
        source: player
        key: minecraft:item.hoe.till
        volume: 1
        pitch: 1
```

**自定义生长阶段和模型**：\
使用 `points` 部分来概述作物的生长阶段。对于每个阶段，指定一个模型（外观）和发生的动作，如种子掉落或全息图调整。

作物的可用事件：`grow`/`break`/`interact`

```yaml
# 这决定了作物的最大生长阶段
max-points: 6
```

```yaml
# 作物每个生长阶段的动作和设置
points:
  0:
    # 代表作物在此生长阶段的模型
    model: tomato_stage_1
    # 调整全息图位置以匹配作物模型的高度
    hologram-offset-correction: 0.2
    # 如果此阶段的类型与上面设置的全局类型不同，请设置类型
    type: BLOCK
    # 此阶段的破坏/互动要求
    requirements:
      break: 
        ...
      interact:
        ...
    # 作物在此阶段被破坏时触发的事件
    events:
      grow: {}
      interact: {}
      break:
        # 破坏时有30%的几率掉落番茄种子
        action_1:
          type: drop-item
          value:
            ignore-fertilizer: true
            item: tomato_seeds
            min: 1
            max: 1
          chance: 0.3
```

**自定义生长和死亡条件**：\
使用 `grow-conditions` 设置作物生长的条件，如季节或水位。同样，`death-conditions` 决定作物在何时死亡，如乌鸦攻击或不适合的季节。

```yaml
# 作物可以生长的条件
grow-conditions:
  default:
    point: 1
    conditions:
      season_condition:
        type: suitable_season
        value:
          - Spring
          - Autumn
      water_condition:
        type: water_more_than
        value: 0
```

```yaml
# 可能导致作物死亡的条件
death-conditions:
  no_water:
    # 由于缺水触发的死亡阶段的自定义模型
    model: crop_stage_death
    conditions:
      '&&':
        condition_1:
          type: water_less_than
          value: 1
        condition_2:
          type: random
          value: 0.7
  unsuitable_season:
    # 作物在不适合的季节死亡
    model: crop_stage_death
    conditions:
      condition_1:
        type: unsuitable_season
        value:
          - Winter
  crow_attack:
    # 由于乌鸦攻击导致的作物移除
    conditions:
      condition_1:
        type: crow_attack
        value:
          chance: 0.005
          fly-model: crow_fly
          stand-model: crow_stand
    # 乌鸦攻击后作物被移除的延迟
    delay: 150
```

**自定义自定义骨粉效果**：\
在 `custom-bone-meal` 下配置使用骨粉触发的特殊效果和动作，如粒子、声音或生长几率。

```yaml
# 使用骨粉的自定义设置
custom-bone-meal:
  bone_meal_1:
    item: BONE_MEAL
    # 允许通过发射器使用
    dispenser: true
    chance:
      2: 0.2
      1: 0.6
    actions:
      swing_action:
        type: swing-hand
        value: true
      particle_action:
        type: particle
        value:
          particle: VILLAGER_HAPPY
          x: 0.5
          y: 0.5
          z: 0.5
          count: 5
          offset-x: 0.3
          offset-y: 0.3
          offset-z: 0.3
      sound_action:
        type: sound
        value:
          source: player
          key: minecraft:item.bone_meal.use
          volume: 1
          pitch: 1
```
