完整版BedrockWiki镜像!

This commit is contained in:
boybook
2025-03-20 11:52:46 +08:00
parent 1994c41f01
commit bf9aa4b056
214 changed files with 9042 additions and 8867 deletions

View File

@@ -1,11 +1,11 @@
---
title: 'Adding a Loot Table, a Spawn rule and a crafting recipe'
category: Guide
description: How to add your first Loot Table, Spawn Rule and Crafting Recipe
title: '添加战利品表、生成规则与合成配方'
category: 指南
description: 如何添加你的第一个战利品表、生成规则和合成配方
nav_order: 8
prefix: '8. '
mentions:
- KaiFireborn
- KaiFireBorn
- SirLich
- sermah
- cda94581
@@ -17,15 +17,18 @@ mentions:
- FrankyRay
---
Next, we'll enhance the custom Ghost entity by adding some more basic mechanics to it:
# 添加战利品表、生成规则与合成配方
## Loot tables
<!--@include: @/wiki/bedrock-wiki-mirror.md-->
First, we'll make the ghost drop Ectoplasm upon death: create the following file:
接下来我们将为自定义的幽灵实体添加更多基础机制:
<CodeHeader>BP/loot_tables/entities/ghost.json</CodeHeader>
## 战利品表
```json
首先让幽灵死亡时掉落灵质,创建以下文件:
::: code-group
```json [BP/loot_tables/entities/ghost.json]
{
"pools": [
{
@@ -50,24 +53,24 @@ First, we'll make the ghost drop Ectoplasm upon death: create the following file
]
}
```
:::
- Loot Tables consist of `"pools"`. Each pool defines a different loot. A pool consists of 3 parts, `"rolls"`, `"entries"` and `"conditions"`. The `"conditions"` are optional and won't be covered in this guide. To learn more about conditions, look at [Loot Tables](/loot/loot-tables).
- The `"rolls"` section defines how many times a random entry will be chosen from the following `"entries"`object.
- The `"entries"` part defines the items, from which the loot table can choose. Each roll a new item will be chosen.
- `"type"` defines what will be chosen. You can set it to `"item"` or `"loot_table"` to either chose an item or an different loot table.
- `"name"` will be set to an item identifier with its namespace. It defines which item will be selected.
- `"weight"` is optional and defines how likely it is, that this item will be selected. If there is more than one item in the `"entries"` section, the `"weight"` attribute can be used to make the probability of one item more or less likely. If it isn't set, it defaults to 1.
- `"functions"` provide a powerful way of customizing the item that will be returned. They can add enchantments to an item, setting an items' name or simply setting the number of items that will be dropped. To define the number of items, we use `"set_count"`. It takes the `"count"` attribute, which sets the maximum and minimum amount of items that will be dropped.
- 战利品表由`"pools"`(池)组成,每个池定义不同的战利品。每个池包含三部分:`"rolls"`(随机次数)、`"entries"`(条目)和可选的`"conditions"`(条件)。关于条件的详细信息请参阅[战利品表](/wiki/loot/loot-tables)
- `"rolls"`定义从`"entries"`中随机选择物品的次数
- `"entries"`定义可供选择的物品列表每次roll会从中选取一个新物品
- `"type"`决定选取类型,可设置为`"item"`(物品)或`"loot_table"`(其他战利品表)
- `"name"`使用命名空间格式指定具体物品
- `"weight"`权重决定物品被选中的概率默认值为1
- `"functions"`提供强大的物品自定义功能,可通过`"set_count"`设置掉落数量范围
For more information on loot tables, see our extended guide: [Loot Tables](/loot/loot-tables)!
更多战利品表知识请参阅进阶指南:[战利品表](/wiki/loot/loot-tables)
## Spawn rules
## 生成规则
Next, we'll make the ghost spawn in deserts at night:
接下来配置幽灵在沙漠生物群系的夜间生成规则:
<CodeHeader>BP/spawn_rules/ghost.json</CodeHeader>
```json
::: code-group
```json [BP/spawn_rules/ghost.json]
{
"format_version": "1.8.0",
"minecraft:spawn_rules": {
@@ -104,27 +107,27 @@ Next, we'll make the ghost spawn in deserts at night:
}
}
```
:::
- You already know what `"format_version"`does.
- Inside the `"minecraft:spawn_rules"` part we define our spawn rules.
- The `"description"` defines the basic properties of the file. The `"identifier"` is used to define on which entity this spawn rule applies on. `"population_control"` is used to limit the amount of entities that will be spawned. Once the pool that is defined inside of `"population_control"` is full, no more entities will be spawned.
- With `"conditions"` we can define rules that limit the spawning of this entity to special cases. We will shortly describe each condition used here, but you can learn more conditions and how to use them [here](/entities/vanilla-usage-spawn-rules).
- `"spawns_on_surface"` allows the mob to only spawn on surfaces.
- `"minecraft:brightness_filter"` limits the spawning to areas with a lighting level thats between the defined values. If `"adjust_for_weather"` is `true`, the light level decrease during rain and storms will be ignored.
- `"minecraft:difficulty_filter"` defines the difficulty level needed to spawn the entity.
- `"weight"` defines how often this entity will spawn. The higher this value, the more often the mob will spawn.
- `"minecraft:herd"`defines how many entities will be spawned at once.
- With `"minecraft:biome_filter"` we define the biomes in which the entity is able to spawn.
- `"description"`定义基础属性:
- `"identifier"`指定应用此规则的实体
- `"population_control"`控制实体生成数量上限
- `"conditions"`包含生成条件:
- `"spawns_on_surface"`限制地表生成
- `"brightness_filter"`设置光照范围0-7`"adjust_for_weather"`忽略天气影响
- `"difficulty_filter"`设置生效难度范围
- `"weight"`控制生成频率(数值越高越常见)
- `"herd"`设置单次生成数量
- `"biome_filter"`限定沙漠生物群系
To learn more about spawn rules, take a look on our guide on [Vanilla spawn rules](/entities/vanilla-usage-spawn-rules).
详细生成规则请参考:[原版生成规则](/wiki/entities/vanilla-usage-spawn-rules)
## Crafting recipes
## 合成配方
And finally, as an introduction to recipes, we'll make the Ectoplasm craftable into Slime Blocks:
最后实现将灵质合成史莱姆方块的功能:
<CodeHeader>BP/recipes/ectoplasm_slime_blocks.json</CodeHeader>
```json
::: code-group
```json [BP/recipes/ectoplasm_slime_blocks.json]
{
"format_version": "1.12.0",
"minecraft:recipe_shaped": {
@@ -144,36 +147,34 @@ And finally, as an introduction to recipes, we'll make the Ectoplasm craftable i
}
}
```
- `"format_version"` is already known.
- With `"recipe_shaped"` we define, that each ingredient has a set place in the crafting grid. There are some other types that can be used, you can find more information [here](/loot/recipes).
- Inside `"description"` we define the `"identifier"` of this recipe, which is the name of the recipe.
- `"tags"` is a list of benches (crafting table, furnace, etc) that are able to use this recipe. After version b1.16.100 it was possible to use custom benches, created by an addon.
- `"pattern"` defines the arrangement of the items inside the crafting grid. Each `#` represents the item that is set under `"key"`. In this case, the whole 3x3 grid has to be filled with `"wiki:ectoplasm"`, our own item. It is possible to define more items, just add an entry to `"key"` and set the key to a character, that you can use inside `"pattern"`.
- `"result"` contains an `"item"`, which is set to the item that will be the output of this recipe.
For more information on this topic, visit our page about [recipes](/loot/recipes)!
## What you have learned
:::tip What you have learned:
- How to create a loot table and define which items a mob is able to drop
- How to set the rules for a mob to spawn
- How to create new crafting recipes
:::
## Your progress so far
- `"recipe_shaped"`表示有序合成配方
- `"tags"`指定适用的工作台类型
- `"pattern"`定义3x3网格布局`#`符号对应`"key"`中指定的灵质
- `"result"`设置输出为原版史莱姆方块
**What you've done:**
完整配方教程请查看:[合成配方](/wiki/loot/recipes)
## 知识总结
:::tip 学习要点
- 创建战利品表配置生物掉落
- 设置生物生成规则
- 制作合成配方
:::
## 当前进度
**已完成内容:**
<Checklist>
- [x] Setup your pack
- [x] Create a custom item
- [x] Create a custom entity
- [x] Create the entity's loot, spawn rules, and a custom recipe
- [x] 资源包初始化
- [x] 创建自定义物品
- [x] 创建自定义实体
- [x] 添加实体掉落、生成规则与合成配方
</Checklist>
Congratulations! you have finished the Guide and created your first Add-on. 🎉
恭喜!你已完成全部教程并创建了第一个附加包 🎉