完整版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,8 +1,8 @@
---
title: Attachables
category: Documentation
title: 附加物
category: 文档
tags:
- beginner
- 新手
mentions:
- Sprunkles317
- MedicalJewel105
@@ -11,27 +11,31 @@ mentions:
- TheItsNameless
---
# 附加物
<!--@include: @/wiki/bedrock-wiki-mirror.md-->
::: tip
This document assumes you have a basic understanding of Molang, render controllers, animations, and client entity definitions. Ensure you are familiar with the basics of [client entities](/entities/entity-intro-rp)!
本文档假设您已掌握Molang、渲染控制器、动画和客户端实体定义的基础知识。请确保您熟悉[客户端实体](/wiki/entities/entity-intro-rp)的基本原理!
:::
## Introduction
## 简介
When we design a custom item or block, Minecraft will build a model from a template so the item can be displayed when held. This takes the form of the item's sprite being an extruded texture mesh, or blocks displaying with their model. By using a system called **attachables** we can design our own models to be displayed when these items are held.
当我们设计自定义物品或方块时Minecraft会根据模板生成模型以便在手持时显示。这表现为物品以拉伸纹理网格形式显示或方块显示其预设模型。通过使用**可附着物**系统,我们可以设计自己的模型来替换这些手持显示效果。
Ever wanted sticks to look like spyglasses? Or to wield a big chainsaw with a spinning chain? Attachables are the way to accomplish that!
想让木棍看起来像望远镜?或是挥舞带有旋转链条的巨型电锯?可附着物正是实现这些效果的关键!
This document covers **two different ways** to create attachables, depending on how the geometry being used is constructed.
本文将介绍**两种不同方法**来创建可附着物,具体取决于所用几何体的构建方式。
## Overview
## 概述
Attachables are a system of rendering entity models when an item or block is equipped. This means having the item held in the main hand, off hand, or armor slots.
可附着物系统用于在装备物品或方块时渲染实体模型。这里的装备包括主手、副手和护甲槽位中的物品。
Attachable definitions are quite similar in design to client entity definitions; they let us define textures, materials, geometries, and animations to display the attachable.
可附着物定义文件在结构上与客户端实体定义非常相似,允许我们定义要显示的纹理、材质、几何体和动画。
### File Structure
### 文件结构
The attachable definition goes within the 'attachables' folder. The file layout is otherwise identical to that of custom entities.
可附着物定义文件应存放在'attachables'文件夹中。其他文件布局与自定义实体完全一致。
<FolderView
:paths="[
@@ -43,13 +47,12 @@ The attachable definition goes within the 'attachables' folder. The file layout
]"
></FolderView>
### Attachable Definition
### 可附着物定义
Here's a basic example of an attachable.
以下是一个基础的可附着物示例:
<CodeHeader>RP/attachables/stick.entity.json</CodeHeader>
```json
::: code-group
```json [RP/attachables/stick.entity.json]
{
"format_version": "1.10.0",
"minecraft:attachable": {
@@ -87,88 +90,80 @@ Here's a basic example of an attachable.
}
}
```
:::
A few key things to point out with this attachable definition:
此定义中有几个关键点需要注意:
- The identifier matches an existing block or item ID. This will activate the attachable when the item is equipped, and will replace the original model that appears when held.
- There is a material and texture listed for the enchantment glint. This is important to keep around if your item should have the glint when enchanted.
- 标识符需与现有方块/物品ID匹配。这将激活可附着物效果替换原版手持模型
- 包含了附魔光效的材质和纹理定义。若物品需要附魔特效,这部分必须保留
Making attachables is a little more involved than making a client entity file. We need to properly rig the geometry's skeleton so that it looks correct when equipped.
制作可附着物比创建普通客户端实体文件更复杂。我们需要正确绑定几何体的骨骼结构,确保装备时显示正确。
## Method 1 - Attached to the Skeleton
## 方法一 - 绑定骨骼系统
<Label name="Beginner" color="blue"></Label>
<Label name="新手" color="blue"></Label>
In this first method we will construct the attachable using a copy of the player's skeleton, by attaching your model to one of the player's bones.
此方法通过复制玩家骨骼系统将模型附加到特定骨骼上实现。适用于单一实体类型特别是玩家和单一装备槽位的场景在Blockbench中预览效果更方便。
This solution is ideal for models that are intended for scenarios involving only one type of mob/entity, especially players; and involving only one equipment slot. It is easy to view what the model will look like in Blockbench.
### 骨骼系统搭建
### Setting up the Skeleton
需要重建玩家骨骼结构,否则模型无法正确绑定骨骼,导致漂浮在玩家周围。
We need to reconstruct the player's skeleton in order for our model to be parented to the correct bone, otherwise it will not be parented to anything and will float freely on the player.
使用文本编辑器将玩家骨骼文件中的骨骼结构复制到您的几何体文件中,然后将模型立方体设为`rightItem`骨骼的子级。将此几何体保存至资源包。
With a text editor, take the bones from the provided player skeleton file and copy them to your geometry file, then set the `rightItem` bone as the parent to the cubes from your model. Save this geometry to your resource pack.
For convenience, such a model has been prepared here. The cubes from the player's model have already been removed:
我们已准备好一个预制模型(已移除原玩家模型的立方体):
<BButton
link="https://github.com/Bedrock-OSS/bedrock-wiki/blob/wiki/docs/public/assets/packs/tutorials/attachables/method_one/steve_head.geo.json?raw=true"
color=blue
>📄 Geometry File</BButton>
>📄 几何体文件</BButton>
### Display Settings
### 显示设置
Having your model floating at the player's feet is not ideal. Our next step is to create animations so we can properly display the model on the player.
为避免模型漂浮在玩家脚部,需要创建动画来控制显示位置。
Create two new animations, one for holding the item in first person and another for holding it in third person. Select your third-person animation, and position it however you want. Save this animation to your resource pack.
新建两个动画:第一人称手持动画和第三人称手持动画。调整第三人称动画的位置参数后保存至资源包。
Here is an example of such an animation. This also includes a first-person animation—the means of making one is detailed in the section below.
示例动画文件(包含第一人称动画制作说明):
<BButton
link="https://github.com/Bedrock-OSS/bedrock-wiki/blob/wiki/docs/public/assets/packs/tutorials/attachables/method_one/steve_head.animation.json?raw=true"
color=blue
>📄 Animation File</BButton>
>📄 动画文件</BButton>
### First-person Animations
### 第一人称动画
To more easily create first-person animations, we need to mimic how the arm is positioned in the first person.
制作第一人称动画时需模拟游戏中手臂的真实姿势:
:::tip
To add animation for player's hands, you need to use player's animations, not attachables animations.
注意:玩家手部动画需使用玩家动画系统,而非可附着物动画系统。
:::
Use the following guide animation and import it into Blockbench. It applies a rotation of (95, -45, 115) and a translation of (13.5, -10, 12) to the right arm bone, perfectly mimicking how the arm is positioned in first-person.
使用指导动画文件(应用右臂骨骼旋转(95, -45, 115)和平移(13.5, -10, 12))来准确定位:
<BButton
link="https://github.com/Bedrock-OSS/bedrock-wiki/blob/wiki/docs/public/assets/packs/tutorials/attachables/method_one/attachable_guide.animation.json?raw=true"
color=blue
>📄 Attachable Guide File</BButton>
>📄 动画指导文件</BButton>
:::warning NOTE
This is where things get tricky. Both animations will need to be played simultaneously; your first-person animation, and the guide's first-person animation.
Be sure you are editing your animation when making your changes. Select it first, then play the guide's first-person animation on top.
:::warning 重要提示
需要同时播放两个动画您的第一人称动画和指导动画。在Blockbench中编辑时请确保选中您的动画后再叠加播放指导动画。
:::
### Conclusion
### 最终效果
With this all set up, go through and delete the *cubes* from the player skeleton if there are any, but keep the bones. Check the model out in-game!
完成上述步骤后,删除玩家骨骼中的立方体(保留骨骼结构),即可在游戏中查看效果!
## Method 2 - Bound to a Bone
## 方法二 - 骨骼绑定系统
<Label name="Intermediate" color="orange"></Label>
<Label name="进阶" color="orange"></Label>
In this second method, the attachable geometry will be constructed using model binding. This allows a model to be directly attached to a bone within a mob's geometry corresponding to the slot it is equipped in. Minecraft employs model binding for its attachable items, including the trident, spyglass, bow, and shield.
此方法通过模型绑定直接将几何体附加到对应装备槽位的骨骼上。Minecraft原生物品如三叉戟、望远镜均采用此方案。虽然能实现动态多生物适配但存在一些特殊限制。
While this method allows the attachable to apply more dynamically to other mobs and equipment slots, model binding also has strange quirks, which will be illustrated below. Some developers may find this method trickier to get working.
### 模型绑定
### Model Binding
首先确保几何体文件版本为`"1.16.0"`可通过Blockbench转换旧版文件。然后在根骨骼添加绑定声明
Our first step is to upgrade the model file format version to `"1.16.0"` if it is not already. If the model is a legacy file, then convert it before continuing; Blockbench has a tool to do this (File → Convert Project).
Next up is modifying the root bone of our geometry to be bound to the equipment slot the item is placed in. Take note of line 4 in this excerpt from the skeleton head geometry file:
<CodeHeader>RP/models/entity/skeleton_head.geo.json</CodeHeader>
```json
// A bone
::: code-group
```json [RP/models/entity/skeleton_head.geo.json]
// 一个骨骼
{
"name": "skeleton_head",
"binding": "q.item_slot_to_bone_name(context.item_slot)",
@@ -182,70 +177,54 @@ Next up is modifying the root bone of our geometry to be bound to the equipment
]
}
```
:::
The `"parent"` key in a bone accepts a string, and whichever bone name is entered will be set as the parent to the current bone; the child bones keep their positions but move relative to the parent bone.
- `binding`键使用Molang查询`q.item_slot_to_bone_name`将装备槽位转换为骨骼名称:
- `'main_hand'` → "rightitem"
- `'off_hand'` → "leftitem"
The `"binding"` key on the other hand accepts Molang, and the pivot point of whichever bone name is entered is set as the *root position* that the child bone and its children should inherit.
For the value of `"binding"` we are using the Molang query `q.item_slot_to_bone_name`, which converts a slot name to a bone name, with the contextual variable `context.item_slot` as an argument. This converts the name of the equipment slot this item resides in to its corresponding bone name in the player's geometry. The conversions are as follows:
- `'main_hand'` → "rightitem"
- `'off_hand'` → "leftitem"
Apply the model binding to your bone, and save the geometry to your resource pack.
An example model with this binding applied is provided here:
示例绑定模型:
<BButton
link="https://github.com/Bedrock-OSS/bedrock-wiki/blob/wiki/docs/public/assets/packs/tutorials/attachables/method_two/skeleton_head.geo.json?raw=true"
color=blue
>📄 Geometry File</BButton>
>📄 几何体文件</BButton>
### Display Settings
### 显示设置
With that done, the next step is to set up animations to display the model in first person and third person.
创建第一人称和第三人称动画时,建议:
Create two new animations, one for holding the item in first person and another for holding it in third person.
To make creating these animations easier, please do the following:
- Download the following player skeleton model. We will use this as a visual aid for positioning your model.
1. 下载玩家骨骼模型作为定位参考:
<BButton
link="https://github.com/Bedrock-OSS/bedrock-wiki/blob/wiki/docs/public/assets/packs/tutorials/attachables/method_two/player_skeleton.geo.json?raw=true"
color=blue
>📄 Player Skeleton File</BButton>
>📄 玩家骨骼文件</BButton>
- With a text editor, add the bones and cubes from your model to the player skeleton model, then import the player skeleton model into Blockbench.
- Set your model's root bone(s) to be a child of the 'rightItem' bone in the player skeleton.
- Download the following animation file import the `wiki.third_person_guide` animation. This will be used later to make positioning easier.
2. 将模型骨骼添加为玩家骨骼中'rightItem'的子级
3. 使用指导动画抵消Minecraft的-24Y轴偏移
<BButton
link="https://github.com/Bedrock-OSS/bedrock-wiki/blob/wiki/docs/public/assets/packs/tutorials/attachables/method_two/attachable_guide.animation.json?raw=true"
color=blue
>📄 Attachable Guide File</BButton>
>📄 动画指导文件</BButton>
These guide animations have one notable feature: they apply a -24 offset to the y-position of the right item bone to counteract a similar -24 y-position offset Minecraft applies to bound bones. We are unsure at this time why this happens.
:::warning NOTE
Similar to Method One, **two** animations will need to be played simultaneously for correct positioning.
Be sure you are editing your animations when making your changes. Select it first, then play the guide animation on top.
:::warning 重要提示
需要同时播放自定义动画和指导动画。在Blockbench中编辑时请先选中您的动画再叠加播放指导动画。
:::
Play both animations, and position your model however you want. Save the animations to your resource pack.
An example animation file for this positioning:
示例动画定位:
<BButton
link="https://github.com/Bedrock-OSS/bedrock-wiki/blob/wiki/docs/public/assets/packs/tutorials/attachables/method_two/skeleton_head.animation.json?raw=true"
color=blue
>📄 Animation File</BButton>
>📄 动画文件</BButton>
### First-person Animations
### 第一人称动画
Similar to the third-person animation, look in the Attachable Guide file and import the `wiki.first_person_guide` animation into Blockbench. Play both your animation and the guide's first-person animation together, then make your changes and save the file.
参照第三人称动画的制作流程,在指导文件中导入`wiki.first_person_guide`动画进行叠加编辑。
## Example Pack
## 示例包
Each of these methods have been compiled into an example pack you may reference, for if you are getting stuck or simply want to see a working example.
我们准备了包含两种方法的完整示例包供参考:
<BButton
link="https://github.com/Bedrock-OSS/wiki-addon/releases/download/download/attachable-example.mcpack"
color=blue
>💾 Example Pack</BButton>
>💾 示例包下载</BButton>

View File

