跳到主要内容

🗃️ 战利品源

简介

Minecraft 原版战利品系统无法直接使用占位符检查、权限控制等插件功能,而且通过数据包覆盖默认战利品表也较为繁琐。

战利品源用于将🎲 战利品表绑定到原版战利品事件,例如破坏方块、击杀实体、钓鱼或开启宝库。事件触发时,CraftEngine 会检查所有类型和目标匹配的战利品源,并把生成结果应用到该事件。

所有战利品源都定义在 loot_sources 节点下。建议先阅读🎲 战利品表,了解战利品表的基本配置。

提示

如果只想在保留原版战利品的同时追加新内容,请保持 overwrite 为默认值 none,并用 random 条件控制掉落概率:

loot_sources:
minecraft:zombie_bonus:
type: entity_death
target: "minecraft:zombie"
conditions:
- type: random
value: 0.1 # 10% 概率在原版战利品之外额外掉落
loot:
pools:
- rolls: 1
entries:
- type: item
item: "default:rotten_essence"

通用选项

loot_sources:
namespace:example:
type: block_break # 战利品源类型
target: "minecraft:stone" # 可选;此战利品源作用的对象
overwrite: items # 可选;从原版结果中移除的内容
conditions: [] # 可选;附加条件
loot: ... # 要生成的战利品
  • type — 战利品源类型,见下文各小节。
  • target / targets (可选) — 单个 ID 或 ID 列表。具体含义取决于类型,可以是方块、实体、战利品表或进度 ID。省略时,战利品源会作用于该类型的所有对象。fishingpiglin_barter 不接受 target
  • overwrite (可选,默认 none — 从原版结果中移除的内容。可填单个值或列表:
    • items — 移除原版掉落的物品
    • experience — 移除原版掉落的经验
    • all — 以上两者
    • none — 不移除任何内容,你的战利品将追加到原版结果之后
  • conditions (可选) — 生成战利品前检查的附加条件。参见 ⚖️ 条件
  • loot — 要生成的战利品。可以内联战利品表,也可以引用另一张战利品表的 ID。如果不存在同 ID 的 CraftEngine 战利品表,系统会回退到数据包中的同名战利品表,因此可以直接引用原版战利品表:
loot: "minecraft:chests/simple_dungeon"
注意

target不允许使用 minecraft:wheat[age=7] 这样的方块状态语法。请改用 match_block_property 条件——参见匹配方块状态

block_break

方块被玩家或其他方块(如活塞)破坏时触发。

  • target:方块 id
loot_sources:
minecraft:stone_loot:
type: block_break
target: "minecraft:stone"
overwrite: items
loot:
pools:
- rolls: 1
entries:
- type: item
item: "default:topaz"

匹配方块状态

要匹配精确的方块状态,请将 targetmatch_block_property 条件组合使用:

loot_sources:
minecraft:ripe_wheat_loot:
type: block_break
target: "minecraft:wheat"
conditions:
- type: match_block_property
properties:
age: "7"
loot:
pools:
- rolls: 1
entries:
- type: item
item: "default:fancy_wheat"

该战利品源会在任意小麦被破坏时触发,但只有小麦的 age7 时才生成战利品。

entity_death

当实体死亡时触发。

  • target:实体 id。若要匹配受支持插件(例如 MythicMobs)提供的实体,请在 config.ymlloot.entity-sources 中列出该插件,并使用其提供的 id,例如 mythicmobs:skeletal_knight
loot_sources:
minecraft:zombie_loot:
type: entity_death
target: "minecraft:zombie"
conditions:
- type: random
value: 0.1
loot:
pools:
- rolls: 1
entries:
- type: item
item: "minecraft:diamond"

fishing

钓鱼浮漂钓到物品时触发。此类型不使用 target

loot_sources:
minecraft:fishing_bonus:
type: fishing
overwrite: items # 必须设置,否则玩家会同时获得原版渔获和你的战利品
conditions:
- type: open_water
loot:
pools:
- rolls: 1
entries:
- type: item
item: "default:treasure_crab"

piglin_barter

猪灵完成以物易物时触发。此类型不使用 target

loot_sources:
minecraft:barter_extra:
type: piglin_barter
overwrite: items
conditions:
- type: random
value: 0.05
loot:
pools:
- rolls: 1
entries:
- type: item
item: "minecraft:netherite_scrap"

container

箱子、木桶或运输矿车等战利品容器生成内容时触发。

  • target:原版战利品表 id,例如 minecraft:chests/simple_dungeon
loot_sources:
minecraft:dungeon_extra:
type: container
target: "minecraft:chests/simple_dungeon"
loot:
pools:
- rolls: 1
entries:
- type: item
item: "default:magic_map"

archaeology

当玩家开始刷扫可疑的沙子或可疑的沙砾时触发。

  • target:考古战利品表 id,例如 minecraft:archaeology/desert_pyramid
loot_sources:
minecraft:desert_pyramid_relic:
type: archaeology
target: "minecraft:archaeology/desert_pyramid"
loot:
pools:
- rolls: 1
entries:
- type: item
item: "default:ancient_relic"

entity_drop

非玩家实体生成掉落物时触发,例如鸡下蛋。

  • target:实体 id
loot_sources:
minecraft:golden_chicken:
type: entity_drop
target: "minecraft:chicken"
overwrite: items
conditions:
- type: random
value: 0.01
loot:
pools:
- rolls: 1
entries:
- type: item
item: "minecraft:gold_ingot"

harvest

当玩家采集有掉落物的方块时触发,例如甜浆果丛。

  • target:方块 id
loot_sources:
minecraft:berry_harvest:
type: harvest
target: "minecraft:sweet_berry_bush"
loot:
pools:
- rolls: 1
entries:
- type: item
item: "default:juicy_berry"

block_shear

当玩家用剪刀修剪方块时触发,例如蜂巢或南瓜。

  • target:方块 id
loot_sources:
minecraft:shear_pumpkin:
type: block_shear
target: "minecraft:pumpkin"
overwrite: items
loot:
pools:
- rolls: 1
entries:
- type: item
item: "minecraft:carved_pumpkin"

entity_shear

当玩家用剪刀修剪实体时触发,例如羊、哞菇或雪傀儡。

  • target:实体 id
loot_sources:
minecraft:shear_sheep:
type: entity_shear
target: "minecraft:sheep"
overwrite: items
loot:
pools:
- rolls: 1
entries:
- type: item
item: "default:rainbow_wool"

vault

当宝库喷出奖励时触发。

  • target:宝库战利品表 id,例如 minecraft:chests/trial_chambers/reward
loot_sources:
minecraft:vault_bonus:
type: vault
target: "minecraft:chests/trial_chambers/reward"
loot:
pools:
- rolls: 1
entries:
- type: item
item: "default:chamber_key_fragment"

advancement

当玩家完成进度时触发。生成的物品会直接放入玩家背包。

  • target:进度 id
loot_sources:
minecraft:adventure_reward:
type: advancement
target: "minecraft:adventure/root"
loot:
pools:
- rolls: 1
entries:
- type: item
item: "minecraft:golden_apple"