Files
netease-bedrock-wiki/mconline/10-addon教程/第12章:更完善的自定义掉落物/课程03.战利品功能.md
2025-08-25 18:36:29 +08:00

253 lines
4.6 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

---
front: https://mc.res.netease.com/pc/zt/20201109161633/mc-dev/assets/img/3_1.ea877fdd.jpg
hard: 进阶
time: 20分钟
---
# 战利品功能
#### 作者:境界
![](./images/3_1.jpg)
战利品功能可以赋予战利品更加强大的能力以僵尸正常掉落战利品的情况为例functions内定义了两个功能set_count和looting_enchant前者是设置掉落腐肉时的数量后者是被抢夺附魔赋予的额外数量。min是最小值而max是最大值数量会在这区间内随机产生。
除此之外,原版还有非常多的功能以供选择。
#### 与附魔相关的有:
enchant_with_levels通过附魔等级给予附魔。可以设置为附魔等级设置固定数值或随机区间。
```json
{
"function": "enchant_with_levels", //功能名称
"treasure": false, //若为真,则赋予稀有的附魔
"levels": 1 //附魔等级
}
```
```json
{
"function": "enchant_with_levels", //功能名称
"treasure": false,//若为真,则赋予稀有的附魔
"levels": {"min":1, "max": 2}//附魔等级
}
```
enchant_randomly随机附魔。
```json
{
"function": "enchant_randomly",//功能名称
"treasure": false,//若为真,则赋予稀有的附魔
}
```
enchant_random_gear给予随机的护甲附魔。
```json
{
"function": "enchant_random_gear", //功能名称
"chance": 0 //概率0.0~1.0区间1.0=100%
}
```
specific_enchants指定附魔和等级等级可以超过原版上限但游戏内只会显示原版的最高等级
```json
{
"function": "specific_enchants",
"enchants": [
{
"id": "aqua_affinity",
"level": 1
}
]
}
```
#### 与物品相关的有:
set_data//指定物品附加值如羊毛附加值15为黑色羊毛。
```json
{
"function": "set_data",
"data": 15
}
```
set_damage指定物品百分比耐久度1=100%的剩余耐久度0为没有剩余耐久度取值在0.0~1.0之间。
```json
{
"function": "set_damage",
"damage": 1
}
```
set_data_from_color_index根据minecraft:color行为设置对应的附加值原版使用minecraft:color行为的生物有羊因此会根据羊的羊毛颜色掉落对应的羊毛。
```json
{
"function": "set_data_from_color_index"
}
```
random_aux_value会给予一个非方块物品随机的附加值。
```json
{
"function": "random_aux_value",
"values": {
"min": 2,
"max": 9
}
}
```
set_book_contents会给予一本写好的书书名、作者、以及书本内容。
```json
{
"function": "set_book_contents",
"title": "1",
"author": "1",
"pages": [
"1111",
"2222"
]
}
```
fill_container会掉落或者给予一个箱子方块、发射器方块、漏斗方块一个自定义的战利品配置表。
```json
{
"function": "fill_container",
"loot_table": "loot_tables/table.json"
}
```
furnace_smelt会掉落一个带有熔炉配方的道具的配方结果如牛肉变烤牛肉条件目前只有on_fire着火和on_ground着地两种。
```json
{
"function": "furnace_smelt",
"conditions": [
{
"condition": "entity_properties",
"entity": "this",
"properties": {
"on_fire": true
}
}
]
}
```
set_banner_details设置旗帜的细节。
```json
{
"function": "set_banner_details",
"conditions": [
{
"condition": "entity_properties",
"type": 1
}
]
}
```
exploration_map设置地图变为探险家地图其中destination的目标值为原版/locate指令的参数包括 "monument", "mansion", "village", "stronghold", "temple", "ruins", "shipwreck", "pillageroutpost", "buriedtreasure", "mineshaft", "endcity", "fortress", "ruinedportal", "bastionremnant"。
```json
{
"function": "exploration_map",
"destination": "monument"
}
```
random_block_state随机选取一个block state值当设置的物品为方块物品且含有该值的话如 "coral_color", "flower_type", "sapling_type"更多blockstate请参考[官方文档](https://learn.microsoft.com/en-us/minecraft/creator/reference/content/blockreference/examples/intrinsicblockstateslist?view=minecraft-bedrock-stable)。
```json
{
"function": "random_block_state",
"values": {
"min": 1,
"max": 1
}
}
```
set_lore设置物品词缀。
```json
{
"function": "set_lore",
"lore": [ "111" ]
}
```
set_name设置物品名称。
```json
{
"function": "set_name",
"name": "design"
}
```
set_actor_id设置生物蛋物品的生物ID会掉落该生物的生物蛋。
```json
{
"function": "set_actor_id",
"id": "minecraft:zombie"
}
```