@@ -1,6 +1,6 @@
---
title: Custom Armor
category: Tutorials
title: 自定义盔甲
category: 巧思案例
tags:
- experimental
mentions:
@@ -17,67 +17,70 @@ mentions:
- SmokeyStack
---
# 自定义盔甲
<!--@include: @/wiki/bedrock-wiki-mirror.md-->
::: tip
It is highly recommended that you look over [the BlockBench modelling and texturing](/guide/blockbench) section in the beginners guides before tackling these sections.
强烈建议在开始本节内容前,先阅读[BlockBench建模与纹理制作指南](/wiki/guide/blockbench)中的新手引导部分。
:::
Making custom armors is surprisingly easy to do, you need to do a bit of fiddling around as there are a few files that need to be added and there can be a little bit of texturing involved but you can do as much or as little as you want here.
制作自定义盔甲其实非常简单,虽然需要处理多个文件并进行一些纹理调整,但你可以根据自己的需求选择工作量。
## Chest Piece
## 胸甲部分
Create a chest piece:
创建胸甲物品:
<CodeHeader>BP/items/my_chest.json</CodeHeader>
```json
::: code-group
```json [BP/items/my_chest.json]
{
"format_version": "1.16.100",
"minecraft:item": {
"description": {
"identifier": "wiki:my_chest",
// Notice we give it the equipment category
// 注意我们将其归类为装备
"category": "equipment"
},
"components": {
// Make sure it appears within the chestplate category
// 确保出现在胸甲分类中
"minecraft:creative_category": {
"parent": "itemGroup.name.chestplate"
},
// The icon we want to use in our INVENTORY
// 物品栏中显示的图标
"minecraft:icon": {
"texture": "my_chest"
},
// We give it a name
// 物品名称
"minecraft:display_name": {
"value": "My Custom Armor"
"value": "我的自定义盔甲"
},
// We dont want it to stack
// 禁止堆叠
"minecraft:max_stack_size": 1,
// We make sure it can only receive enchantments for chest pieces
// 仅接受胸甲部位附魔
"minecraft:enchantable": {
"value": 10,
"slot": "armor_torso"
},
// This tells it how much protection it should give
// 护甲值设置
"minecraft:armor": {
"protection": 5
},
// We want it to be repairable, and what to use to repair it
// 修复材料设置
"minecraft:repairable": {
"repair_items": [
{
"items": ["minecraft:stick"],
"repair_amount": "context.other->q.remaining_durability + 0.05 * context.other->q.max_durability"
// Some complicated molang; just copy it
// 复杂molang表达式直接复制即可
}
]
},
// Mark it as a wearable and that it goes in the chest slot
// 穿戴设置(胸部槽位)
"minecraft:wearable": {
"dispensable": true,
"slot": "slot.armor.chest"
},
// Provide its durability
// 耐久度设置
"minecraft:durability": {
"max_durability": 200
}
@@ -86,78 +89,67 @@ Create a chest piece:
}
```
At this point you could just go and add an item texture into your `RP/textures/item_texture.json` with the key `my_chest` and you are on your way. We have attached a default item texture for your armor here if you want to just follow along.
此时你只需在`RP/textures/item_texture.json`中添加名为`my_chest`的纹理即可。我们提供了默认纹理供参考:
![](/assets/images/tutorials/custom-armor/custom_chestplate.png)
<BButton link="https://raw.githubusercontent.com/Bedrock-OSS/bedrock-wiki/wiki/docs/public/assets/images/tutorials/custom-armor/custom_chestplate.png">Download texture here</BButton>
<BButton link="https://raw.githubusercontent.com/Bedrock-OSS/bedrock-wiki/wiki/docs/public/assets/images/tutorials/custom-armor/custom_chestplate.png">点击此处下载纹理</BButton>
## Adding attachables and textures
## 添加附着物与纹理
At this point your item would appear in game and would be wearable but it would not have any appearance. This is because we need to tell it how to handle the attachable equipment and give it a texture to show.
现在需要配置盔甲模型附着物:
To start with you need to create an `attachables` folder in your RP (you may already have one).
<CodeHeader>RP/attachables/my_chest.json</CodeHeader>
```json
::: code-group
```json [RP/attachables/my_chest.json]
{
"format_version": "1.8.0",
"minecraft:attachable": {
"description": {
"identifier": "wiki:my_chest",
// These 2 are default and are required
// 必需材质配置
"materials": {
"default": "armor",
"enchanted": "armor_enchanted"
},
"textures": {
// This is our CUSTOM armor texture we need to make next
// 自定义盔甲纹理路径
"default": "textures/models/armor/custom_main",
// This texture doesn't actually exist in our RP
// but it will blow up without it so leave it in
// 保留默认附魔光效
"enchanted": "textures/misc/enchanted_item_glint"
},
// We tell it what geometry to use for the chestplate
// 使用胸甲模型
"geometry": {
"default": "geometry.player.armor.chestplate"
},
// We tell it to hide the chest layer as we will be showing our armor on top
// 隐藏默认胸甲层
"scripts": {
"parent_setup": "v.chest_layer_visible = 0.0;"
},
// We tell it what controller to use (default armor one)
// 使用标准渲染控制器
"render_controllers": ["controller.render.armor"]
}
}
}
```
At this point we need to make sure we create a texture for our model, these live in `RP/textures/models/armor`. We however actually need 2 textures, as one is for the main armor as if it is being worn all together, and one is for the legs which when worn alone will often cover some of the boot area.
If you do not feel creative we have provided a recoloured diamond armour skin for use with this tutorial. So just `Save As` and plop them in the folder.
下载配套纹理文件:
![](/assets/images/tutorials/custom-armor/custom_main.png)
<BButton link="https://raw.githubusercontent.com/Bedrock-OSS/bedrock-wiki/wiki/docs/public/assets/images/tutorials/custom-armor/custom_main.png">Download texture here</BButton>
<BButton link="https://raw.githubusercontent.com/Bedrock-OSS/bedrock-wiki/wiki/docs/public/assets/images/tutorials/custom-armor/custom_main.png">下载主纹理</BButton>
![](/assets/images/tutorials/custom-armor/custom_legs.png)
<BButton link="https://raw.githubusercontent.com/Bedrock-OSS/bedrock-wiki/wiki/docs/public/assets/images/tutorials/custom-armor/custom_legs.png">Download texture here</BButton>
<BButton link="https://raw.githubusercontent.com/Bedrock-OSS/bedrock-wiki/wiki/docs/public/assets/images/tutorials/custom-armor/custom_legs.png">下载腿部纹理</BButton>
> In the real world you would probably want to use `BlockBench` or some photo editing program to edit the textures and ideally see how they look on a model before you add them into the addon.
> If you now go into the game and check what you have produced you should be able to wear your chest piece and pat yourself on the back for a job well done.
> 实际开发中建议使用BlockBench预览模型效果
![](/assets/images/tutorials/custom-armor/armor-item-image.jpg)
![](/assets/images/tutorials/custom-armor/armor-model-image.jpg)
## 护腿部分
## Leggings
创建护腿物品:
So while the chest piece alone is great, you probably want a whole set, so from here if you make another item json for the boots like so.
<CodeHeader>BP/items/my_leggings.json</CodeHeader>
```json
::: code-group
```json [BP/items/my_leggings.json]
{
"format_version": "1.16.100",
"minecraft:item": {
@@ -166,19 +158,18 @@ So while the chest piece alone is great, you probably want a whole set, so from
"category": "equipment"
},
"components": {
// We give it the leggings category this time
// 护腿分类
"minecraft:creative_category": {
"parent": "itemGroup.name.leggings"
},
// Give it an applicable ITEM texture
"minecraft:icon": {
"texture": "my_leggings"
},
"minecraft:display_name": {
"value": "My Custom Leggings"
"value": "我的自定义护腿"
},
"minecraft:max_stack_size": 1,
// Make sure the enchantments are for legs
// 腿部附魔槽
"minecraft:enchantable": {
"value": 10,
"slot": "armor_legs"
@@ -186,15 +177,8 @@ So while the chest piece alone is great, you probably want a whole set, so from
"minecraft:armor": {
"protection": 3
},
"minecraft:repairable": {
"repair_items": [
{
"items": ["minecraft:stick"],
"repair_amount": "context.other->q.remaining_durability + 0.05 * context.other->q.max_durability"
}
]
},
// Make sure the wearable slot is legs
"minecraft:repairable": { /* 同胸甲配置 */ },
// 腿部穿戴槽
"minecraft:wearable": {
"dispensable": true,
"slot": "slot.armor.legs"
@@ -207,356 +191,165 @@ So while the chest piece alone is great, you probably want a whole set, so from
}
```
This is great and like before you will need to add your own item texture, although here is one if you just want to continue.
护腿纹理下载:
![](/assets/images/tutorials/custom-armor/custom_leggings.png)
<BButton link="https://raw.githubusercontent.com/Bedrock-OSS/bedrock-wiki/wiki/docs/public/assets/images/tutorials/custom-armor/custom_leggings.png">Download texture here</BButton>
<BButton link="https://raw.githubusercontent.com/Bedrock-OSS/bedrock-wiki/wiki/docs/public/assets/images/tutorials/custom-armor/custom_leggings.png">下载护腿纹理</BButton>
Once we are done here we need to create the attachables file like this:
附着物配置:
<CodeHeader>RP/attachables/my_leggings.json</CodeHeader>
```json
::: code-group
```json [RP/attachables/my_leggings.json]
{
"format_version": "1.8.0",
"minecraft:attachable": {
"description": {
"identifier": "wiki:my_leggings",
// Notice this is the same as before
"materials": {
"default": "armor",
"enchanted": "armor_enchanted"
},
"materials": { /* 同胸甲配置 */ },
"textures": {
// Same as before
"enchanted": "textures/misc/enchanted_item_glint",
// This one is different as we are using the legging specific texture
"default": "textures/models/armor/custom_legs"
"default": "textures/models/armor/custom_legs",
"enchanted": "textures/misc/enchanted_item_glint"
},
// Tell it to use leggings geom
// 使用护腿模型
"geometry": {
"default": "geometry.humanoid.armor.leggings"
},
// Hide legs layer as we will be rendering over it
// 隐藏默认腿部层
"scripts": {
"parent_setup": "v.leg_layer_visible = 0.0;"
},
// Same as before
"render_controllers": ["controller.render.armor"]
}
}
}
```
Given that we have already put in the textures needed we can run it and see our legs straight away.
## 头盔部分
## Helmet
头盔物品配置:
This is just like the chest piece, just we change some of the categories and slots like so.
<CodeHeader>BP/items/my_helm.json</CodeHeader>
```json
::: code-group
```json [BP/items/my_helm.json]
{
"format_version": "1.16.100",
"minecraft:item": {
"description": {
"identifier": "wiki:my_helm",
"category": "equipment"
},
"description": { /* 基础配置 */ },
"components": {
// Helmet category
// 头盔分类
"minecraft:creative_category": {
"parent": "itemGroup.name.helmet"
},
"minecraft:icon": {
"texture": "my_helm"
},
"minecraft:display_name": {
"value": "My Custom Helmet"
},
"minecraft:max_stack_size": 1,
// Helm enchantment slot
// 头部附魔槽
"minecraft:enchantable": {
"value": 10,
"slot": "armor_head"
},
"minecraft:armor": {
"protection": 3
},
"minecraft:repairable": {
"repair_items": [
{
"items": ["minecraft:stick"],
"repair_amount": "context.other->q.remaining_durability + 0.05 * context.other->q.max_durability"
}
]
},
// Wearable head slot
// 头部穿戴槽
"minecraft:wearable": {
"dispensable": true,
"slot": "slot.armor.head"
},
"minecraft:durability": {
"max_durability": 200
}
/* 其他配置同前 */
}
}
}
```
As you can see not much has changed, we just update the categories/slots to the correct ones for helms and then we add the attachables file (here is the item texture if you need it).
头盔纹理下载:
![](/assets/images/tutorials/custom-armor/custom_helmet.png)
<BButton link="https://raw.githubusercontent.com/Bedrock-OSS/bedrock-wiki/wiki/docs/public/assets/images/tutorials/custom-armor/custom_helmet.png">Download texture here</BButton>
<BButton link="https://raw.githubusercontent.com/Bedrock-OSS/bedrock-wiki/wiki/docs/public/assets/images/tutorials/custom-armor/custom_helmet.png">下载头盔纹理</BButton>
<CodeHeader>RP/attachables/my_helm.json</CodeHeader>
## 靴子部分
```json
{
"format_version": "1.8.0",
"minecraft:attachable": {
"description": {
"identifier": "wiki:my_helm",
// These 2 are default and are required
"materials": {
"default": "armor",
"enchanted": "armor_enchanted"
},
"textures": {
// This is our CUSTOM armor texture we need to make next
"default": "textures/models/armor/custom_main",
// This texture doesn't actually exist in our RP
// but it will blow up without it so leave it in
"enchanted": "textures/misc/enchanted_item_glint"
},
// We tell it what geometry to use for the helmet
"geometry": {
"default": "geometry.player.armor.helmet"
},
// We tell it to hide the helmet layer as we will be showing our armor on top
"scripts": {
"parent_setup": "v.chest_layer_visible = 0.0;"
},
// We tell it what controller to use (default armor one)
"render_controllers": ["controller.render.armor"]
}
}
}
```
靴子物品配置:
There you go, you now have 3/4 of a complete set, we may as well go through the boots as well so you know all the categories etc.
## Boots
You already know the pattern so lets make the item and attachable json files.
<CodeHeader>BP/items/my_boots.json</CodeHeader>
```json
::: code-group
```json [BP/items/my_boots.json]
{
"format_version": "1.16.100",
"minecraft:item": {
"description": {
"identifier": "wiki:my_boots",
"category": "equipment"
},
"components": {
// Boots category
// 靴子分类
"minecraft:creative_category": {
"parent": "itemGroup.name.boots"
},
"minecraft:icon": {
"texture": "my_boots"
},
"minecraft:display_name": {
"value": "My Custom Boots"
},
"minecraft:max_stack_size": 1,
// Enchantable Feet
// 足部附魔槽
"minecraft:enchantable": {
"value": 10,
"slot": "armor_feet"
},
"minecraft:armor": {
"protection": 3
},
"minecraft:repairable": {
"repair_items": [
{
"items": ["minecraft:stick"],
"repair_amount": "context.other->q.remaining_durability + 0.05 * context.other->q.max_durability"
}
]
},
// Feet slot
// 足部穿戴槽
"minecraft:wearable": {
"dispensable": true,
"slot": "slot.armor.feet"
},
"minecraft:durability": {
"max_durability": 200
}
/* 其他配置同前 */
}
}
}
```
The custom boots texture if you need it.
靴子纹理下载:
![](/assets/images/tutorials/custom-armor/custom_boots.png)
<BButton link="https://raw.githubusercontent.com/Bedrock-OSS/bedrock-wiki/wiki/docs/public/assets/images/tutorials/custom-armor/custom_boots.png">Download texture here</BButton>
<BButton link="https://raw.githubusercontent.com/Bedrock-OSS/bedrock-wiki/wiki/docs/public/assets/images/tutorials/custom-armor/custom_boots.png">下载靴子纹理</BButton>
<CodeHeader>RP/attachables/my_boots.json</CodeHeader>
## 套装效果(进阶)
```json
{
"format_version": "1.8.0",
"minecraft:attachable": {
"description": {
"identifier": "wiki:my_boots",
// These 2 are default and are required
"materials": {
"default": "armor",
"enchanted": "armor_enchanted"
},
"textures": {
// This is our CUSTOM armor texture we need to make next
"default": "textures/models/armor/custom_main",
// This texture doesn't actually exist in our RP
// but it will blow up without it so leave it in
"enchanted": "textures/misc/enchanted_item_glint"
},
// We tell it what geometry to use for the boots
"geometry": {
"default": "geometry.player.armor.boots"
},
// We tell it to hide the boots layer as we will be showing our armor on top
"scripts": {
"parent_setup": "v.chest_layer_visible = 0.0;"
},
// We tell it what controller to use (default armor one)
"render_controllers": ["controller.render.armor"]
}
}
}
```
在`player.json`中添加伤害检测与事件响应:
Thats it, you now have a whole suit of custom armor you can swagger around in, and use this as a basis to make whatever other armors you want in the game.
> It is worth noting that we have used 2 separate textures here, and you could potentially use a texture per attachable, but each new texture consumes memory so its best to use as few as possible.
> So this is what you should end up with, and as a bonus there is one more section on making set effects using filters, which is a bit more advanced but its a fun thing to do.
![](/assets/images/tutorials/custom-armor/custom-set-image.jpg)
## Bonus - Making Set Effects
This is a bit more advanced but lets say you want your custom armor to act like it's a set from an RPG game. We can add some code to check if we have the set equipped and do some great stuff with it.
Note that for effects you can use tick.json and functions with hasitem selector argument to avoid using player.json.
In this example we will just add a chance to teleport the attacker somewhere nearby and put a blurb on the console for flavour.
As we want this to trigger when the player is hit we need to add some logic to the `player.json` file. This is a huge file and we unfortunately need to make sure it has all the default content in there as well due to the way it will overwrite the default player components etc.
So rather than include the whole `player.json` I will just include the parts you will need to add to your `components` and `events` sections. If you have no idea what the `player.json` is then look in the vanilla behavior pack and look for it and just copy it over into your project.
So first of all lets put in the damage sensor component (which goes in your component section) which listens for when you take damage and lets you raise an event from it.
<CodeHeader>BP/entities/player.json#components</CodeHeader>
```json
::: code-group
```json [BP/entities/player.json#components]
"minecraft:damage_sensor": {
"triggers": {
"on_damage": {
"filters": {
"all_of": [
{
"test": "has_equipment",
"subject": "self",
// Domain is the body part in this case
"domain": "head",
"operator": "==",
// The item identifier we want to check
"value": "wiki:my_helm"
},
{
"test": "has_equipment",
"subject": "self",
"domain": "torso",
"operator": "==",
// Worth noting you can omit prefix for minecraft internal items i.e stick
"value": "wiki:my_chest"
},
{
"test": "has_equipment",
"subject": "self",
"domain": "leg",
"operator": "==",
"value": "wiki:my_leggings"
},
{
"test": "has_equipment",
"subject": "self",
"domain": "feet",
"operator": "==",
"value": "wiki:my_boots"
}
// 检测全身装备
{ "test": "has_equipment", "domain": "head", "value": "wiki:my_helm" },
{ "test": "has_equipment", "domain": "torso", "value": "wiki:my_chest" },
{ "test": "has_equipment", "domain": "leg", "value": "wiki:my_leggings" },
{ "test": "has_equipment", "domain": "feet", "value": "wiki:my_boots" }
]
},
// If all the triggers match in the filter raise the event
"event": "wiki:armor_sets.my_custom.taken_damage"
},
// This means if it matches the check it still applies damage
// Can be good to ignore team damage or similar scenarios
"deals_damage": true
}
}
}
```
As you can see from the comments, there is a lot there but really all we are doing is listening out for something then making sure we only filter the results we care about then relay on an event.
> The event can be called anything but it is often better to have it more specific, incase you end up having multiple similar events etc, also it can help finding if you have multiple sections to it, i.e I could search on "armour_sets" and find all events related to it.
> Then once you are done, in the same file we decide what we want to do with the event, which we put into our `events` section.
<CodeHeader>BP/entities/player.json#events</CodeHeader>
```json
```json [BP/entities/player.json#events]
"wiki:armor_sets.my_custom.taken_damage": {
"randomize": [
{
"weight": 1,
// We do a sequence here as we want to apply one command
// on one entity and the other on ourselves
"sequence": [
{
// This will take the attacker/other because it was in context
// at time of raising the event in the damage_sensor
// 传送攻击者
"run_command": {
// Teleport the entity away from us
"command": "spreadplayers ~~ 5 20 @s",
// Run the command on the attacker not us
"target": "other"
}
},
{
// 发送提示信息
"run_command": {
"command": "tellraw @s{\"rawtext\":[{\"text\":\"§aYour Armor Glows And The Enemy Vanishes\"}]}"
"command": "tellraw @s{\"rawtext\":[{\"text\":\"§a盔甲发光,敌人消失了!\"}]}"
}
}
]
},
{
// Dummy weighting so it happens semi frequently
"weight": 20
}
{ "weight": 20 }
]
}
```
Thats it, you can rejig the bits how you see fit but ultimately you have all the pieces to apply effects to armor and check for if you have the whole set applied or check for other equipment.
完成效果展示:
You can also change the equipment checks from self to other and check if whoever is attacking you has something equipped or even check if you are attacking a sort of block/entity and do different effects based on that. We haven't touched on that directly here but there is a good enough starting point to get you on your way and let you be creative with things.
![](/assets/images/tutorials/custom-armor/custom-set-image.jpg)
> 提示:建议使用最少纹理数量优化性能。通过组合使用主纹理和腿部纹理即可完成全套盔甲效果。

View File

@@ -1,8 +1,8 @@
---
title: Custom Weapons
category: Tutorials
title: 自定义武器
category: 巧思案例
tags:
- experimental
- 实验性
mentions:
- SirLich
- solvedDev
@@ -13,49 +13,52 @@ mentions:
- Xterionix
---
Making a custom weapon is pretty simple since the 1.16.100 changes, as these allow you to simply define an item entry for it in your `BP/items` folder and provide a corresponding texture in the `RP/textures/items` folder with a bit of config and you have a fully working weapon that you can customize however you see fit.
# 自定义武器
## Custom Sword Item
<!--@include: @/wiki/bedrock-wiki-mirror.md-->
Like with the other item tutorials we will start by making a simple custom sword like so.
自1.16.100版本更新以来,制作自定义武器变得非常简单。您只需在`BP/items`文件夹中定义物品条目,并在`RP/textures/items`文件夹中提供相应纹理,稍作配置即可获得功能完整的可定制武器。
<CodeHeader>BP/items/my_sword.json</CodeHeader>
## 自定义剑类物品
```json
与其他物品教程类似,我们先从制作基础剑类物品开始。
::: code-group
```json [BP/items/my_sword.json]
{
"format_version": "1.16.100",
"minecraft:item": {
"description": {
"identifier": "wiki:my_sword",
// Notice we give it the equipment category
// 注意我们将其归类为装备
"category": "equipment"
},
"components": {
// This allows us to have the sword in the creative category of swords
// 这样可以将剑放置在创造模式下的剑类物品栏中
"minecraft:creative_category": {
"parent": "itemGroup.name.sword"
},
"minecraft:max_stack_size": 1,
// This is a new change as we want it to be equippable in the hand
// 新增配置使物品可手持
"minecraft:hand_equipped": true,
"minecraft:durability": {
"max_durability": 600
},
// Give it however much damage you want
// 按需设置伤害值
"minecraft:damage": 10,
// We also let it be enchantable in the "sword" slot
// 允许在"sword"槽位附魔
"minecraft:enchantable": {
"value": 10,
"slot": "sword"
},
// This texture is used for both inventory and the hand model
// 该纹理同时用于物品栏和手持模型
"minecraft:icon": {
"texture": "my_sword"
},
"minecraft:display_name": {
"value": "My Custom Sword"
"value": "我的自定义剑"
},
// Allow the sword to be repaired with sticks
// 允许使用木棍修复
"minecraft:repairable": {
"repair_items": [
{
@@ -69,50 +72,44 @@ Like with the other item tutorials we will start by making a simple custom sword
}
```
So at a bare minimum that is enough to get a sword put into the game, we still need to register the icon with the RP but thats not a massive issue as all we need to do is go to our RP folder and enter it in like so.
<CodeHeader>RP/textures/item_texture.json</CodeHeader>
```json
```json [RP/textures/item_texture.json]
{
"resource_pack_name": "vanilla",
"texture_name": "atlas.items",
"texture_data": {
"my_sword": {
// Make sure you have put an icon texture called my_sword.png here
// 确保已添加名为my_sword.png的纹理
"textures": "textures/items/my_sword"
}
}
}
```
:::
Here is an example texture if you do not have your own to use, just `Save As` and plop it in the `RP/textures/items` directory.
若需示例纹理,可将下方图片另存为`my_sword.png`并放入`RP/textures/items`目录。
![](/assets/images/tutorials/custom-weapons/my_sword.png)
<BButton link="https://raw.githubusercontent.com/Bedrock-OSS/bedrock-wiki/wiki/docs/public/assets/images/tutorials/custom-weapons/my_sword.png">Download texture here</BButton>
<BButton link="https://raw.githubusercontent.com/Bedrock-OSS/bedrock-wiki/wiki/docs/public/assets/images/tutorials/custom-weapons/my_sword.png">点击此处下载纹理</BButton>
## In-game
## 游戏内效果
So now we have a BP containing our items json data and an RP containing the texture, we can make a new level, and make sure we include our BP/RP, however we **also need to enable the Holiday Creator Features** under experimental gameplay.
完成BP物品配置和RP纹理添加后创建新世界时需加载这两个包并**在实验性玩法中启用假日创作者功能**。
Once you have done all the above, go into creative mode and you should be able to find your sword by its name, or under the sword category as shown.
进入创造模式后,可通过名称搜索或剑类物品栏找到您的自定义武器。
![](/assets/images/tutorials/custom-weapons/custom_sword.jpg)
Then if you put it in your hands you should see it in the game like this.
手持时效果如下:
![](/assets/images/tutorials/custom-weapons/held_sword.jpg)
Now that wasn't too hard was it! and you can make as many custom swords as you want now, however there is far more fun stuff you can do from here if you feel up for it.
## 工具类功能扩展
## Tool-like Functionality
可通过添加`minecraft:digger`等组件实现特殊挖掘功能:
You can also mix and match other components like `minecraft:digger` to allow you to go through web or bamboo quicker like this:
<CodeHeader>BP/items/my_sword.json#components</CodeHeader>
```json
::: code-group
```json [BP/items/my_sword.json#components]
"minecraft:digger": {
"use_efficiency": true,
"destroy_speeds": [
@@ -127,51 +124,36 @@ You can also mix and match other components like `minecraft:digger` to allow you
],
"on_dig":{
"event": "wiki:my_sword.on_dig_damage"
//Needed to change sword durability
// 用于改变武器耐久度
}
}
```
Also add an event:
<CodeHeader>BP/items/my_sword.json</CodeHeader>
```json
```json [BP/items/my_sword.json]
"events": {
"wiki:my_sword.on_dig_damage": {
"damage":{
//This part of event will make sword take damage when it was used to dig block
// 该事件会使武器在挖掘时损耗耐久
"type":"durability",
"target":"self",
//By using "self" you define item as target to take damage
// 使用"self"指定物品自身承受损耗
"amount":1
}
}
}
```
:::
You can also give it a default mining speed by adding `"minecraft:mining_speed": 1.5`, which would give it a generic mining speed letting you use your weapon like a pickaxe.
(It is currently broken)
## 伤害数值显示
## Damage Tooltip
添加`"minecraft:weapon": {}`组件可在物品提示中显示攻击伤害值。
The above was a bare bones approach, but you probably want to be able to show the damage a sword does when the user hovers over it.
## 特殊能力与耐久系统
To do this you need to add the `"minecraft:weapon": {}` component, even if its just empty this is enough to MC to know internally to treat your popup like a weapon popup when mouse over-ing.
通过武器组件触发事件实现特殊效果:
So if you add the above component to your item json file when you mouse over your sword you will now see **+10 Attack Damage** listed in its tooltip.
> You may be thinking "why didn't you just add this above?" and the answer is because we will build off this component to add more cool stuff in the next section, so I wanted to keep it separate.
## Unique ability & durability
At this point you could call it a day, but what if you wanted to make a sword that could inflict status effects, or teleport an enemy when they attacked you?
Assuming you wanted to do something like this we will need to build off the `minecraft:weapon` component and raise an event when the weapon hits an entity.
<CodeHeader>BP/items/my_sword.json#components</CodeHeader>
```json
::: code-group
```json [BP/items/my_sword.json#components]
"minecraft:weapon": {
"on_hurt_entity": {
"event": "wiki:my_sword.hurt_entity"
@@ -179,49 +161,35 @@ Assuming you wanted to do something like this we will need to build off the `min
}
```
Once we add that then every time you hurt an entity it will raise the event `wiki:my_sword.hurt_entity`. You can name this whatever you want, but if you end up with lots of events its recommended to have some level of namespacing, so in this scenario `example` is my main namespace, `my_sword` is the item I want it to apply on and `hurt_entity` is the related event on that item.
> I could just as easily call the event **"space-noodle"** and it would work fine, but you want it to be easily searchable and self explaining, so keep that in mind
Now that we have an event being raised we can do what we want with it. In this example I am going to do 3 things:
1. Teleport the player with 25% chance.
2. Output a message letting the player know that something happened.
3. Damage the sword.
So if you go back into your my_sword.json and after your `components` section add a new section like so.
<CodeHeader>BP/items/my_sword.json</CodeHeader>
```json
```json [BP/items/my_sword.json]
"events": {
"wiki:my_sword.hurt_entity": {
"sequence":[
//Sequence is needed to run two or more parts of event
{
"randomize": [
{
// Weights are relative, so this has 1
// 权重值为1
"weight": 1,
// Teleport the HOLDER (you) within an 8x8x8 range
// 在8x8x8范围内传送持有者
"teleport": {
"target": "holder",
"max_range": [8,8,8]
},
// Then tell some green text
// 显示提示文本
"run_command":{
"command":[
"tellraw @s{\"rawtext\":[{\"text\":\"§aYour Sword Glows§r\"}]}"
"tellraw @s{\"rawtext\":[{\"text\":\"§a剑身发出光芒§r\"}]}"
]
}
},
{
// We have another dummy random element here which contains the max weight
// 占位权重值
"weight": 3
}
]
},
{
// I think you haven't forgot what this do
// 损耗武器耐久度
"damage":{
"type":"durability",
"target":"self",
@@ -232,20 +200,12 @@ So if you go back into your my_sword.json and after your `components` section ad
}
}
```
:::
That was a bit to bite off, but as explained above this lets us randomly **1/4** of the time trigger a teleportation of the sword holder and show a text command when it happens.
## 合成配方示例
You can do whatever you want here and get super creative, set enemies on fire, or spawn enemies or blocks etc. There is so much you can do with this basic approach to creating weapons!
> It's worth noting here that the dummy element is needed to scale the weightings, so we have one element with a weight of **1** and a 2nd one with a weight of **4** so this gives us the **1 in 4** chance of it proccing. If we were to have gone with the dummy element having a weight of **100** then we would have a **1 in 100** chance of proccing. If we didn't have a 2nd dummy element then the first weight would be ignored and it would happen 100% of the time.
## Anything Else?
You should probably make a recipe for it, which is covered in previous chapters, as there isn't anything really new in there, but incase you are unsure here is an example one to make the sword with ender eyes and ender pearls.
<CodeHeader>BP/recipes/my_sword.json</CodeHeader>
```json
::: code-group
```json [BP/recipes/my_sword.json]
{
"format_version": "1.12.0",
"minecraft:recipe_shaped": {
@@ -271,7 +231,8 @@ You should probably make a recipe for it, which is covered in previous chapters,
}
}
```
:::
![](/assets/images/tutorials/custom-weapons/sword_recipe.jpg)
If you whack that in then you can now craft your sword in the game and hopefully go off and make any other custom swords you fancy or even bows or tridents.
现在您已掌握制作自定义武器的基本方法,可以尝试扩展更多创意功能!

View File

@@ -1,6 +1,6 @@
---
title: Enchantments
category: Documentation
title: 附魔
category: 文档
nav_order: 5
tags:
- Stable
@@ -11,44 +11,49 @@ mentions:
- SmokeyStack
---
Enchantment identifiers are used in the `/enchant` command and in item functions and conditions.
# 附魔
| Name | Identifier | Maximum Level | Treasure | Curse |
| ----------------------- | ----------------------- | ------------- | -------- | ----- |
| Silk Touch | `silk_touch` | 1 | ❌ | ❌ |
| Fortune | `fortune` | 3 | ❌ | ❌ |
| Efficiency | `efficiency` | 5 | ❌ | ❌ |
| Luck of the Sea | `luck_of_the_sea` | 3 | ❌ | ❌ |
| Lure | `lure` | 3 | ❌ | ❌ |
| Sharpness | `sharpness` | 5 | ❌ | |
| Smite | `smite` | 5 | ❌ | ❌ |
| Bane of Arthropods | `bane_of_arthropods` | 5 | ❌ | |
| Fire Aspect | `fire_aspect` | 2 | ❌ | |
| Knockback | `knockback` | 2 | ❌ | |
| Looting | `looting` | 3 | ❌ | |
| Power | `power` | 5 | ❌ | |
| Flame | `flame` | 1 | ❌ | ❌ |
| Punch | `punch` | 2 | ❌ | |
| Infinity | `infinity` | 1 | ❌ | |
| Multishot | `multishot` | 1 | ❌ | |
| Piercing | `piercing` | 4 | ❌ | |
| Quick Charge | `quick_charge` | 3 | ❌ | |
| Impaling | `impaling` | 5 | ❌ | |
| Riptide | `riptide` | 3 | ❌ | |
| Loyalty | `loyalty` | 3 | ❌ | |
| Channeling | `channeling` | 1 | ❌ | |
| Protection | `protection` | 4 | ❌ | |
| Projectile Protection | `projectile_protection` | 4 | ❌ | |
| Fire Protection | `fire_protection` | 4 | ❌ | |
| Blast Protection | `blast_protection` | 4 | ❌ | |
| Feather Falling | `feather_falling` | 4 | ❌ | |
| Thorns | `thorns` | 3 | ❌ | ❌ |
| Frost Walker | `frost_walker` | 2 | | |
| Respiration | `respiration` | 3 | ❌ | ❌ |
| Aqua Affinity | `aqua_affinity` | 1 | ❌ | |
| Curse of Binding | `curse_of_binding` | 1 | | |
| Depth Strider | `depth_strider` | 3 | ❌ | ❌ |
| Soul Speed | `soul_speed` | 3 | | |
| Unbreaking | `unbreaking` | 3 | ❌ | ❌ |
| Mending | `mending` | 1 | ✅ | ❌ |
| Curse of Vanishing | `curse_of_vanishing` | 1 | | |
<!--@include: @/wiki/bedrock-wiki-mirror.md-->
附魔标识符用于`/enchant`命令以及物品函数和条件判断中。
| 附魔名称 | 标识符 | 最高等级 | 宝藏附魔 | 诅咒附魔 |
| -------------------------- | ------------------- | -------- | -------- | -------- |
| 精准采集 | `silk_touch` | 1 | | ❌ |
| 时运 | `fortune` | 3 | ❌ | |
| 效率 | `efficiency` | 5 | ❌ | ❌ |
| 海之眷顾 | `luck_of_the_sea` | 3 | ❌ | |
| 饵钓 | `lure` | 3 | ❌ | |
| 锋利 | `sharpness` | 5 | ❌ | |
| 亡灵杀手 | `smite` | 5 | ❌ | |
| 节肢杀手 | `bane_of_arthropods`| 5 | ❌ | |
| 火焰附加 | `fire_aspect` | 2 | | ❌ |
| 击退 | `knockback` | 2 | ❌ | |
| 抢夺 | `looting` | 3 | ❌ | |
| 力量 | `power` | 5 | ❌ | |
| 火矢 | `flame` | 1 | ❌ | |
| 冲击 | `punch` | 2 | ❌ | |
| 无限 | `infinity` | 1 | ❌ | |
| 多重射击 | `multishot` | 1 | ❌ | |
| 穿透 | `piercing` | 4 | ❌ | |
| 快速装填 | `quick_charge` | 3 | ❌ | |
| 穿刺 | `impaling` | 5 | ❌ | |
| 激流 | `riptide` | 3 | ❌ | |
| 忠诚 | `loyalty` | 3 | ❌ | |
| 引雷 | `channeling` | 1 | ❌ | |
| 保护 | `protection` | 4 | ❌ | |
| 弹射物保护 | `projectile_protection`| 4 | | ❌ |
| 火焰保护 | `fire_protection` | 4 | | |
| 爆炸保护 | `blast_protection` | 4 | | ❌ |
| 摔落缓冲 | `feather_falling` | 4 | ❌ | |
| 荆棘 | `thorns` | 3 | | |
| 冰霜行者 | `frost_walker` | 2 | | ❌ |
| 水下呼吸 | `respiration` | 3 | | |
| 水下速掘 | `aqua_affinity` | 1 | | ❌ |
| 绑定诅咒 | `curse_of_binding` | 1 | | |
| 深海探索者 | `depth_strider` | 3 | ❌ | |
| 灵魂疾行 | `soul_speed` | 3 | ✅ | ❌ |
| 耐久 | `unbreaking` | 3 | ❌ | ❌ |
| 经验修补 | `mending` | 1 | ✅ | ❌ |
| 消失诅咒 | `curse_of_vanishing`| 1 | ✅ | ✅ |
:::

View File

@@ -1,9 +1,9 @@
---
title: Run Commands with Equipped Items
category: Tutorials
title: 通过装备物品运行命令
category: 巧思案例
tags:
- experimental
- intermediate
- 实验性
- 中级
mentions:
- Chikorita-Lover
- MedicalJewel105
@@ -11,23 +11,26 @@ mentions:
- TheItsNameless
---
## Introduction
# 通过装备物品运行命令
A common concept for add-ons is implementing new armor sets with unique effects, just like the turtle shell and netherite armor. While items have a knockback resistance component, they don't have a component for inflicting mob effects, emitting particles, etc. under certain conditions. However, using server animations, Molang and item tags, this can easily be done!
<!--@include: @/wiki/bedrock-wiki-mirror.md-->
Keep in mind that this requires modifying the player behavior, which is a common theme for many add-ons; thus, your add-on may not be compatible with others if you wish to do this.
## 简介
> However some people found a way not to use player.json. They replace it with dummy entity-rider. Try experimenting yourself!
附加组件开发中常见的需求是为新盔甲套装添加独特效果就像海龟壳和下界合金盔甲那样。虽然物品本身具有击退抗性组件但它们并没有在特定条件下施加生物效果、生成粒子等功能的原生组件。不过通过服务器动画、Molang查询和物品标签我们可以轻松实现这些效果
The use of Holiday Creator Features is also required to add item tags and easily equip our item in armor or off-hand slots.
请注意,此方法需要修改玩家行为文件,这是许多附加组件的常见操作。因此如果使用此方法,你的附加包可能会与其他修改玩家行为的附加包产生兼容性问题。
## Server Animation
> 有开发者发现可以通过实体骑乘机制替代直接修改玩家行为文件的方法。建议自行实验探索!
The first step will be to create a server animation, which is a file that runs commands or events at certain keyframes. While client animations are in the resource pack, server animations are in the behavior pack. You can read a bit more [here](/entities/timers#animation-based-timers). We can start by using the following as a template:
本教程需要使用假日创作者功能来添加物品标签,并方便地在盔甲栏或副手槽位装备物品。
<CodeHeader>BP/animations/player.json</CodeHeader>
## 服务器动画
```json
第一步是创建服务器动画文件,这种文件可以在特定关键帧执行命令或触发事件。客户端动画存放在资源包中,而服务器动画则位于行为包内。更多信息可参阅[基于动画的计时器](/wiki/entities/timers#animation-based-timers)。以下模板可供参考:
::: code-group
```json [BP/animations/player.json]
{
"format_version": "1.10.0",
"animations": {
@@ -41,58 +44,54 @@ The first step will be to create a server animation, which is a file that runs c
}
}
```
:::
Let's go over what's in this template and what everything does:
模板参数解析:
- `animation.player.emerald_armor` is our animation's identifier; you can change this to something else, such as `animation.player.phantom_armor`.
- `timeline` runs commands and events at given keyframes.
- `animation_length` is how long the animation lasts; we'll use 0.05 seconds, as that's the length of an in-game tick.
- `loop` is quite straight-forward; setting it to true makes the animation loop.
- `animation.player.emerald_armor` 是动画标识符,可自定义如`animation.player.phantom_armor`
- `timeline` 用于在指定时间点执行命令/事件
- `animation_length` 设置动画时长0.05秒即1游戏刻
- `loop` 控制是否循环播放
We can add commands to the `0.0` array in our timeline to execute, such as an `/effect` command, like such:
在时间轴中添加命令示例:
<CodeHeader>BP/animations/player.json#timeline</CodeHeader>
```json
::: code-group
```json [BP/animations/player.json#timeline]
{
"0.0": [
"/effect @s speed 1 0"
]
}
```
:::
We're not limited to `/effect`, of course. If you want to use some other command, such as `/function` or `/particle`, go right ahead!
除了`/effect`,也可以使用`/function`、`/particle`等其他命令。完成服务器动画配置后,接下来需要设置物品行为。
After this, we're finished in our server animation, and we'll head into the behavior file for our item for a quick addition.
## 物品行为
## Item Behavior
为了检测装备状态我们需要使用Molang查询配合物品标签。以下情况可跳过本节
To actually check if our item is equipped, we can use a Molang query that checks for item tags.
- 检测原版物品(如通过`minecraft:iron_tier`标签检测铁质盔甲)
- 使用`q.is_item_name_any`通过物品ID检测
You can skip this section if:
添加标签组件示例:
- You want check for a vanilla item instead, such as an iron armor piece through the `minecraft:iron_tier` tag
- You want to check for the item via `q.is_item_name_any`, which checks for an item identifier in any slot
In our item's behavior, we'll have to add a tag to `components`. For example, if we wanted to add the `example:emerald_tier` tag, we would add the `tag:example:emerald_tier` component:
<CodeHeader>BP/items/my_item.json#components</CodeHeader>
```json
::: code-group
```json [BP/items/my_item.json#components]
"tag:example:emerald_tier": {}
```
:::
That's it, now your item has whatever tag you assigned it! You can add more tags if you want, but this is all we need for what we're doing.
至此物品已拥有指定标签,可根据需要添加多个标签。
## Player Behavior
## 玩家行为
Finally, we need to modify the player's behavior to run the server animation. We'll be working entirely within `description`.
最后需要修改玩家行为文件来触发动画。主要操作在`description`部分完成。
First, we need to set a short name for our animation. If you have any experience with client animations, this process will be quite similar. Add `animations` to `description`, and set a short name, like such:
首先为动画设置简称:
<CodeHeader>BP/entities/player.json#description</CodeHeader>
```json
::: code-group
```json [BP/entities/player.json#description]
{
"identifier": "minecraft:player",
"is_spawnable": false,
@@ -103,31 +102,31 @@ First, we need to set a short name for our animation. If you have any experience
}
}
```
:::
Now with a short name set, we can run our animation.
接着在`scripts`中添加Molang条件检测
Add `scripts` to `description`, and set a Molang query to run. To check for the item, we can use one of the following:
检测方式选择:
- `q.is_item_name_any`, to check for a given item identifier in any slot. This example will check for `example:totem_of_retreat` in either hand:
- `q.is_item_name_any` 检测指定ID物品示例检测双手是否持有图腾
```
q.is_item_name_any('slot.weapon.mainhand',0,'example:totem_of_retreat') || q.is_item_name_any('slot.weapon.offhand',0,'example:totem_of_retreat')
```
- `q.equipped_item_any_tag`, to check for at least one of any given tag in a given slot. This example will allow an emerald- or phantom- tier armor piece to be used:
- `q.equipped_item_any_tag` 检测单标签存在(示例检测头部护甲标签):
```
q.equipped_item_any_tag('slot.armor.head','example:emerald_tier','example:phantom_tier')
```
- `q.equipped_item_all_tags`, to check for all given tags in a given slot. This example will only allow an armor piece that's both emerald- and ancient- tier:
- `q.equipped_item_all_tags` 检测多标签共存:
```
q.equipped_item_all_tags('slot.armor.head','example:ancient_tier','example:emerald_tier')
```
Let's take a look at an example using `q.equipped_item_any_tag`:
应用示例:
<CodeHeader>BP/entities/player.json#description</CodeHeader>
```json
::: code-group
```json [BP/entities/player.json#description]
{
"identifier": "minecraft:player",
"is_spawnable": false,
@@ -145,54 +144,52 @@ Let's take a look at an example using `q.equipped_item_any_tag`:
}
}
```
:::
This example will run a server animation with the `emerald_armor` short name if an emerald-tier item is equipped in the helmet slot. You can change the Molang field to match your item tag, use a different query, or add additional queries.
此配置会在玩家头部装备翡翠标签物品时触发动画。更多装备槽位标识符请参考[Minecraft Wiki](https://minecraft.wiki/w/Slot#Bedrock_Edition)。
You can view a list of additional slot identifiers at the [Minecraft Wiki](https://minecraft.wiki/w/Slot#Bedrock_Edition).
## 总结
## Conclusion
完成服务器动画、玩家行为和物品标签的配置后,装备特定物品即可执行自定义命令!此技术突破了物品组件的限制,为物品定制提供了更多可能性。如需扩展功能,请参考以下附加内容。
With the server animation, player behavior, and item tag all set up, your equipped item can now run commands! This technique allows for greater item customization than being restricted to item components. If you want to add more to the effect or add-on, check the next section; otherwise, congratulations, you're finished!
## 扩展应用
## Additions
### 多件套装检测
### Multiple Required Items
检测全套装备示例:
If you want to run a command when multiple of the armor set's pieces are equipped, we can expand our Molang from before:
<CodeHeader>BP/entities/player.json#scripts</CodeHeader>
```json
::: code-group
```json [BP/entities/player.json#scripts]
"animate": [
{
"emerald_armor": "q.equipped_item_any_tag('slot.armor.head','example:emerald_tier') && q.equipped_item_any_tag('slot.armor.chest','example:emerald_tier') && q.equipped_item_any_tag('slot.armor.legs','example:emerald_tier') && q.equipped_item_any_tag('slot.armor.feet','example:emerald_tier')"
}
]
```
:::
This example will check for emerald-tier armor in all four armor slots, and run the animation if they're all equipped.
当四件护甲都具备指定标签时触发效果。
### Further Conditions
### 复合条件判断
The turtle shell doesn't always inflict Water Breathing, but instead only for 10 seconds when a player first enters water. If we want our emerald armor to only run our animation when we have lower health, we can add another query to our Molang:
仿照海龟壳的水下呼吸机制,添加血量条件:
<CodeHeader>BP/entities/player.json#scripts</CodeHeader>
```json
::: code-group
```json [BP/entities/player.json#scripts]
"animate": [
{
"emerald_armor": "q.equipped_item_any_tag('slot.armor.head','example:emerald_tier') && q.health <= 5"
}
]
```
:::
This example will run the animation with 2.5 hearts or less remaining, allowing players to make a quick getaway when they're in danger.
当玩家生命值≤2.5心时触发逃生效果。
We can also apply this to requiring multiple armor pieces, with even longer Molang:
复合条件示例:
<CodeHeader>BP/entities/player.json#scripts</CodeHeader>
```json
::: code-group
```json [BP/entities/player.json#scripts]
{
"animate": [
{
@@ -201,16 +198,16 @@ We can also apply this to requiring multiple armor pieces, with even longer Mola
]
}
```
:::
You can view a list of documented Molang queries at [bedrock.dev](https://bedrock.dev/docs/stable/Molang#List%20of%20Entity%20Queries).
完整Molang查询列表详见[bedrock.dev](https://bedrock.dev/docs/stable/Molang#List%20of%20Entity%20Queries)。
### Multiple Items with Effects
### 多物品系统
If you want to add more items with unique effects, fret not; this is easily done. You can either create a new server animation file, or add on to the file from before, like such:
添加新物品效果时,可扩展动画文件:
<CodeHeader>BP/animations/player.json</CodeHeader>
```json
::: code-group
```json [BP/animations/player.json]
{
"format_version": "1.10.0",
"animations": {
@@ -231,12 +228,12 @@ If you want to add more items with unique effects, fret not; this is easily done
}
}
```
:::
In our player behavior, you'll have to add on to `animations` and `scripts` as well.
同步更新玩家行为文件:
<CodeHeader>BP/entities/player.json#description</CodeHeader>
```json
::: code-group
```json [BP/entities/player.json#description]
{
"identifier": "minecraft:player",
"is_spawnable": false,
@@ -258,3 +255,4 @@ In our player behavior, you'll have to add on to `animations` and `scripts` as w
}
}
```
:::

View File

@@ -1,10 +1,10 @@
---
title: Items
title: 物品 Items
categories:
- title: General
- title: 基础
color: blue
- title: Tutorials
- title: 巧思案例
color: green
- title: Documentation
- title: 文档
color: red
---

View File

@@ -1,24 +1,27 @@
---
title: Item Components
description: Item components are used to change how your item appears and functions in the world.
category: General
title: 物品组件
description: 物品组件用于改变物品在游戏中的外观和功能。
category: 基础
nav_order: 2
mentions:
- SmokeyStack
- QuazChick
---
:::tip FORMAT & MIN ENGINE VERSION `1.20.50`
Using the latest format version when creating custom items provides access to fresh features and improvements. The wiki aims to share up-to-date information about custom items, and currently targets format version `1.20.50`.
# 物品组件
<!--@include: @/wiki/bedrock-wiki-mirror.md-->
:::tip 格式版本 & 最低引擎版本 `1.20.50`
创建自定义物品时使用最新格式版本可获得最新功能和改进。本wiki旨在分享自定义物品的最新信息当前目标格式版本为`1.20.50`
:::
## Applying Components
## 应用组件
Item components are used to change how your item appears and functions in the world. They are applied in the `components` child of `minecraft:item`.
物品组件用于修改物品在游戏中的外观和功能。这些组件应添加在`minecraft:item``components`子项中。
<CodeHeader>BP/items/custom_item.json</CodeHeader>
```json
::: code-group
```json [BP/items/custom_item.json]
{
"format_version": "1.20.50",
"minecraft:item": {
@@ -36,26 +39,26 @@ Item components are used to change how your item appears and functions in the wo
}
}
```
:::
## Allow Off Hand
## 允许副手
Determines whether an item can be placed in the off-hand slot of the inventory.
决定物品是否可以放入物品栏的副手槽位。
<CodeHeader>minecraft:item > components</CodeHeader>
```json
::: code-group
```json [minecraft:item > components]
"minecraft:allow_off_hand": {
"value": true
}
```
:::
## Block Placer
## 方块放置器
Sets the item as a Planter item component for blocks. Items with this component will place a block when used.
将物品设置为可放置方块的种植者组件。具有此组件的物品在使用时会放置指定方块。
<CodeHeader>minecraft:item > components</CodeHeader>
```json
::: code-group
```json [minecraft:item > components]
"minecraft:block_placer":{
"block": "seeds",
"use_on": [
@@ -64,95 +67,95 @@ Sets the item as a Planter item component for blocks. Items with this component
]
}
```
:::
## Can Destroy In Creative
## 创造模式可破坏
Determines if an item will break blocks in Creative Mode while swinging.
决定在创造模式下挥动物品时是否会破坏方块。
<CodeHeader>minecraft:item > components</CodeHeader>
```json
::: code-group
```json [minecraft:item > components]
"minecraft:can_destroy_in_creative": {
"value": true
}
```
:::
## Cooldown
## 冷却时间
Sets an items "Cool down" time. After using an item, it becomes unusable for the duration specified by the 'duration' setting of this component.
设置物品的冷却时间。使用物品后,在组件指定的'duration'持续时间内无法再次使用。
<CodeHeader>minecraft:item > components</CodeHeader>
```json
::: code-group
```json [minecraft:item > components]
"minecraft:cooldown":{
"category" : "attack",
"duration" : 0.2
}
```
:::
## Damage
## 伤害值
Determines how much extra damage an item does on attack.
决定物品攻击时造成的额外伤害量。
<CodeHeader>minecraft:item > components</CodeHeader>
```json
::: code-group
```json [minecraft:item > components]
"minecraft:damage": {
"value": 10
}
```
:::
## Digger
## 挖掘工具
Allows a creator to determine how quickly an item can dig specific blocks.
允许创作者设定物品挖掘特定方块的速度。
<CodeHeader>minecraft:item > components</CodeHeader>
```json
::: code-group
```json [minecraft:item > components]
"minecraft:digger": {
"use_efficiency": true,
"destroy_speeds": [
{
"block": {
"tags": "q.any_tag('stone', 'metal')" // Note that not all blocks have tags; listing many blocks may be necessary
"tags": "q.any_tag('stone', 'metal')" // 注意并非所有方块都有标签,可能需要列举多个方块
},
"speed": 6
}
]
}
```
:::
## Display Name
## 显示名称
Sets the item display name within Minecraft: Bedrock Edition. This component may also be used to pull from the localization file by referencing a key from it.
设置物品在Minecraft基岩版中的显示名称。此组件也可通过引用本地化文件中的键值来获取名称。
### Example
### 示例
<CodeHeader>minecraft:item > components</CodeHeader>
```json
::: code-group
```json [minecraft:item > components]
"minecraft:display_name":{
"value": "secret_weapon"
}
```
:::
### Example Using Localization Key
### 使用本地化键示例
<CodeHeader>minecraft:item > components</CodeHeader>
```json
::: code-group
```json [minecraft:item > components]
"minecraft:display_name":{
"value": "item.snowball.name"
}
```
:::
## Durability
## 耐久度
Sets how much damage the item can take before breaking, and allows the item to be combined at an anvil, grindstone, or crafting table.
设置物品在损坏前可承受的伤害量,并允许物品在铁砧、砂轮或工作台进行修复。
<CodeHeader>minecraft:item > components</CodeHeader>
```json
::: code-group
```json [minecraft:item > components]
"minecraft:durability":{
"damage_chance": {
"min": 10,
@@ -161,24 +164,25 @@ Sets how much damage the item can take before breaking, and allows the item to b
"max_durability": 36
}
```
:::
## Enchantable
## 可附魔
Determines what enchantments can be applied to the item. Not all enchantments will have an effect on all item components.
决定可应用于物品的附魔类型。并非所有附魔都会对所有物品组件生效。
<CodeHeader>minecraft:item > components</CodeHeader>
```json
::: code-group
```json [minecraft:item > components]
"minecraft:enchantable": {
"slot": "bow",
"value": 10
}
```
:::
### Enchantable Slots
Note: The "all" enchantable slot allows you to apply any enchantment that you want to the item, just like an enchanted book.
### 可附魔槽位
注意:"all"槽位允许像附魔书一样应用任何附魔
| Slot Name |
| 槽位名称 |
| ------------- |
| armor_feet |
| armor_torso |
@@ -199,32 +203,30 @@ Note: The "all" enchantable slot allows you to apply any enchantment that you wa
| sword |
| all |
## 实体放置器
## Entity Placer
允许物品在世界中放置实体。在1.19.80及以上版本中,此组件还可设置刷怪笼生成的生物类型。
Allows an item to place entities into the world. Additionally, in version 1.19.80 and above, the component allows the item to set the spawn type of a monster spawner.
<CodeHeader>minecraft:item > components</CodeHeader>
```json
::: code-group
```json [minecraft:item > components]
"minecraft:entity_placer":{
"entity": "minecraft:spider",
"dispense_on": ["minecraft:web"],
"use_on": ["minecraft:web"]
}
```
## Food
Sets the item as a food component, allowing it to be edible to the player.
:::tip
The `minecraft:food` must have the `minecraft:use_modifiers` component in order to function properly.
:::
<CodeHeader>minecraft:item > components</CodeHeader>
## 食物
```json
将物品设置为可食用组件,允许玩家食用。
:::tip
`minecraft:food`必须与`minecraft:use_modifiers`组件配合使用才能正常工作。
:::
::: code-group
```json [minecraft:item > components]
"minecraft:food":{
"can_always_eat": false,
"nutrition" : 3,
@@ -240,152 +242,152 @@ The `minecraft:food` must have the `minecraft:use_modifiers` component in order
"using_converts_to": "bowl"
}
```
:::
## Fuel
## 燃料
Allows this item to be used as fuel in a furnace to 'cook' other items.
允许此物品作为熔炉燃料用于"烹饪"其他物品。
<CodeHeader>minecraft:item > components</CodeHeader>
```json
::: code-group
```json [minecraft:item > components]
"minecraft:fuel":{
"duration": 3.0
}
```
:::
## Glint
## 附魔光效
Determines whether the item has the enchanted glint render effect on it.
决定物品是否显示附魔光效。
<CodeHeader>minecraft:item > components</CodeHeader>
```json
::: code-group
```json [minecraft:item > components]
"minecraft:glint": false
```
:::
## Hand Equipped
## 手持装备
Determines if an item is rendered like a tool while in-hand.
决定物品在手中是否像工具一样渲染。
<CodeHeader>minecraft:item > components</CodeHeader>
```json
::: code-group
```json [minecraft:item > components]
"minecraft:hand_equipped": {
"value": true
}
```
:::
## Hover Text Color
## 悬停文本颜色
Determines the color of the item name when hovering over it.
决定鼠标悬停时物品名称的显示颜色。
<CodeHeader>minecraft:item > components</CodeHeader>
```json
::: code-group
```json [minecraft:item > components]
"minecraft:hover_text_color": "green"
```
:::
## Icon
## 图标
Sets the icon item component. Determines the icon to represent the item in the UI and elsewhere.
设置物品图标组件。决定物品在UI和其他位置的显示图标。
<CodeHeader>minecraft:item > components</CodeHeader>
```json
::: code-group
```json [minecraft:item > components]
"minecraft:icon":{
"texture": "oak_slab"
}
```
:::
## Interact Button
## 交互按钮
Is a boolean or string that determines if the interact button is shown in touch controls, and what text is displayed on the button. When set to 'true', the default 'Use Item' text will be used.
布尔值或字符串,决定是否在触控界面显示交互按钮及按钮文本。设为'true'时将使用默认"使用物品"文本。
<CodeHeader>minecraft:item > components</CodeHeader>
```json
"minecraft:interact_button": "Use This Custom Item" // Can be a string or a boolean value.
::: code-group
```json [minecraft:item > components]
"minecraft:interact_button": "使用这个自定义物品" // 可以是字符串或布尔值
```
:::
## Liquid Clipped
## 液体剪切
Determines whether an item interacts with liquid blocks on use.
决定物品使用时是否与液体方块互动。
<CodeHeader>minecraft:item > components</CodeHeader>
```json
::: code-group
```json [minecraft:item > components]
"minecraft:liquid_clipped": {
"value": true
}
```
:::
## Max Stack Size
## 最大堆叠数
Determines how many of an item can be stacked together.
决定物品的最大堆叠数量。
<CodeHeader>minecraft:item > components</CodeHeader>
```json
::: code-group
```json [minecraft:item > components]
"minecraft:max_stack_size": {
"value": 64
}
```
:::
## Projectile
## 投射物
Compels the item to shoot, similarly to an arrow. Items with `minecraft:projectile` can be shot from dispensers or used as ammunition for items with the `minecraft:shooter` item component. Additionally, this component sets the entity that is spawned for items that also contain the `minecraft:throwable` component.
使物品可像箭矢一样发射。具有`minecraft:projectile`的物品可从发射器发射,或作为具有`minecraft:shooter`组件的物品的弹药。此组件也用于设置带有`minecraft:throwable`组件的物品生成的实体。
<CodeHeader>minecraft:item > components</CodeHeader>
```json
::: code-group
```json [minecraft:item > components]
"minecraft:projectile":{
"minimum_critical_power": 1.25,
"projectile_entity": "arrow"
}
```
:::
## Record
## 唱片
Used by record items to play music.
用于唱片物品播放音乐。
<CodeHeader>minecraft:item > components</CodeHeader>
```json
::: code-group
```json [minecraft:item > components]
"minecraft:record": {
"comparator_signal": 1,
"duration": 5,
"sound_event": "ambient.tame"
}
```
:::
### Sound Event
### 可用音效
Listed [here](https://learn.microsoft.com/en-us/minecraft/creator/reference/content/itemreference/examples/itemcomponents/minecraft_record?view=minecraft-bedrock-stable) are the available sounds
可用的音效列表请参考[此处](https://learn.microsoft.com/en-us/minecraft/creator/reference/content/itemreference/examples/itemcomponents/minecraft_record?view=minecraft-bedrock-stable)
## Repairable
## 可修复
Defines the items that can be used to repair a defined item, and the amount of durability each item restores upon repair. Each entry needs to define a list of strings for 'items' that can be used for the repair and an optional 'repair_amount' for how much durability is repaired.
定义可用于修复该物品的材料及每次修复恢复的耐久度。每个条目需定义可修复材料列表(items)和可选修复量(repair_amount)。
<CodeHeader>minecraft:item > components</CodeHeader>
```json
::: code-group
```json [minecraft:item > components]
"minecraft:repairable":{
"on_repaired": "minecraft:celebrate",
"repair_items": ["anvil"]
}
```
## Shooter
Compels an item to shoot projectiles, similarly to a bow or crossbow. Must have the `minecraft:use_modifiers` component in order to function properly.
:::tip
Ammunition used by `minecraft:shooter` must have the `minecraft:projectile` component in order to function properly.
:::
<CodeHeader>minecraft:item > components</CodeHeader>
## 发射器
```json
使物品可像弓或弩一样发射投射物。必须与`minecraft:use_modifiers`组件配合使用。
:::tip
`minecraft:shooter`使用的弹药必须具有`minecraft:projectile`组件才能正常工作。
:::
::: code-group
```json [minecraft:item > components]
"minecraft:shooter": {
"ammunition": [
{
@@ -400,52 +402,52 @@ Ammunition used by `minecraft:shooter` must have the `minecraft:projectile` comp
"charge_on_draw": false
}
```
:::
## Should Despawn
## 应消失
Determines if an item should despawn while floating in the world.
决定漂浮在世界的物品是否会自动消失。
<CodeHeader>minecraft:item > components</CodeHeader>
```json
::: code-group
```json [minecraft:item > components]
"minecraft:should_despawn": {
"value": true
}
```
:::
## Stacked By Data
## 按数据堆叠
Determines if the same item with different aux values can stack. Additionally, this component defines whether the item actors can merge while floating in the world.
决定具有不同辅助值的相同物品是否可以堆叠。此组件也定义漂浮物品是否可以合并。
<CodeHeader>minecraft:item > components</CodeHeader>
```json
::: code-group
```json [minecraft:item > components]
"minecraft:stacked_by_data": {
"value": true
}
```
:::
## Tags
## 标签
Determines which tags are included on a given item.
决定物品包含哪些标签。
<CodeHeader>minecraft:item > components</CodeHeader>
```json
::: code-group
```json [minecraft:item > components]
"minecraft:tags": {
"tags": [
"custom_tag"
]
}
```
:::
## Throwable
## 可投掷
Sets the throwable item component.
设置可投掷物品组件。
<CodeHeader>minecraft:item > components</CodeHeader>
```json
::: code-group
```json [minecraft:item > components]
"minecraft:throwable":{
"do_swing_animation" : false,
"launch_power_scale" : 1.0,
@@ -455,45 +457,46 @@ Sets the throwable item component.
"scale_power_by_draw_duration" : false
}
```
:::
## Use Animation
## 使用动画
Determines which animation plays when using an item.
决定使用物品时播放的动画类型。
<CodeHeader>minecraft:item > components</CodeHeader>
```json
::: code-group
```json [minecraft:item > components]
"minecraft:use_animation": "eat"
```
:::
## Use Modifiers
## 使用修饰符
Determines how long an item takes to use in combination with components such as Shooter, Throwable, or Food.
决定与ShooterThrowable或Food等组件配合使用时的物品使用时长。
<CodeHeader>minecraft:item > components</CodeHeader>
```json
::: code-group
```json [minecraft:item > components]
"minecraft:use_modifiers": {
"use_duration": 1.6,
"movement_modifier": 0.35
}
```
:::
## Wearable
## 可穿戴
Sets the wearable item component.
设置可穿戴物品组件。
<CodeHeader>minecraft:item > components</CodeHeader>
```json
::: code-group
```json [minecraft:item > components]
"minecraft:wearable":{
"dispensable" : true,
"slot": "slot.chest"
}
```
:::
### Slots
| Slot Name |
### 可用槽位
| 槽位名称 |
| -------------------- |
| slot.weapon.mainhand |
| slot.weapon.offhand |
@@ -507,4 +510,4 @@ Sets the wearable item component.
| slot.saddle |
| slot.armor |
| slot.chest |
| slot.equippable |
| slot.equippable |

View File

@@ -1,8 +1,8 @@
---
title: Vanilla Item Identifiers
category: Documentation
title: 原版物品标识符
category: 文档
tags:
- deprecated
- 已弃用
mentions:
- TheDoctor15
- Medicaljewel105
@@ -11,128 +11,131 @@ mentions:
- SmokeyStack
---
# 原版物品标识符
<!--@include: @/wiki/bedrock-wiki-mirror.md-->
:::danger
This method no longer works after 1.18.30.
该方法在 1.18.30 版本后已失效。
:::
An `identifier` is a required parameter that sits inside the description of the item's behaviour file.
It accepts Vanilla Minecraft names, like so, `<namespace>:<vanilla item>`, which will apply certain hardcoded item behaviours, depending on the identifier used.
`identifier`(标识符)是物品行为文件中必须填写的参数。它接受原版 Minecraft 的名称,格式为 `<命名空间>:<原版物品>`,这将根据使用的标识符应用某些硬编码的物品行为。
<CodeHeader>BP/items/custom_item.json#minecraft:item</CodeHeader>
```json
::: code-group
```json [BP/items/custom_item.json#minecraft:item]
"description": {
"identifier": "wiki:totem_of_undying",
"category": "items"
}
```
:::warning
Not every Vanilla Identifier and their behaviours are documented. The following list may be missing important points about the known Identifiers that do affect items.
Consider experimenting with them.
:::
## Known Identifier Effects
:::warning
并非所有原版标识符及其行为都有官方文档记录。以下列表可能遗漏了已知标识符的重要特性。
The namespace is allowed to be changed, learn more about namespaces [here](/concepts/namespaces).
建议自行实验测试。
:::
### namespace:banner
## 已知标识符效果
- The item icon and model will be changed to that of the Vanilla Banner.
允许修改命名空间,更多信息请参考[命名空间](/wiki/concepts/namespaces)。
### 命名空间:banner
- 物品图标和模型将变为原版旗帜的样式
---
### namespace:bow
### 命名空间:bow
- Adds a small increasing zoom on use, for the zoom to work it requires the item to be usable.
- 使用时会显示小幅放大效果(需要物品具有可使用属性才能生效)
---
### namespace:crossbow
### 命名空间:crossbow
- The item will be rotated horizontally on your arm.
- 物品在手臂上会保持水平旋转状态
---
### namespace:diamond
### 命名空间:diamond
- Is accepted as a valid item to change the effect given off by a Beacon.
- 可作为有效物品来更改信标发出的效果
---
### namespace:emerald
### 命名空间:emerald
- Is accepted as a valid item to change the effect given off by a Beacon.
- 可作为有效物品来更改信标发出的效果
---
### namespace:filled_map
### 命名空间:filled_map
- Will add the holding map animation.
- Can be put in a cartography table.
- 添加持地图动画
- 可放入制图台使用
---
### namespace:gold_ingot
### 命名空间:gold_ingot
- Is accepted as a valid item to change the effect given off by a Beacon.
- 可作为有效物品来更改信标发出的效果
---
### namespace:iron_ingot
### 命名空间:iron_ingot
- Is accepted as a valid item to change the effect given off by a Beacon.
- 可作为有效物品来更改信标发出的效果
---
### namespace:lapis_lazuli
### 命名空间:lapis_lazuli
- Makes the Item usable with Enchantment Tables, to enchant your items in place of Lapis Lazuli.
- 可在附魔台中替代青金石用于物品附魔
---
### namespace:lead
### 命名空间:lead
- Will behave like a Lead.
- 具备拴绳的牵引功能
---
### namespace:map
### 命名空间:map
- Will use the holding map animation.
- 使用持地图动画
---
### namespace:netherite_ingot
### 命名空间:netherite_ingot
- Is accepted in custom Smithing Recipes as the secondary item.
- Is accepted as a valid item to change the effect given off by a Beacon.
- 可作为锻造台配方中的次级材料
- 可作为有效物品来更改信标发出的效果
---
### namespace:shield
### 命名空间:shield
- The item icon will be permanently changed to that of the Vanilla Shield.
- Adds the shield animation and behavior.
- 物品图标将永久变为原版盾牌样式
- 添加盾牌动画和格挡功能
---
### namespace:spyglass
### 命名空间:spyglass
- Makes it zoom-able like a spyglass, for the zoom to work it requires the item to be usable.
- 具备望远镜缩放功能(需要物品具有可使用属性才能生效)
---
### namespace:skull
### 命名空间:skull
- The item icon will be changed to that of the Vanilla Skull.
- The item will be able to put on a armorstand and a player, the model and textures of the skull will be applied only then.
- 物品图标将变为原版头颅样式
- 可放置在盔甲架和玩家头部,此时会应用头颅的模型和材质
---
### namespace:totem_of_undying
### 命名空间:totem_of_undying
- Will behave like a Totem of Undying.
- 具备不死图腾的复活功能
---
---

View File

@@ -1,21 +1,24 @@
---
title: Item Tags
category: General
title: 物品标签
category: 基础
nav_order: 3
mentions:
- Xterionix
- SmokeyStack
---
Item tags can be used to ensure that a item meets certain conditions.
# 物品标签
## Applying Tags
<!--@include: @/wiki/bedrock-wiki-mirror.md-->
### From 1.20.50 and onwards
物品标签可用于确保某个物品符合特定条件。
<CodeHeader></CodeHeader>
## 标签应用
```json
### 1.20.50 及以后版本
::: code-group
```json [1.20.50+]
{
"format_version": "1.20.50",
"minecraft:item": {
@@ -32,12 +35,12 @@ Item tags can be used to ensure that a item meets certain conditions.
}
}
```
:::
### Before 1.20.50
### 1.20.50 之前版本
<CodeHeader></CodeHeader>
```json
::: code-group
```json [1.20.50-]
{
"format_version": "1.16.100",
"minecraft:item": {
@@ -50,22 +53,23 @@ Item tags can be used to ensure that a item meets certain conditions.
}
}
```
:::
## Testing for Tags
## 标签检测
Tags can be queried with:
可通过以下方式查询标签:
- `q.all_tags`
- `q.any_tag`
- `q.equipped_item_all_tags`
- `q.equipped_item_any_tag`
## Lists of Vanilla Item Tags
## 原版物品标签列表
Vanilla tags can be applied to custom items, and some vanilla items are tagged internally.
原版标签可应用于自定义物品,部分原版物品已内置标签。
| Tag | Items |
|------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| 标签 | 对应物品 |
|------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| minecraft:arrow | minecraft:arrow |
| minecraft:banner | minecraft:banner |
| minecraft:boat | minecraft:birch_boat, minecraft:bamboo_raft, minecraft:cherry_chest_boat, minecraft:mangrove_boat, minecraft:bamboo_chest_raft, minecraft:jungle_chest_boat, minecraft:oak_boat, minecraft:oak_chest_boat, minecraft:dark_oak_chest_boat, minecraft:cherry_boat, minecraft:mangrove_chest_boat, minecraft:acacia_boat, minecraft:acacia_chest_boat, minecraft:jungle_boat, minecraft:spruce_chest_boat, minecraft:dark_oak_boat, minecraft:boat, minecraft:spruce_boat, minecraft:birch_chest_boat, minecraft:chest_boat |
@@ -122,4 +126,4 @@ Vanilla tags can be applied to custom items, and some vanilla items are tagged i
| minecraft:warped_stems | minecraft:warped_stem, minecraft:stripped_warped_stem, minecraft:warped_hyphae, minecraft:stripped_warped_hyphae |
| minecraft:wooden_slabs | minecraft:warped_slab, minecraft:wooden_slab, minecraft:crimson_slab, minecraft:bamboo_slab, minecraft:mangrove_slab, minecraft:cherry_slab |
| minecraft:wooden_tier | minecraft:wooden_pickaxe, minecraft:wooden_shovel, minecraft:wooden_hoe, minecraft:wooden_axe, minecraft:wooden_sword |
| minecraft:wool | minecraft:white_wool, minecraft:green_wool, minecraft:magenta_wool, minecraft:gray_wool, minecraft:orange_wool, minecraft:light_gray_wool, minecraft:red_wool, minecraft:pink_wool, minecraft:brown_wool, minecraft:black_wool, minecraft:wool, minecraft:light_blue_wool, minecraft:yellow_wool, minecraft:lime_wool, minecraft:cyan_wool, minecraft:blue_wool, minecraft:purple_wool |
| minecraft:wool | minecraft:white_wool, minecraft:green_wool, minecraft:magenta_wool, minecraft:gray_wool, minecraft:orange_wool, minecraft:light_gray_wool, minecraft:red_wool, minecraft:pink_wool, minecraft:brown_wool, minecraft:black_wool, minecraft:wool, minecraft:light_blue_wool, minecraft:yellow_wool, minecraft:lime_wool, minecraft:cyan_wool, minecraft:blue_wool, minecraft:purple_wool |

View File

@@ -1,11 +1,11 @@
---
title: Intro to Items
description: A "Hello world" guide in making items. Learn the item format and how to create basic custom items.
category: General
title: 物品入门指南
description: 手把手教你创建自定义物品,学习物品格式和基础制作方法。
category: 基础
nav_order: 1
tags:
- guide
- beginner
- 教程
- 新手入门
mentions:
- SirLich
- solvedDev
@@ -23,19 +23,22 @@ mentions:
- SmokeyStack
---
Minecraft Bedrock allows us to add custom items into our world with various vanilla-like properties
# 物品入门指南
This tutorial will cover how to create basic items for the stable version of Minecraft.
<!--@include: @/wiki/bedrock-wiki-mirror.md-->
## Registering Items
Minecraft 基岩版允许我们在世界中添加具有多种原版特性的自定义物品。
Item definitions are structured similarly to entities: they contain a description and a list of components that defines the item's behavior.
本教程将介绍如何为稳定版 Minecraft 创建基础物品。
Below is the **minimum** behavior-side code to get a custom item into the creative inventory.
## 注册物品
<CodeHeader>BP/items/custom_item.json</CodeHeader>
物品定义的结构与实体类似:包含描述信息和定义物品行为的组件列表。
```json
以下是让自定义物品出现在创造模式物品栏的**最低限度**行为端代码。
::: code-group
```json [BP/items/custom_item.json]
{
"format_version": "1.20.50",
"minecraft:item": {
@@ -45,26 +48,26 @@ Below is the **minimum** behavior-side code to get a custom item into the creati
"category": "construction"
}
},
"components": {} // Must be here, even if empty!
"components": {} // 必须存在,即使为空!
}
}
```
:::
### Item Description
### 物品描述
- Defines the item's identifier - a unique ID in the format of `namespace:identifier`.
- Configures which `menu_category` the item is placed into.
- Also takes the optional parameters `group` and `is_hidden_in_commands`.
- 定义物品唯一标识符,格式为 `命名空间:标识符`
- 配置物品在哪个`menu_category`分组显示
- 可额外设置`group`分组和`is_hidden_in_commands`是否隐藏于命令提示
## Adding Components
## 添加组件
Right now, our custom item is using the default component values (which can be found [here](/items/item-components)).
当前我们的自定义物品使用的是默认组件值(详见[物品组件文档](/wiki/items/item-components))。
Let's configure our own functionality!
现在让我们配置自定义功能!
<CodeHeader>BP/items/custom_item.json</CodeHeader>
```json
::: code-group
```json [BP/items/custom_item.json]
{
"format_version": "1.20.50",
"minecraft:item": {
@@ -88,16 +91,16 @@ Let's configure our own functionality!
}
}
```
:::
Browse more item components [here](/items/item-components)!
查看完整物品组件列表请访问[物品组件文档](/wiki/items/item-components)
## Applying Textures
## 应用纹理
We need to create a texture shortname to link it to an image in `RP/textures/item_texture.json`.
我们需要在`RP/textures/item_texture.json`中创建纹理简称来关联图片。
<CodeHeader>RP/textures/item_texture.json</CodeHeader>
```json
::: code-group
```json [RP/textures/item_texture.json]
{
"resource_pack_name": "wiki",
"texture_name": "atlas.items",
@@ -108,12 +111,12 @@ We need to create a texture shortname to link it to an image in `RP/textures/ite
}
}
```
:::
In our item file, we will add the `minecraft:icon` component to apply the texture.
在物品文件中添加`minecraft:icon`组件来应用纹理。
<CodeHeader>BP/items/custom_item.json</CodeHeader>
```json
::: code-group
```json [BP/items/custom_item.json]
{
"format_version": "1.20.50",
"minecraft:item": {
@@ -131,26 +134,27 @@ In our item file, we will add the `minecraft:icon` component to apply the textur
}
}
```
:::
## Defining Names
## 定义名称
Finally, we will give our item a name. Additionally, you can use the [Display Name](/items/item-components#display_name) component.
最后为物品添加名称。你还可以使用[显示名称组件](/wiki/items/item-components#display_name)。
<CodeHeader>RP/texts/en_US.lang</CodeHeader>
```c
tile.wiki:custom_item.name=Custom Item
::: code-group
```c [RP/texts/zh_CN.lang]
tile.wiki:custom_item.name=自定义物品
```
:::
## Result
## 成果总结
In this page, you've learnt about the following:
本节教程您已掌握以下内容:
<Checklist>
- [x] Basic features of items
- [x] How to apply a texture
- [x] How to link textures using shortnames in `item_textures.json`
- [x] How to define names in the language file
- [x] 物品基础特性
- [x] 如何应用纹理
- [x] 使用`item_textures.json`关联纹理简称
- [x] 在语言文件中定义物品名称
</Checklist>

View File

@@ -9,7 +9,7 @@ This page is a more up-to-date version of [this page](https://learn.microsoft.co
## Overview
Item IDs (not to be confused with type IDs) are an older system which are mainly used to render items with [JSON UI](/json-ui/json-ui-documentation#item-id-aux-item-id-aux) nowadays. All items & blocks (Even custom ones!) have their own unique ID.
Item IDs (not to be confused with type IDs) are an older system which are mainly used to render items with [JSON UI](/wiki/json-ui/json-ui-documentation#item-id-aux-item-id-aux) nowadays. All items & blocks (Even custom ones!) have their own unique ID.
## ID Formatting
- Vanilla items & blocks have IDs from `-743` to `721`.

View File

@@ -1,8 +1,8 @@
---
title: Spawning Items
category: Tutorials
title: 生成物品
category: 巧思案例
tags:
- intermediate
- 中级
mentions:
- SirLich
- Joelant05
@@ -13,44 +13,47 @@ mentions:
- Xterionix
---
It is fairly common to want to spawn an item in the world, as if dropped. This page will walk through how to accomplish this through various methods, including Entity Deaths, Interactions, and an all-purpose method.
# 生成物品
## /loot
<!--@include: @/wiki/bedrock-wiki-mirror.md-->
The simplest method of spawning items to date is by using /loot. Formatted as such:
在世界中生成物品(如同自然掉落)是常见的需求。本文将介绍多种实现方法,包括实体死亡、交互操作和通用方法。
## /loot命令
目前最简单的方式是使用`/loot`命令。格式如下:
```
/loot spawn ~ ~ ~ loot "entities/cow"
```
<CodeHeader>BP/loot_tables/entities/cow.json</CodeHeader>
```json
::: code-group
```json [BP/loot_tables/entities/cow.json]
"minecraft:loot": {
"table": "loot_tables/entities/cow.json"
}
```
:::
## Entity Deaths
## 实体死亡
Another simple method of spawning items - and generally the most common one - is dropping items upon an entity's death. This is done by adding the `minecraft:loot` component to the entity and linking it to the respective loot table (`forium` in the following example) containing items you wish to be dropped.
另一种常用方法是在实体死亡时掉落物品。通过为实体添加`minecraft:loot`组件并关联对应的战利品表如下例中的forium表实现。
<CodeHeader>BP/entities/my_entity.json#components</CodeHeader>
```json
::: code-group
```json [BP/entities/my_entity.json#components]
"minecraft:loot": {
"table": "loot_tables/entities/forium.json"
}
```
:::
## Dummy Entity Deaths
## 虚体死亡
We can use `minecraft:loot` on a [dummy entity](/entities/dummy-entities) that dies when we spawn it to create a `drop_entity`. This entity can be summoned like `/summon wiki:drop_entity` to spawn the items. This is useful for scenarios where death particles or sounds are not an issue.
我们可以为[虚体](/wiki/entities/dummy-entities)添加`minecraft:loot`组件,在生成时立即死亡来创建`drop_entity`。通过`/summon wiki:drop_entity`即可生成物品,适用于不介意死亡粒子/音效的场景。
Behaviors:
行为包配置:
<CodeHeader>BP/entities/my_entity.json</CodeHeader>
```json
::: code-group
```json [BP/entities/my_entity.json]
{
"format_version": "1.16.0",
"minecraft:entity": {
@@ -62,7 +65,7 @@ Behaviors:
},
"components": {
// Causes the entity to die when spawned
// 使实体生成时立即死亡
"minecraft:health": {
"value": 0
},
@@ -73,16 +76,16 @@ Behaviors:
}
}
```
:::
## Interactions
## 交互操作
Here is an example of an entity called "box" which will drop its contents upon interaction. The table in `spawn_items` is linked to the loot table with the items desired to be dropped. In this particular case, the event `break_box` is also called when the entity is interacted with, adding a component group that removes the box.
以下示例展示了名为"box"的实体在被交互时掉落物品。`spawn_items`中的表关联需要掉落的战利品表。此例中`break_box`事件会添加移除箱子的组件组。
Note that if the entity is not removed upon interaction, it can be interacted with again and will spawn the items. If the entity should persist after the interaction, the `cooldown` parameter may be added to the entity to prevent interaction for a specified amount of time. Alternatively, an event may be called to remove the component group containing this `minecraft:interact` component.
注意:若未移除实体,可重复交互生成物品。如需保留实体,可为实体添加`cooldown`参数限制交互间隔,或通过事件移除包含`minecraft:interact`组件的组件组。
<CodeHeader>BP/entities/my_entity.json#components</CodeHeader>
```json
::: code-group
```json [BP/entities/my_entity.json#components]
"minecraft:interact": {
"interactions": [
{
@@ -103,22 +106,20 @@ Note that if the entity is not removed upon interaction, it can be interacted wi
]
}
```
:::
## All-Purpose Method
## 通用方法
This is a method that can be used for virtually any scenario: entity deaths, animation-based interactions, general item drops. This method was created in particular for dropping items without any death animation, sound, or particles.
此方法适用于各种场景:实体死亡、动画交互、常规掉落。特别适合需要静默生成物品(无死亡动画/音效/粒子)的情况。
Several parts are required to set up the item dropping: a new entity with behavior, a corresponding animation controller, the resources for an invisible entity (refer to Dummy Entities tutorial), and a loot table. To spawn the items after it is set up, the entity is spawned where the items are to be dropped. If multiple items are desired, component groups with spawn events may be set up for each item.
需要配置以下要素:新实体的行为包、动画控制器、虚体资源(参考虚体教程)和战利品表。生成物品时召唤实体到目标位置。多个物品可通过组件组和生成事件实现。
### Behavior
### 行为配置
The items are spawned using the `minecraft:behavior.drop_item_for` component in conjunction with the `minecraft:navigation.walk` component, the latter being required for the former to work. Note that the `time_of_day_range` parameter in the following is not initialized to how it is defined below despite the documentation listing it as such, and this is necessary for proper function. The parameter `max_dist` must be increased to an appropriate value if the items are desired to be dropped when the player is very far away.
使用`minecraft:behavior.drop_item_for`配合`minecraft:navigation.walk`组件实现物品生成。注意`time_of_day_range`参数需显式定义,`max_dist`需根据需求调整。此方法可能导致实体位移,建议略微抬高生成位置或缩小碰撞箱。
This behavior appears to push the mob back when the items are dropped. Thus it is essential to summon the entity slightly above the ground (or teleport it up in the following animation controller) to avoid the items spawning a few blocks away from the spawn location. Decreasing the size of the collision box may also help.
<CodeHeader>BP/entities/my_entity.json#components</CodeHeader>
```json
::: code-group
```json [BP/entities/my_entity.json#components]
"minecraft:navigation.walk": {},
"minecraft:behavior.drop_item_for": {
"priority": 1,
@@ -127,16 +128,14 @@ This behavior appears to push the mob back when the items are dropped. Thus it i
"time_of_day_range": [0.0, 1.0]
}
```
:::
### Animation Controller
### 动画控制器
**The following animation controller must be linked to the entity** to remove it upon summoning. Alternatively, an animation with a timeline can be used. If you are unsure how to do this, refer to the Entity Commands tutorial.
**必须为实体关联此动画控制器**以实现自动移除。也可使用时间轴动画实现。通过传送实体至虚空避免死亡效果。双重状态过渡确保实体不在生成瞬间被移除。
Teleporting the entity into the void causes no death animation, sound, or particles. Two transitions are used to ensure it is not killed in the same tick it spawns.
<CodeHeader>BP/animation_controllers/my_entity.ac.json</CodeHeader>
```json
::: code-group
```json [BP/animation_controllers/my_entity.ac.json]
{
"format_version": "1.10.0",
"animation_controllers": {
@@ -165,12 +164,10 @@ Teleporting the entity into the void causes no death animation, sound, or partic
}
}
```
:::
## Structure Method
## 结构方法
There is also one interesting method of spawning items - via structure.
You can fill a structure with `structure_void` (so air doesn't replace blocks when structure loaded) and drop an item into it.
This method allows us to keep item data (such as durability).
Then you can load this structure whenever and wherever you want.
通过结构生成物品是另一种有趣的方式。使用`structure_void`填充结构(避免加载时覆盖方块)并放入物品。此方法可保留物品数据(如耐久度),支持随时加载。
![](/assets/images/items/spawning-items/structure-method.png)
![](/assets/images/items/spawning-items/structure-method.png)

View File

@@ -1,8 +1,8 @@
---
title: Custom Spear
category: Tutorials
title: 自定义长矛
category: 巧思案例
tags:
- scripting
- 脚本
mentions:
- XxPoggyisLitxX
- SirLich
@@ -12,15 +12,19 @@ mentions:
hidden: true
---
# 自定义长矛
<!--@include: @/wiki/bedrock-wiki-mirror.md-->
::: tip
It's highly recommended that you have a basic understanding of JavaScript and Script-API.
强烈建议您对JavaScriptScript-API有基本的了解。
:::
::: warning
It's highly recommended that you have made the basic textures and models for this guide..
请确保已为本教程准备好基础纹理和模型。
:::
Before we start, let's make sure you have your file structure set up:
开始前,请确认文件结构已正确设置:
<FolderView
:paths="[
@@ -39,45 +43,44 @@ Before we start, let's make sure you have your file structure set up:
]"
></FolderView>
Making custom spears is a really simple task. It was not simple for Koala Boy though. There are some scripting involved, but it doesn't do the main behaviors.
制作自定义长矛其实非常简单不过对Koala Boy来说可不简单。虽然涉及部分脚本但核心行为并不依赖脚本实现。
## Item
## 物品
It can go without saying that you'd obviously need an item to make a spear, however we don't use some "basic" behaviors. Let's get an item file and let's add the following components. Let's start with the main components:
首先需要创建长矛物品,但这里不使用"基础"行为组件。我们通过以下组件实现特殊功能:
<CodeHeader>BP/items/spear.json</CodeHeader>
```json
::: code-group
```json [BP/items/spear.json]
{
//Use duration is the max time we can use the item.
//使用持续时间是我们能使用物品的最长时间
"minecraft:use_duration": 3600,
//This component is what gives our spear the ability to 'draw' it like a bow
//赋予长矛类似弓的拉弓能力
"minecraft:throwable": {
"min_draw_duration": 2,
"max_draw_duration": 4,
"scale_power_by_draw_duration": true
},
//What projectile to shoot when draw is complete
//完成蓄力后发射的抛射物
"minecraft:projectile": {
"projectile_entity": "wiki:thrown_iron_spear",
"minimum_critical_power": 1.0
},
//Durability of the spear.
//长矛耐久度
"minecraft:durability": {
"max_durability": 125
}
}
```
:::
## Spear Projectile
## 抛射物实体
We can safely say that we got the important components for our spear. Next we move over to the projectile. This projectile will be a simple entity, with some added components and a runtime identifier to get the correct behaviors.
接下来创建抛射物实体。该实体需要特殊组件和运行时标识符来实现正确行为:
<Spoiler title="Projectile">
<Spoiler title="抛射物实体">
<CodeHeader>BP/entities/spear.json</CodeHeader>
```json
::: code-group
```json [BP/entities/spear.json]
{
"format_version": "1.12.0",
"minecraft:entity": {
@@ -155,17 +158,17 @@ We can safely say that we got the important components for our spear. Next we mo
}
}
```
:::
</Spoiler>
Here we got our simple projectile entity. We are missing one part to make this a useful projectile. There is no way for our player to pick it up from the ground. In order to do this, we need events and entity sensors:
<CodeHeader>BP/entities/spear.json</CodeHeader>
现在需要添加玩家拾取机制。通过实体传感器和事件实现:
```json
::: code-group
```json [BP/entities/spear.json]
{
"components": {
//Entity sensor detects if the projectile is on the ground, and if the player is near the entity.
//This will run an event when it's true
//实体传感器检测抛射物是否在地面上,以及玩家是否靠近实体
//当条件满足时触发事件
"minecraft:entity_sensor": {
"event": "wiki:give",
"event_filters": {
@@ -189,7 +192,7 @@ Here we got our simple projectile entity. We are missing one part to make this a
},
"events": {
/*
This event will despawn our projectile, and give our player a tag, which we will use in our script.
该事件会立即销毁抛射物,并给玩家添加标签(将在脚本中使用)
*/
"wiki:give": {
"sequence": [
@@ -218,18 +221,16 @@ Here we got our simple projectile entity. We are missing one part to make this a
}
}
```
:::
Once we're done with out projectile entity, it's time to go to Resource Packs.
## 客户端实体
## Client Entity
为抛射物创建客户端实体文件:
We will be using a basic client entity file for our projectile with added code.
<Spoiler title="客户端实体">
<Spoiler title="Client Entity">
<CodeHeader>RP/entities/spear.json</CodeHeader>
```json
::: code-group
```json [RP/entities/spear.json]
{
"format_version": "1.10.0",
"minecraft:client_entity": {
@@ -259,23 +260,21 @@ We will be using a basic client entity file for our projectile with added code.
}
}
```
:::
</Spoiler>
Inside our client entity file, you might have noticed that there is animations bound to it. This animation will make our projectile rotate as it flies.
:::warning
Make sure your entity model is modeled like the image bellow!
请确保实体模型符合下图样式!
:::
![](/assets/images/items/spears/spear_model.png)
## Animation
## 动画
The animation we use for our projectile isn't you normal entity animation. This one uses [molang](https://bedrock.dev/docs/stable/Molang) to define rotations.
使用[Molang](https://bedrock.dev/docs/stable/Molang)实现抛射物飞行时的旋转动画:
<CodeHeader>BP/animations/spear.json</CodeHeader>
```json
::: code-group
```json [BP/animations/spear.json]
{
"format_version": "1.8.0",
"animations": {
@@ -283,7 +282,7 @@ The animation we use for our projectile isn't you normal entity animation. This
"loop": true,
"bones": {
"body": {
//This is some molang stuff. The animation uses this to rotate the model based on its current angle.
//这是一些molang代码。动画根据当前角度旋转模型
"rotation": ["-q.target_x_rotation", "-q.body_y_rotation", 0]
}
}
@@ -291,14 +290,14 @@ The animation we use for our projectile isn't you normal entity animation. This
}
}
```
:::
## Attachable
## 附着物
We will be using the Trident Attachable because it comes with item positions and use animations already. It should look like this:
使用三叉戟的附着物模板,已包含持握动画:
<CodeHeader>BP/attachables/spear.json</CodeHeader>
```json
::: code-group
```json [BP/attachables/spear.json]
{
"format_version": "1.10.0",
"minecraft:attachable": {
@@ -339,64 +338,59 @@ We will be using the Trident Attachable because it comes with item positions and
}
}
```
:::
## Script
## 脚本
Now that we've setup our spear, there is no way to damage the spear when it's thrown. To do this, we will make use of Script-API.
The script is really simple, and wouldn't require much brain power.
通过Script-API实现耐久度消耗
```js
import { world, ItemStack } from "@minecraft/server"
import { system } from "@minecraft/server";
//This prevents world crash
//防止世界崩溃
system.beforeEvents.watchdogTerminate.subscribe(data => {
data.cancel = true;
});
world.afterEvents.itemReleaseUse.subscribe(ev => {
//This is for multiplayer support
//多人游戏支持
for (const player of world.getPlayers()){
//Basic variables to get the player inventory and held item.
let inv = player.getComponent( 'inventory' ).container
//Our itemStack to save our item. This also saves item data.
//保存物品数据
const itemStack = inv.getItem(player.selectedSlot);
//If the item we're holding is our spear, we run code.
//检测是否持有长矛
if (itemStack?.typeId === 'wiki:iron_spear') {
var container = player.getComponent('inventory').container
//The new item to be given.
var newItem = new ItemStack("wiki:iron_spear");
var oldItem = container?.getItem(player.selectedSlot)
//Here's that tag!
player.removeTag("iron_spear")
}
//We subscribe a tick event to detect when we have the tag and if the item has durability less than the max.
//Tick事件检测标签和耐久度
let e = system.runInterval(() => {
if(player.hasTag("iron_spear") && itemStack?.typeId === 'wiki:iron_spear' && itemStack?.getComponent("durability").damage <= 125) {
player.removeTag("iron_spear")
//This gives our saved item (newItem) +1 durability each time we pick it up.
//拾取时增加耐久损耗
newItem.getComponent("durability").damage = oldItem.getComponent("durability").damage + 1;
container.setItem(player.selectedSlot, newItem);
//When we don't have the tag, we stop the tick event.
//清除Tick事件
if(!player.hasTag("iron_spear")){
system.clearRun(e);
}}
})}
})
```
## Final Product
## 最终效果
Once you've followed this guide, you should have your own working spear in-game.
完成所有步骤后,即可在游戏中获得可正常使用的长矛:
![](/assets/images/items/spears/spear_first_person.png)
![](/assets/images/items/spears/spear_third_person.png)
Example Pack Download:
示例包下载:
<BButton
link="https://github.com/Bedrock-OSS/wiki-addon/releases/download/download/custom_spear.mcaddon"
color=blue
>💾 Example Pack</BButton>
>💾 示例包</BButton>

View File

@@ -1,8 +1,8 @@
---
title: Throwable Items
category: Tutorials
title: 投掷物
category: 巧思案例
tags:
- intermediate
- 中级
mentions:
- Fabrimat
- MedicalJewel105
@@ -14,23 +14,26 @@ mentions:
- ThomasOrs
---
# 投掷物
<!--@include: @/wiki/bedrock-wiki-mirror.md-->
::: tip
This tutorial assumes you have a basic understanding of Molang, animation controllers and entity definitions.
本教程假定您已掌握 Molang、动画控制器和实体定义的基础知识。
:::
Items like the Splash Potion or the Trident are special items that can be thrown. Currently, there are two ways to accomplish something similar in your add-on, one that can be done in the stable release and one that needs the `Holiday Creator Features` experimental toggle to be enabled.
类似喷溅药水或三叉戟这样的物品属于可投掷的特殊物品。目前有两种方式可以在附加包中实现类似效果,一种适用于稳定版,另一种需要开启 `Holiday Creator Features` 实验性功能。
## Stable method
## 稳定版实现方案
This method lets you detect the usage of an item through the `minecraft:food` component from an animation controller, and modifying the `player.json` you can then spawn an entity when that happens.
此方案通过动画控制器检测 `minecraft:food` 组件的使用情况,并通过修改 `player.json` 在投掷时生成实体。
### The Item
### 物品定义
First, you'll want to make the actual item:
首先创建可投掷物品:
<CodeHeader>BP/items/throwable_item.item.json</CodeHeader>
```json
::: code-group
```json [BP/items/throwable_item.item.json]
{
"format_version": "1.16.0",
"minecraft:item": {
@@ -47,18 +50,18 @@ First, you'll want to make the actual item:
}
}
```
:::
We can notice several things here:
关键点解析:
- `format_version` must be `1.16.0`
- `minecraft:use_duration` should be a high number, in order to stop the eating sound to play and to prevent the player from eating the item
- `minecraft:food` is used to allow player to actually "use" the item, so we can detect it
- `format_version` 必须为 `1.16.0`
- `minecraft:use_duration` 需设置较大值以防止播放进食音效
- `minecraft:food` 组件用于启用物品使用检测
Because the format version is `1.16.0`, your item needs an RP definition too:
由于格式版本为 `1.16.0`,需添加资源包定义:
<CodeHeader>RP/items/throwable_item.item.json</CodeHeader>
```json
::: code-group
```json [RP/items/throwable_item.item.json]
{
"format_version": "1.16.0",
"minecraft:item": {
@@ -72,15 +75,14 @@ Because the format version is `1.16.0`, your item needs an RP definition too:
}
}
```
:::
### The Entity
### 实体定义
The entity will be the actual thrown item, and it will behave like a projectile.
Make sure to add snowball runtime identifier to make your projectile to actually be shoot, not spawned. You can also experiment with other projectile runtime id's.
该实体将作为实际投掷物,具有弹射物特性。注意添加雪球运行时标识使实体具有投射行为,也可尝试其他投射物标识。
<CodeHeader>BP/entities/throwable_item_entity.se.json</CodeHeader>
```json
::: code-group
```json [BP/entities/throwable_item_entity.se.json]
{
"format_version": "1.16.0",
"minecraft:entity": {
@@ -128,33 +130,31 @@ Make sure to add snowball runtime identifier to make your projectile to actually
}
}
```
:::
This entity is based on the Vanilla splash potion.
此实体基于原版喷溅药水设计,可通过修改 `minecraft:projectile` 组件调整行为(示例中投掷物将造成伤害并给予经验)。
You can then customize its behavior by editing the `minecraft:projectile` component, in this case the thrown item will grant some exp and will damage any entity it will hit.
### 动画控制器
### The Animation Controller
动画控制器负责检测物品使用并触发投掷事件:
The animation controller is responsible for detecting the usage of the item and for telling the player entity to spawn a throwable entity.
<CodeHeader>BP/animation_controllers/throwables.ac.json</CodeHeader>
```json
::: code-group
```json [BP/animation_controllers/throwables.ac.json]
{
"format_version": "1.10.0",
"animation_controllers": {
"controller.animation.player.throwables": { // The ID we will reference in the player's entity description
"controller.animation.player.throwables": { // 将在玩家实体描述中引用的ID
"states": {
"default": {
"transitions": [
{
// Current "q.is_item_name_any" takes 3 arguments, first is slot name, second is slot id, third is the item we want to check for
// "q.is_item_name_any" 接受三个参数槽位名称、槽位ID、检测物品
"throw_item": "q.is_item_name_any('slot.weapon.mainhand', 0, 'wiki:throwable_item') && q.is_using_item"
// "q.is_using_item" returns 'true' or 'false', in our case if player uses item it is going to return 'true'
// "q.is_using_item" 返回布尔值表示物品使用状态
}
],
"on_entry": [
// Resets the player entity in order to be able to throw another item
// 重置玩家状态以支持连续投掷
"@s wiki:reset_player"
]
},
@@ -165,9 +165,9 @@ The animation controller is responsible for detecting the usage of the item and
}
],
"on_entry": [
// Call the event in the player entity responsible of throwing the item
// 触发投掷事件
"@s wiki:throw_item",
// Remove the item from player's inventory
// 移除玩家物品
"/clear @s wiki:throwable_item -1 1"
]
}
@@ -176,23 +176,22 @@ The animation controller is responsible for detecting the usage of the item and
}
}
```
:::
#### player.json
#### player.json 配置
:::tip
Always make sure that your `player.json` file is updated to the latest version available, depending on the game version you are working on.
You can do that [here](https://bedrock.dev/packs).
请确保您的 `player.json` 文件与当前游戏版本保持同步,可在此处获取最新版本:[bedrock.dev](https://bedrock.dev/packs)
:::
:::warning
Do not edit/remove existing parts of the `player.json` file unless you know what you are doing, as it could (and probably will) break the game.
请勿随意修改或删除 `player.json` 原有内容,否则可能导致游戏异常
:::
Now, you have to register the animation controller to the `player.json` file:
注册动画控制器至玩家实体:
<CodeHeader>BP/entities/player.json</CodeHeader>
```json
::: code-group
```json [BP/entities/player.json]
{
"format_version": "1.18.20",
"minecraft:entity": {
@@ -203,15 +202,15 @@ Now, you have to register the animation controller to the `player.json` file:
"is_experimental": false,
"scripts": {
"animate": [
"throwables_controller" // This should exactly match the same as the one below
"throwables_controller" // 需与下方定义保持一致
]
},
"animations": {
"throwables_controller": "controller.animation.player.throwables" // ID as referenced in animation controller file
"throwables_controller": "controller.animation.player.throwables" // 动画控制器ID
}
},
"components": {
"minecraft:breathable": { // keeps breath timer bubbles from appearing
"minecraft:breathable": { // 防止显示呼吸气泡
"total_supply": 15,
"suffocate_time": -1,
"inhale_time": 3.75,
@@ -221,14 +220,14 @@ Now, you have to register the animation controller to the `player.json` file:
...
}
```
:::
Then, you need to add all the events and component groups to the `player.json` file:
添加组件组和事件:
<CodeHeader>BP/entities/player.json#minecraft:entity</CodeHeader>
```json
::: code-group
```json [BP/entities/player.json#minecraft:entity]
"component_groups": {
"wiki:throw_entity": { // Contains a component that will spawn the entity
"wiki:throw_entity": { // 包含实体生成组件
"minecraft:spawn_entity": {
"entities": {
"min_wait_time": 0,
@@ -257,16 +256,16 @@ Then, you need to add all the events and component groups to the `player.json` f
}
}
```
:::
## Experimental method
## 实验版实现方案
This method requires the `Holiday Creator Features` experimental toggle to be enabled.
此方案需启用 `Holiday Creator Features` 实验性功能。
### The Item
### 物品定义
<CodeHeader>BP/items/throwable_item.item.json</CodeHeader>
```json
::: code-group
```json [BP/items/throwable_item.item.json]
{
"format_version": "1.16.100",
"minecraft:item": {
@@ -304,29 +303,28 @@ This method requires the `Holiday Creator Features` experimental toggle to be en
}
}
```
:::
We can notice several things here:
关键点说明:
- `format_version` must be `1.16.100`
- `minecraft:on_use` will call an event every time the item is used (right-clicked)
- `format_version` 必须为 `1.16.100`
- `minecraft:on_use` 用于响应右键事件
In the event:
事件参数:
- `shoot` will shoot our entity
- `swing` will run the swing animation on the player
- `decrement_stack` will remove one item from the player's inventory
- `run_command` will execute commands when the item is shot, like playing sounds
- `shoot` 投射实体
- `swing` 播放挥动动画
- `decrement_stack` 减少物品堆叠
- `run_command` 执行音效指令
### 实体定义
### The Entity
The entity file is the same as the Stable version.
实体文件与稳定版相同。
<Spoiler title="BP/entities/throwable_item_entity.se.json">
<CodeHeader>BP/entities/throwable_item_entity.se.json</CodeHeader>
```json
::: code-group
```json [BP/entities/throwable_item_entity.se.json]
{
"format_version": "1.16.0",
"minecraft:entity": {
@@ -374,9 +372,17 @@ The entity file is the same as the Stable version.
}
}
```
:::
</Spoiler>
## Conclusion
## 扩展应用
Once you have your throwable item you can start trying several things, like playing with its power, effects, animations or combining it with an [AOE Cloud](/entities/introduction-to-aec). The only limit is your imagination.
完成基础投掷物后,您可以尝试以下扩展:
- 调整投射力度和弹道参数
- 添加粒子效果和高级动画
- 组合使用[区域效果云](/wiki/entities/introduction-to-aec)
- 实现不同命中效果(燃烧、中毒等)
通过灵活运用组件和事件系统,可以创造出丰富的投掷物玩法。

View File

@@ -1,47 +1,48 @@
---
title: Tool Durability
category: Tutorials
title: 工具耐久度
category: 巧思案例
tags:
- experimental
- intermediate
- scripting
- 实验性
- 中级
- 脚本
mentions:
- MedicalJewel105
- TheDoctor15
- napstaa967
---
## Introduction
# 工具耐久度
1.16.100+ items have different durability mechanic than 1.10 and 1.16 items.
Now you need to define when will the item get durability damage and also an event that does it.
What will be discussed on this page:
- Durability component
- Event that updates durability
- Damaging entities
- Block breaking
- `repair_amount` value
- `on_tool_used` event
<!--@include: @/wiki/bedrock-wiki-mirror.md-->
### Components
## 简介
<CodeHeader>BP/items/my_item.json#components</CodeHeader>
1.16.100+版本的物品耐久机制与1.10和1.16版本存在差异。现在需要明确定义物品何时会受到耐久损耗,并通过事件触发损耗行为。本教程将涵盖以下内容:
- 耐久度组件
- 更新耐久度的事件
- 实体伤害机制
- 方块破坏机制
- `repair_amount` 参数
- `on_tool_used` 事件
```json
### 组件
::: code-group
```json [BP/items/my_item.json#components]
"minecraft:durability": {
"max_durability": 200
}
```
:::
`minecraft:durability` will give your item a set max durability
`minecraft:durability`组件用于定义物品的最大耐久值
## Event
## 事件机制
### Item event
### 物品事件
<CodeHeader>BP/items/my_item.json#events</CodeHeader>
```json
::: code-group
```json [BP/items/my_item.json#events]
"durability_update": {
"damage": {
"type": "none",
@@ -50,24 +51,23 @@ What will be discussed on this page:
}
}
```
:::
When this event is called the item (`self` target) will receive durability damage.
Looks simple, doesn't it?
当该事件被触发时,物品(`self`目标)将承受耐久损耗。看似简单,不是吗?
### Script event
### 脚本事件
For the script methods, we'll be using a function to damage our item
对于脚本实现,我们将使用自定义函数处理耐久损耗
This function supports unbreaking on items
该函数支持物品的"耐久"附魔效果
<CodeHeader>BP/scripts/main.js</CodeHeader>
```js
::: code-group
```js [BP/scripts/main.js]
function damage_item(item) {
// Get durability
// 获取耐久度组件
const durabilityComponent = item.getComponent("durability")
var unbreaking = 0
// Get unbreaking level
// 获取耐久附魔等级
if (item.hasComponent("enchantments")) {
unbreaking = item.getComponent("enchantments").enchantments.getEnchantment("unbreaking")
if (!unbreaking) {
@@ -76,7 +76,7 @@ function damage_item(item) {
unbreaking = unbreaking.level
}
}
// Apply damage
// 应用损耗
if (durabilityComponent.damage == durabilityComponent.maxDurability) {
return
@@ -85,39 +85,39 @@ function damage_item(item) {
return item
}
```
## Damaging entities
### Using scripts
:::warning Experimental Script
This script uses `@minecraft/server 1.9.0-beta`, which will change in the next minecraft update.
:::
For format versions 1.20.40 and onward, `on_hurt_entity` no longer works.
## 实体伤害
This provides a way to damage weapons using scripts
### 脚本实现
<CodeHeader>BP/scripts/main.js</CodeHeader>
:::warning 实验性脚本
```js
// Add your item IDs into this array
本脚本使用`@minecraft/server 1.9.0-beta`,该版本将在后续游戏更新中变更。
:::
对于1.20.40及更高格式版本,`on_hurt_entity`已失效。
以下脚本实现了武器耐久损耗机制:
::: code-group
```js [BP/scripts/main.js]
// 在此数组中添加你的物品ID
const my_items = ["wiki:silver_dagger"]
world.afterEvents.entityHurt.subscribe(event => {
// If there's no source entity, skip
// 无伤害来源实体则跳过
if (!event.damageSource.damagingEntity) return
// Get equipped weapon
// 获取装备的武器
const equipment = event.damageSource.damagingEntity.getComponent("minecraft:equippable")
if (!equipment) return
const weapon = equipment.getEquipment(EquipmentSlot.Mainhand)
// If there's no weapon, skip
// 无武器则跳过
if (!weapon) return
// If the item is not in our item IDs, skip
// 物品不在列表则跳过
if (!my_items.includes(weapon.typeId)) return
let newItem = damage_item(weapon)
equipment.setEquipment(EquipmentSlot.Mainhand, newItem)
@@ -128,52 +128,52 @@ world.afterEvents.entityHurt.subscribe(event => {
}
})
```
:::
### on_hurt_entity
### on_hurt_entity事件
:::warning
`on_hurt_entity` was removed in format version 1.20.40
`on_hurt_entity`在格式版本1.20.40后已移除
:::
`on_hurt_entity` can be defined in "minecraft:weapon" component. It tells the game what event should happen when player hurts entity using this item.
在`minecraft:weapon`组件中定义`on_hurt_entity`,用于指定玩家使用该物品攻击实体时触发的事件
<CodeHeader>BP/items/my_item.json#components</CodeHeader>
```json
::: code-group
```json [BP/items/my_item.json#components]
"minecraft:weapon": {
"on_hurt_entity": {
"event": "durability_update"
}
}
```
## Block breaking
### Using scripts
:::warning Experimental Script
This script uses `@minecraft/server 1.9.0-beta`, which will change in the next minecraft update.
:::
For format versions 1.20.20 and onward, `on_dig` no longer works.
## 方块破坏
This provides a way to damage digger items by using scripts
### 脚本实现
<CodeHeader>BP/scripts/main.js</CodeHeader>
:::warning 实验性脚本
```js
// Add your item IDs into this array
本脚本使用`@minecraft/server 1.9.0-beta`,该版本将在后续游戏更新中变更。
:::
对于1.20.20及更高格式版本,`on_dig`已失效。
以下脚本实现了工具耐久损耗机制:
::: code-group
```js [BP/scripts/main.js]
// 在此数组中添加你的物品ID
const my_items = ["wiki:obsidian_pickaxe"]
world.afterEvents.playerBreakBlock.subscribe(event => {
// If there's no item, skip
// 无物品则跳过
if (!event.itemStackAfterBreak) return
// If the item is not in our item IDs, skip
// 物品不在列表则跳过
if (!my_items.includes(event.itemStackAfterBreak.typeId)) return
// If player is in creative, skip
// 创造模式玩家跳过
if (world.getPlayers({
gameMode: GameMode.creative
}).includes(event.player)) return
@@ -184,19 +184,19 @@ world.afterEvents.playerBreakBlock.subscribe(event => {
}
})
```
:::
### on_dig
### on_dig事件
:::warning
`on_dig` was removed in format version 1.20.20
`on_dig`在格式版本1.20.20后已移除
:::
`on_dig` can be defined in "minecraft:digger" component. It tells the game what event should happen when player dug a block using this item.
在`minecraft:digger`组件中定义`on_dig`,用于指定玩家使用该物品破坏方块时触发的事件
<CodeHeader>BP/items/my_item.json#components</CodeHeader>
```json
::: code-group
```json [BP/items/my_item.json#components]
"minecraft:digger": {
"use_efficiency": true,
"destroy_speeds": [
@@ -206,25 +206,25 @@ world.afterEvents.playerBreakBlock.subscribe(event => {
},
"speed": 8,
"on_dig": {
// Defines event that should happen when block with tag wood was dug.
// 定义破坏带有wood标签的方块时触发的事件
"event": "durability_update"
}
}
],
"on_dig": {
// Defines event that should happen when any block was destroyed.
// 定义破坏任意方块时触发的事件
"event": "durability_update"
}
}
```
:::
## repair_amount
## repair_amount参数
`repair_amount` can be defined in "minecraft:repairable" component. It tells the game how much of the item's durability should be back when it was repaired.
在`minecraft:repairable`组件中定义`repair_amount`,用于指定物品修复时的耐久恢复量
<CodeHeader>BP/items/my_item.json#components</CodeHeader>
```json
::: code-group
```json [BP/items/my_item.json#components]
"minecraft:repairable": {
"repair_items": [
{
@@ -237,31 +237,30 @@ world.afterEvents.playerBreakBlock.subscribe(event => {
]
}
```
:::
Formula explanation:
公式解析:
`"context.other->q.remaining_durability + 0.05 * context.other->q.max_durability"`
The _final_ durability will be durability of the first axe + durability of the second axe + 5% of 2nd axe MAX durability.
最终耐久 = 第一把斧的剩余耐久 + 第二把斧的剩余耐久 + 第二把斧最大耐久的5%
## on_tool_used
## on_tool_used事件
(This might not work now)
`on_tool_used` is special event that can be called using tags.
Tags work kinda like runtime identifiers for entities.
Known tags:
(当前可能不可用)
`on_tool_used`是通过标签系统触发的特殊事件。标签类似于实体的运行时标识符。已知标签:
| Tag | Effects | How can be called |
| -------------------- | -------------- | -------------------------------------------------- |
| minecraft:is_axe | Strips logs | By interacting with blocks that axe interacts with |
| minecraft:is_hoe | Makes farmland | By interacting with blocks that hoe interacts with |
| minecraft:is_pickaxe | Unknown | Unknown |
| minecraft:is_sword | Unknown | Unknown |
| 标签 | 效果 | 触发方式 |
| -------------------- | ------------- | -------------------------------- |
| minecraft:is_axe | 剥离原木 | 与斧头可交互的方块互动时触发 |
| minecraft:is_hoe | 制作耕地 | 与锄头可交互的方块互动时触发 |
| minecraft:is_pickaxe | 未知 | 未知 |
| minecraft:is_sword | 未知 | 未知 |
You can apply these tags this way:
可通过以下方式应用标签:
<CodeHeader>BP/items/my_item.json#components</CodeHeader>
```json
::: code-group
```json [BP/items/my_item.json#components]
"tag:minecraft:is_axe": {}
```
:::

View File

@@ -1,6 +1,6 @@
---
title: Troubleshooting Items
category: General
title: 物品问题排查
category: 基础
nav_order: 4
tags:
- help
@@ -13,74 +13,78 @@ mentions:
- ThomasOrs
---
# 物品问题排查
<!--@include: @/wiki/bedrock-wiki-mirror.md-->
:::tip
This page contains troubleshooting information about _items_. You should read our [global troubleshooting](/guide/troubleshooting) document before continuing here.
本文包含关于_物品_的故障排查信息。在继续阅读前建议先查看[全局故障排查指南](/wiki/guide/troubleshooting)。
:::
## Start Here
## 从这里开始
I followed a tutorial or tried to make my own item and something is wrong! Calm down. This page will help debug common issues. Follow the buttons and prompts to learn about possible issues with your item, and tips for fixing.
我按照教程制作了自定义物品,但出现了问题!请保持冷静。本指南将帮助您排查常见问题。根据按钮提示了解可能的问题原因及修复方法。
<BButton color="blue" link="#_1-10-vs-1-16-items">Continue</BButton>
<BButton color="blue" link="#_1-10-vs-1-16-items">继续</BButton>
---
## 1.10 vs 1.16 Items?
## 1.10 1.16 格式物品的区别?
Before starting, you need to determine whether you creating an experimental item, or a stable item.
首先需要确认您使用的是实验性物品格式还是稳定版物品格式。
:::tip
Versions `1.16.0` and prior are currently **stable** (Includes versions `1.16`, `1.14`, `1.13`, `1.12`, `1.10`). These **do not** require `Holiday Creator Features` to be enabled.
🔗 Tutorial on [stable items](/guide/custom-item).
🔗 Documentation for [stable items](https://bedrock.dev/docs/1.16.0.0/1.16.20.54/Item)
`1.16.0` 及更早版本属于**稳定版**(包含 `1.16`, `1.14`, `1.13`, `1.12`, `1.10`)。这些格式**无需**启用 `Holiday Creator Features` 实验性玩法。
🔗 [稳定版物品教程](/wiki/guide/custom-item)
🔗 [稳定版物品文档](https://bedrock.dev/docs/1.16.0.0/1.16.20.54/Item)
:::
:::tip
Versions `1.16.100` and onward are **experimental**. These items **will not work unless** `Holiday Creator Features` **is enabled in the world**.
`1.16.100` 及更高版本属于**实验性格式**。这些物品**必须**在世界设置中启用 `Holiday Creator Features` 才能正常使用。
🔗 Our tutorial on [experimental items](/items/item-components).
🔗 Documentation for [experimental items](https://bedrock.dev/docs/stable/Item)
🔗 [实验性物品教程](/wiki/items/item-components)
🔗 [实验性物品文档](https://bedrock.dev/docs/stable/Item)
:::
### Continue
### 继续选择
<BButton color="blue" link="#stable-items">1.10 format (stable)</BButton> <BButton color="blue" link="#experimental-items">1.16.100 format (experimental)</BButton>
<BButton color="blue" link="#stable-items">1.10 格式(稳定版)</BButton> <BButton color="blue" link="#experimental-items">1.16.100 格式(实验性)</BButton>
---
## Stable Items
## 稳定版物品
This section contains troubleshooting information for stable items. Remember, you are using the `1.10` format, so you need both an RP file and a BP file for your item! If you only have a BP file, you have become confused between format versions. Please start again [here](#_1-10-vs-1-16-items).
本部分针对稳定版物品的故障排查。请注意:使用 `1.10` 格式时,您需要同时存在 RP 和 BP 文件!如果只有 BP 文件,说明混淆了格式版本。请返回[此处](#_1-10-vs-1-16-items)重新确认。
Find the issue you have, then read the prompts.
根据问题现象选择对应排查步骤:
- [I cannot /give myself my custom item!](#i-cannot-give-myself-my-custom-item)
- [My textures are missing!](#my-textures-are-missing)
- [无法通过 /give 获取物品](#无法通过-give-获取物品)
- [物品贴图丢失](#物品贴图丢失)
### I cannot /give myself my custom item!
### 无法通过 /give 获取物品
An issue here will be caused by the item file in the BP.
此问题通常由 BP 文件配置错误引起:
- Confirm that your pack is actually applied to your world
- Confirm that your item is in the folder `BP/items/`
- Confirm that your item is valid, according to [jsonlint](https://jsonlint.com/).
- Confirm that your identifier is all lowercase, and looks similar to this: `wiki:my_item`
- 确认资源包已正确加载至世界
- 确认物品文件存放在 `BP/items/` 目录
- 使用 [jsonlint](https://jsonlint.com/) 验证 JSON 格式正确
- 确保物品标识符全小写,格式如:`wiki:my_item`
### My textures are missing!
### 物品贴图丢失
Navigate to your `item_texture.json` file. Ensure that it is properly named, and in the correct folder. Some examples of wrong names:
首先检查 `item_texture.json` 文件:
- ⚠️ `texture/item_texture.json`
- ⚠️ `textures/Item_texture.json`
- ⚠️ `textures/item_textures.json`
- 正确路径应为:`RP/textures/item_texture.json`
- 常见错误路径示例:
- ⚠️ `texture/item_texture.json`
- ⚠️ `textures/Item_texture.json`
- ⚠️ `textures/item_textures.json`
Here is an example file to compare against:
参考示例文件结构:
<CodeHeader>RP/textures/item_texture.json</CodeHeader>
```json
::: code-group
```json [RP/textures/item_texture.json]
{
"resource_pack_name": "wiki",
"texture_name": "atlas.items",
@@ -91,16 +95,18 @@ Here is an example file to compare against:
}
}
```
:::
Next, navigate to your items RP file. Ensure that it is in the correct folder. Example of incorrect path:
接着检查 RP 物品文件:
- ⚠️ `item/gem.json`
- 正确路径应为:`RP/items/物品名称.json`
- 错误示例路径:
- ⚠️ `item/gem.json`
An example file, to compare against:
参考示例配置(注意注释说明):
<CodeHeader>RP/items/gem.json</CodeHeader>
```json
::: code-group
```json [RP/items/gem.json]
{
"format_version": "1.10",
"minecraft:item": {
@@ -109,55 +115,57 @@ An example file, to compare against:
"category": "Nature"
},
"components": {
"minecraft:icon": "gem", //make sure this string matches the string you put in item_texture.json!
"minecraft:icon": "gem", // 确保此字符串与 item_texture.json 中的键名一致!
"minecraft:render_offsets": "tools"
}
}
}
```
:::
If you followed this properly, your item should now have a texture.
正确配置后物品将正常显示贴图。
---
## Experimental Items
## 实验性物品
This section contains troubleshooting information for experimental items. Remember, you are using the `1.16` format, so there shouldn't be an RP file for your item! If you have both an RP file and a BP file, you have become confused between format versions. Please start again [here](#_1-10-vs-1-16-items).
本部分针对实验性物品格式的故障排查。请注意:使用 `1.16` 格式时**不应存在 RP 物品文件**!如果同时存在 RP 和 BP 文件,说明混淆了格式版本。请返回[此处](#_1-10-vs-1-16-items)重新确认。
Find the issue you have, then read the prompts.
根据问题现象选择对应排查步骤:
- [Start Here](#start-here)
- [1.10 vs 1.16 Items?](#110-vs-116-items)
- [Continue](#continue)
- [Stable Items](#stable-items)
- [I cannot /give myself my custom item!](#i-cannot-give-myself-my-custom-item)
- [My textures are missing!](#my-textures-are-missing)
- [Experimental Items](#experimental-items)
- [I cannot /give myself my custom item!](#i-cannot-give-myself-my-custom-item-1)
- [My Textures Are Missing!](#my-textures-are-missing-1)
- [My item is Huge](#my-item-is-huge)
- [What now?](#what-now)
- [从这里开始](#从这里开始)
- [1.10 1.16 格式物品的区别?](#110--116-格式物品的区别)
- [继续选择](#继续选择)
- [稳定版物品](#稳定版物品)
- [无法通过 /give 获取物品](#无法通过-give-获取物品)
- [物品贴图丢失](#物品贴图丢失)
- [实验性物品](#实验性物品)
- [无法通过 /give 获取物品](#无法通过-give-获取物品-1)
- [物品贴图丢失!](#物品贴图丢失-1)
- [物品模型过大](#物品模型过大)
- [后续步骤](#后续步骤)
### I cannot /give myself my custom item!
### 无法通过 /give 获取物品
- Confirm that your pack is actually applied to your world
- Confirm that your item is in the folder `BP/items/`
- Confirm that your item is valid, according to [jsonlint](https://jsonlint.com/).
- Confirm that your identifier is all lowercase, and looks similar to this: `wiki:my_item`
- 确认资源包已正确加载至世界
- 确认物品文件存放在 `BP/items/` 目录
- 使用 [jsonlint](https://jsonlint.com/) 验证 JSON 格式正确
- 确保物品标识符全小写,格式如:`wiki:my_item`
### My Textures Are Missing!
### 物品贴图丢失!
Navigate to your `item_texture.json` file. Ensure that it is properly named, and in the correct folder. Some examples of wrong names:
检查 `item_texture.json` 文件:
- ⚠️ `texture/item_texture.json`
- ⚠️ `textures/Item_texture.json`
- ⚠️ `textures/item_textures.json`
- 正确路径应为:`RP/textures/item_texture.json`
- 常见错误路径示例:
- ⚠️ `texture/item_texture.json`
- ⚠️ `textures/Item_texture.json`
- ⚠️ `textures/item_textures.json`
Here is an example file to compare against:
参考示例文件:
<CodeHeader>RP/textures/item_texture.json</CodeHeader>
```json
::: code-group
```json [RP/textures/item_texture.json]
{
"resource_pack_name": "wiki",
"texture_name": "atlas.items",
@@ -168,40 +176,40 @@ Here is an example file to compare against:
}
}
```
:::
Next, navigate to your items BP file. Place the `minecraft:icon` component in your item file under the components section. Ensure that it is properly named.
接着在 BP 文件中确认 `minecraft:icon` 组件配置:
<CodeHeader>BP/items/your_item.json</CodeHeader>
```json
::: code-group
```json [BP/items/your_item.json]
{
"format_version": "1.16.100",
"minecraft:item": {
"description": {
"identifier": "namespace:your_item",
"category" : "items" // This line is required
"category" : "items" // 此字段必须存在
},
"components": {
"minecraft:icon": {
"texture": "your_item_name" // Make sure this string matches the string you put in item_texture.json
"texture": "your_item_name" // 确保此字符串与 item_texture.json 中的键名一致
}
},
"events": {...}
}
}
```
:::
If you followed this properly, your item should now have a texture.
正确配置后物品将正常显示贴图。
### My item is Huge
### 物品模型过大
To turn it to back into a normal size item (`16x16`), use render offsets and the following formula: `base value/(res/16)`
如需恢复标准物品尺寸(`16x16`),使用以下公式计算渲染缩放:`基准值/(分辨率/16)`
The base values, `[0.075, 0.125, 0.075]`, seems to be the about the same scale value as normal items.
推荐使用基准值 `[0.075, 0.125, 0.075]` 可获得近似原版物品的缩放比例。
<CodeHeader>BP/items/your_item.json#components</CodeHeader>
```json
::: code-group
```json [BP/items/your_item.json#components]
"minecraft:render_offsets":{
"main_hand":{
"first_person":{
@@ -237,7 +245,8 @@ The base values, `[0.075, 0.125, 0.075]`, seems to be the about the same scale v
}
}
```
:::
## What now?
## 后续步骤
You've reached the end of the guide. If you still have any problems, feel free to [join the discord server](/discord) and ask your question there.
如果您的问题仍未解决,欢迎[加入 Discord 社区](/discord)进行咨询。

View File

@@ -1,37 +1,40 @@
---
title: Vanilla Usage Components
category: Documentation
title: 原版使用组件
category: 文档
mentions:
- MedicalJewel105
---
This page was created with [Wiki Content Generator](https://github.com/Bedrock-OSS/bedrock-wiki-content-generator). If there are issues, contact us on [Bedrock OSS](https://discord.gg/XjV87YN) Discord server.
Note that not more than 8 examples are shown for each component to keep this page fast to load. Namespace `minecraft` was also removed.
If you want to see full page, you can do it [here](/items/vui-full). *Last updated for 1.20.10*
# 原版使用组件
<!--@include: @/wiki/bedrock-wiki-mirror.md-->
本页面由 [Wiki内容生成器](https://github.com/Bedrock-OSS/bedrock-wiki-content-generator) 创建。如有问题请联系 [Bedrock OSS](https://discord.gg/XjV87YN) Discord 服务器。
注意为保持页面加载速度每个组件最多展示8个示例。命名空间 `minecraft` 已省略。
如需查看完整内容,请访问[此处](/wiki/items/vui-full)。*最后更新版本1.20.10*
## block
<Spoiler title="Show">
<Spoiler title="显示">
camera
<CodeHeader></CodeHeader>
```json
::: code-group
```json [原始CodeHeader的值]
"minecraft:block": "minecraft:camera"
```
:::
</Spoiler>
## camera
<Spoiler title="Show">
<Spoiler title="显示">
camera
<CodeHeader></CodeHeader>
```json
::: code-group
```json [原始CodeHeader的值]
"minecraft:camera": {
"black_bars_duration": 0.2,
"black_bars_screen_ratio": 0.08,
@@ -40,76 +43,76 @@ camera
"slide_away_duration": 0.2
}
```
:::
</Spoiler>
## foil
<Spoiler title="Show">
<Spoiler title="显示">
appleEnchanted
<CodeHeader></CodeHeader>
```json
::: code-group
```json [原始CodeHeader的值]
"minecraft:foil": true
```
:::
golden_apple
<CodeHeader></CodeHeader>
```json
::: code-group
```json [原始CodeHeader的值]
"minecraft:foil": false
```
:::
</Spoiler>
## food
<Spoiler title="Show">
<Spoiler title="显示">
apple
<CodeHeader></CodeHeader>
```json
::: code-group
```json [原始CodeHeader的值]
"minecraft:food": {
"nutrition": 4,
"saturation_modifier": "low"
"nutrition": 4, // 营养值
"saturation_modifier": "low" // 饱和度修正:低
}
```
:::
appleEnchanted
<CodeHeader></CodeHeader>
```json
::: code-group
```json [原始CodeHeader的值]
"minecraft:food": {
"nutrition": 4,
"saturation_modifier": "supernatural",
"can_always_eat": true,
"effects": [
"saturation_modifier": "supernatural", // 超自然饱和度
"can_always_eat": true, // 可随时食用
"effects": [ // 效果列表
{
"name": "regeneration",
"chance": 1.0,
"duration": 30,
"amplifier": 4
"name": "regeneration", // 再生
"chance": 1.0, // 触发概率
"duration": 30, // 持续时间(秒)
"amplifier": 4 // 效果等级
},
{
"name": "absorption",
"name": "absorption", // 伤害吸收
"chance": 1.0,
"duration": 120,
"amplifier": 3
},
{
"name": "resistance",
"name": "resistance", // 抗性提升
"chance": 1.0,
"duration": 300,
"amplifier": 0
},
{
"name": "fire_resistance",
"name": "fire_resistance", // 火焰抗性
"chance": 1.0,
"duration": 300,
"amplifier": 0
@@ -117,420 +120,420 @@ appleEnchanted
]
}
```
:::
baked_potato
<CodeHeader></CodeHeader>
```json
::: code-group
```json [原始CodeHeader的值]
"minecraft:food": {
"nutrition": 5,
"saturation_modifier": "normal"
"saturation_modifier": "normal" // 普通饱和度
}
```
:::
beef
<CodeHeader></CodeHeader>
```json
::: code-group
```json [原始CodeHeader的值]
"minecraft:food": {
"nutrition": 3,
"saturation_modifier": "low"
}
```
:::
beetroot
<CodeHeader></CodeHeader>
```json
::: code-group
```json [原始CodeHeader的值]
"minecraft:food": {
"nutrition": 1,
"saturation_modifier": "normal"
}
```
:::
beetroot_soup
<CodeHeader></CodeHeader>
```json
::: code-group
```json [原始CodeHeader的值]
"minecraft:food": {
"nutrition": 6,
"saturation_modifier": "normal",
"using_converts_to": "bowl"
"using_converts_to": "bowl" // 使用后转换为碗
}
```
:::
bread
<CodeHeader></CodeHeader>
```json
::: code-group
```json [原始CodeHeader的值]
"minecraft:food": {
"nutrition": 5,
"saturation_modifier": "normal"
}
```
:::
carrot
<CodeHeader></CodeHeader>
```json
::: code-group
```json [原始CodeHeader的值]
"minecraft:food": {
"nutrition": 3,
"saturation_modifier": "normal"
}
```
:::
</Spoiler>
## hand_equipped
<Spoiler title="Show">
<Spoiler title="显示">
appleEnchanted
<CodeHeader></CodeHeader>
```json
"minecraft:hand_equipped": false
::: code-group
```json [原始CodeHeader的值]
"minecraft:hand_equipped": false // 是否手持装备
```
:::
</Spoiler>
## max_damage
<Spoiler title="Show">
<Spoiler title="显示">
clownfish
<CodeHeader></CodeHeader>
```json
"minecraft:max_damage": 0
::: code-group
```json [原始CodeHeader的值]
"minecraft:max_damage": 0 // 最大耐久值
```
:::
cooked_fish
<CodeHeader></CodeHeader>
```json
::: code-group
```json [原始CodeHeader的值]
"minecraft:max_damage": 0
```
:::
cooked_salmon
<CodeHeader></CodeHeader>
```json
::: code-group
```json [原始CodeHeader的值]
"minecraft:max_damage": 0
```
:::
fish
<CodeHeader></CodeHeader>
```json
::: code-group
```json [原始CodeHeader的值]
"minecraft:max_damage": 0
```
:::
pufferfish
<CodeHeader></CodeHeader>
```json
::: code-group
```json [原始CodeHeader的值]
"minecraft:max_damage": 0
```
:::
salmon
<CodeHeader></CodeHeader>
```json
::: code-group
```json [原始CodeHeader的值]
"minecraft:max_damage": 0
```
:::
</Spoiler>
## max_stack_size
<Spoiler title="Show">
<Spoiler title="显示">
beetroot_soup
<CodeHeader></CodeHeader>
```json
"minecraft:max_stack_size": 1
::: code-group
```json [原始CodeHeader的值]
"minecraft:max_stack_size": 1 // 最大堆叠数量
```
:::
honey_bottle
<CodeHeader></CodeHeader>
```json
::: code-group
```json [原始CodeHeader的值]
"minecraft:max_stack_size": 16
```
:::
mushroom_stew
<CodeHeader></CodeHeader>
```json
::: code-group
```json [原始CodeHeader的值]
"minecraft:max_stack_size": 1
```
:::
rabbit_stew
<CodeHeader></CodeHeader>
```json
::: code-group
```json [原始CodeHeader的值]
"minecraft:max_stack_size": 1
```
:::
suspicious_stew
<CodeHeader></CodeHeader>
```json
::: code-group
```json [原始CodeHeader的值]
"minecraft:max_stack_size": 1
```
:::
</Spoiler>
## seed
<Spoiler title="Show">
<Spoiler title="显示">
beetroot_seeds
<CodeHeader></CodeHeader>
```json
::: code-group
```json [原始CodeHeader的值]
"minecraft:seed": {
"crop_result": "beetroot"
"crop_result": "beetroot" // 种植产物
}
```
:::
carrot
<CodeHeader></CodeHeader>
```json
::: code-group
```json [原始CodeHeader的值]
"minecraft:seed": {
"crop_result": "carrots"
}
```
:::
glow_berries
<CodeHeader></CodeHeader>
```json
::: code-group
```json [原始CodeHeader的值]
"minecraft:seed": {
"crop_result": "cave_vines",
"plant_at": [
"crop_result": "cave_vines", // 洞穴藤蔓
"plant_at": [ // 可种植位置
"cave_vines",
"cave_vines_head_with_berries"
],
"plant_at_any_solid_surface": true,
"plant_at_face": "DOWN"
"plant_at_any_solid_surface": true, // 可在任意固体表面种植
"plant_at_face": "DOWN" // 种植面:下方
}
```
:::
melon_seeds
<CodeHeader></CodeHeader>
```json
::: code-group
```json [原始CodeHeader的值]
"minecraft:seed": {
"crop_result": "melon_stem"
"crop_result": "melon_stem" // 西瓜茎
}
```
:::
nether_wart
<CodeHeader></CodeHeader>
```json
::: code-group
```json [原始CodeHeader的值]
"minecraft:seed": {
"plant_at": "soul_sand",
"plant_at": "soul_sand", // 必须种植在灵魂沙上
"crop_result": "nether_wart"
}
```
:::
pitcher_pod
<CodeHeader></CodeHeader>
```json
::: code-group
```json [原始CodeHeader的值]
"minecraft:seed": {
"crop_result": "pitcher_crop"
"crop_result": "pitcher_crop" // 投手作物
}
```
:::
potato
<CodeHeader></CodeHeader>
```json
::: code-group
```json [原始CodeHeader的值]
"minecraft:seed": {
"crop_result": "potatoes"
}
```
:::
pumpkin_seeds
<CodeHeader></CodeHeader>
```json
::: code-group
```json [原始CodeHeader的值]
"minecraft:seed": {
"crop_result": "pumpkin_stem"
"crop_result": "pumpkin_stem" // 南瓜茎
}
```
:::
</Spoiler>
## stacked_by_data
<Spoiler title="Show">
<Spoiler title="显示">
appleEnchanted
<CodeHeader></CodeHeader>
```json
"minecraft:stacked_by_data": true
::: code-group
```json [原始CodeHeader的值]
"minecraft:stacked_by_data": true // 允许数据值堆叠
```
:::
clownfish
<CodeHeader></CodeHeader>
```json
::: code-group
```json [原始CodeHeader的值]
"minecraft:stacked_by_data": true
```
:::
cooked_fish
<CodeHeader></CodeHeader>
```json
::: code-group
```json [原始CodeHeader的值]
"minecraft:stacked_by_data": true
```
:::
cooked_salmon
<CodeHeader></CodeHeader>
```json
::: code-group
```json [原始CodeHeader的值]
"minecraft:stacked_by_data": true
```
:::
fish
<CodeHeader></CodeHeader>
```json
::: code-group
```json [原始CodeHeader的值]
"minecraft:stacked_by_data": true
```
:::
golden_apple
<CodeHeader></CodeHeader>
```json
::: code-group
```json [原始CodeHeader的值]
"minecraft:stacked_by_data": true
```
:::
pufferfish
<CodeHeader></CodeHeader>
```json
::: code-group
```json [原始CodeHeader的值]
"minecraft:stacked_by_data": true
```
:::
salmon
<CodeHeader></CodeHeader>
```json
::: code-group
```json [原始CodeHeader的值]
"minecraft:stacked_by_data": true
```
:::
</Spoiler>
## use_duration
<Spoiler title="Show">
<Spoiler title="显示">
apple
<CodeHeader></CodeHeader>
```json
"minecraft:use_duration": 32
::: code-group
```json [原始CodeHeader的值]
"minecraft:use_duration": 32 // 使用耗时tick
```
:::
appleEnchanted
<CodeHeader></CodeHeader>
```json
::: code-group
```json [原始CodeHeader的值]
"minecraft:use_duration": 32
```
:::
baked_potato
<CodeHeader></CodeHeader>
```json
::: code-group
```json [原始CodeHeader的值]
"minecraft:use_duration": 32
```
:::
beef
<CodeHeader></CodeHeader>
```json
::: code-group
```json [原始CodeHeader的值]
"minecraft:use_duration": 32
```
:::
beetroot
<CodeHeader></CodeHeader>
```json
::: code-group
```json [原始CodeHeader的值]
"minecraft:use_duration": 32
```
:::
beetroot_soup
<CodeHeader></CodeHeader>
```json
::: code-group
```json [原始CodeHeader的值]
"minecraft:use_duration": 32
```
:::
bread
<CodeHeader></CodeHeader>
```json
::: code-group
```json [原始CodeHeader的值]
"minecraft:use_duration": 32
```
:::
camera
<CodeHeader></CodeHeader>
```json
::: code-group
```json [原始CodeHeader的值]
"minecraft:use_duration": 100000
```
:::
</Spoiler>
</Spoiler>