完整版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

@@ -6,7 +6,7 @@ import { withMermaid } from "vitepress-plugin-mermaid";
// https://vitepress.dev/reference/site-config // https://vitepress.dev/reference/site-config
export default withMermaid({ export default withMermaid({
lang: 'zh-CN', lang: 'zh-CN',
title: "我的世界中国版 ModSDK", title: "我的世界中国版 Wiki",
description: "ModSDK 开发者文档 镜像,但提供更优质的搜索", description: "ModSDK 开发者文档 镜像,但提供更优质的搜索",
ignoreDeadLinks: true, ignoreDeadLinks: true,
// 替换原生搜索组件,自定义展示的搜索结果内容 // 替换原生搜索组件,自定义展示的搜索结果内容
@@ -59,7 +59,7 @@ export default withMermaid({
// https://vitepress.dev/reference/default-theme-config // https://vitepress.dev/reference/default-theme-config
nav: [ nav: [
{ text: '首页', link: '/' }, { text: '首页', link: '/' },
{ text: 'Wiki', link: '/wiki/0-欢迎' }, { text: 'Wiki', link: '/wiki' },
{ text: 'API文档', link: '/mcdocs/0-欢迎' }, { text: 'API文档', link: '/mcdocs/0-欢迎' },
{ text: '开发指南', link: '/mcguide/0-欢迎' }, { text: '开发指南', link: '/mcguide/0-欢迎' },
{ text: '教学课程', link: '/mconline/0-欢迎' }, { text: '教学课程', link: '/mconline/0-欢迎' },

View File

@@ -0,0 +1,100 @@
<template>
<component
:is="link ? `a` : `button`"
class="btn"
:class="classes"
:href="link"
>
<component
:is="icon"
v-if="icon"
class="btn-icon"
:class="[iconColor]"
/>
<div>
<slot />
</div>
<component
:is="iconRight"
v-if="iconRight"
class="btn-icon"
:class="[iconColor]"
/>
</component>
</template>
<script setup lang="ts">
import { computed } from 'vue'
import type { Component } from 'vue'
const props = defineProps<{
color?: '' | 'green' | 'blue' | 'red'
link?: string
text?: boolean
// Expecting Vue Components
icon?: Component
iconRight?: Component
iconColor?: string
}>()
const classes = computed(() => {
let classes = []
if (props.color) classes.push(props.color)
if (props.text) classes.push('text')
return classes
})
</script>
<style scoped>
.btn {
font-family: inherit;
font-size: inherit;
font-weight: 500;
line-height: 1.5;
@apply px-3 py-1 mx-1 my-2 bg-white rounded-md !no-underline !shadow-md !hover:shadow-sm !focus:shadow-sm !active:shadow-none border !cursor-pointer border-box;
@apply text-true-gray-500 hover:text-true-gray-600 focus:text-true-gray-600 active:text-true-gray-800;
@apply !inline-flex justify-center items-center;
@apply transition-colors;
}
.btn.text {
@apply !bg-transparent border-none !shadow-none !hover:shadow-none !hover:bg-light-50 !hover:bg-opacity-5 !hover:shadow-md;
}
button.btn {
@apply align-bottom;
}
.dark .btn {
@apply bg-true-gray-900;
}
.green {
@apply text-green-500 hover:text-green-600 focus:text-green-600 active:text-green-800;
}
.blue {
@apply text-blue-500 hover:text-blue-600 focus:text-blue-600 active:text-blue-800;
}
.red {
@apply text-red-500 hover:text-red-600 focus:text-red-600 active:text-red-800;
}
.default {
@apply text-dark-500 hover:text-dark-600 focus:text-dark-600 active:text-dark-800;
}
.dark .default {
@apply text-light-500 hover:text-light-600 focus:text-light-600 active:text-light-800;
}
.btn-icon {
fill: currentColor !important;
}
.btn-icon:first-child {
@apply mr-2;
}
.btn-icon:last-child {
@apply ml-2;
}
</style>

View File

@@ -0,0 +1,129 @@
<template>
<label
v-for="el, i in elementsObjects"
:key="i"
class="checklist-label"
>
<input
type="checkbox"
:checked="el.checked === true"
disabled
>
<span
class="checkbox"
:class="{ 'checkbox-checked': el.checked }"
/>
<div
v-if="el.checked"
class="tickmark-checked"
><img src="/assets/images/icons/tick.png"></div>
<div
v-else
class="tickmark-unchecked"
/>
<span
class="checklist-content"
>
{{ el.content }}
</span>
</label>
</template>
<script setup lang="ts">
import { useSlots, ref } from 'vue'
interface IElement {
checked: boolean;
content: string;
}
const slots = useSlots()
let elementsObjects = ref<IElement[]>([])
// get content of slots
// @ts-ignore
slots.default()[0].children.forEach(element => {
element = element.children
if (typeof element === 'object') {
let new_element = ''
// @ts-ignore
element.forEach( e => {
// if element uses some markdown formatting, the formatting will be added manually
if (typeof e.type === 'symbol') {
new_element += e.children
}
else {
// if element uses exactly TWO formattings, they both will be added.
// currently, its not possible to add more than two. I dont know if its even necessary two add this, as the only use of two formattings i am aware of is ***text***.
if (typeof e.children === 'object') {
new_element += `<${e.type}><${e.children[0].type}>` + e.children[0].children + `</${e.children[0].type}></${e.type}>`
}
else {
new_element += `<${e.type}>` + e.children + `</${e.type}>`
}
}
})
element = new_element
}
elementsObjects.value.push({
content: element.startsWith('[x]') ? element.replace('[x]', '') : element.replace('[ ]', ''),
checked: element.startsWith('[x]')
})
})
</script>
<style scoped>
:root {
--tickmark-color: rgb(83, 146, 224);
}
.checklist-label {
display: flex;
align-items: center;
word-break: break-all;
}
.checklist-label input[type='checkbox'] {
visibility: hidden;
}
.checklist-content {
width: 100%;
}
.checkbox {
width: 14px;
height: 14px;
margin-right: 0;
background: rgba(39, 38, 38, 0.719);
border: 1px solid rgb(22, 21, 21);
border-radius: 4px;
}
.checkbox-checked {
background: rgb(204, 225, 250);
}
.tickmark-unchecked {
position: relative;
display: inline-block;
width: 1.1rem;
height: 1rem;
left: -1.08rem;
bottom: 0.27rem;
}
.tickmark-checked {
position: relative;
display: inline-block;
width: 1.1rem;
height: 1rem;
left: -0.9rem;
bottom: 0.52rem;
}
@media screen and (max-width: 768px){
.checklist-content {
width: 80%;
}
}
</style>

View File

@@ -0,0 +1,57 @@
<template>
<div class="border-2 p-2 m-2 rounded-md border-gray">
<FolderViewChild
:depth="-1"
:name="'.'"
:nodes="getData()"
/>
</div>
</template>
<script lang="js">
import FolderViewChild from './FolderViewChild.vue'
export default {
name: 'FolderView',
components: {
FolderViewChild
},
props: {
paths: {
type: Array,
default: () => [],
}
},
methods: {
fillDict(data, path) {
let first = path.shift()
// Create if needed
if (!(first in data)) {
data[first] = {
name: first,
children: {},
}
}
// If there are more paths, recurse
if (path.length > 0) {
this.fillDict(data[first]['children'], path)
}
},
getData() {
let data = {
name: 'root',
children: {},
}
this.paths.forEach(path => {
path = path.split('/')
this.fillDict(data['children'], path)
})
return data
}
},
}
</script>

View File

@@ -0,0 +1,111 @@
<template>
<div>
<div class="flex">
<div
:style="indent"
:class="{ collapsed: collapsed }"
@click="toggleChildren"
>
{{ getDisplay() }}
</div>
</div>
<div :class="{ hidden: collapsed }">
<FolderViewChild
v-for="(node, i) in getNodes()"
:key="i"
:depth="depth + 1"
:nodes="node"
:name="node.name"
/>
</div>
</div>
</template>
<script lang="js">
export default {
name: 'FolderViewChild',
components: {
},
props: {
// eslint-disable-next-line vue/require-prop-types
nodes: {
// eslint-disable-next-line @typescript-eslint/no-empty-function
default: () => {},
},
depth: {
type: Number,
default: () => 0
},
name : {
type: String,
default: () => '???',
}
},
data() {
return { collapsed: false }
},
computed: {
indent() {
return { transform: `translate(${this.depth * 30}px)` }
}
},
methods: {
toggleChildren() {
if (this.isFolder()) {
this.collapsed = !this.collapsed
}
},
getDisplay() {
if (this.depth === -1) {
return ''
}
return this.getIcon(this.name) + this.getName(this.name)
},
isFolder() {
return Object.keys(this.nodes.children).length > 0
},
getNodes() {
return Object.values(this.nodes.children)
},
getIcon(path) {
if (this.isFolder())
{
return '📁'
}
let type = path.split('.').pop()
if (type === 'js' || type === 'ts' || type === 'json' || type === 'mcfunction') {
return '📝'
} else if (type === 'mcstructure') {
return '🏛'
} else if (type === 'png' || type === 'jpg' || type === 'jpeg') {
return '🖼️'
} else if (type === 'ogg' || type === 'wav' || type === 'mp3' || type === 'fsb') {
return '🔊'
} else if (type === 'lang') {
return '🈵'
} else {
return '📁'
}
},
getName(path) {
return path.split('/')[0]
}
},
}
</script>
<style>
.collapsed {
opacity: 0.5;
font-style: italic;
}
.hidden {
display: none;
}
</style>

View File

@@ -2,6 +2,9 @@ import DefaultTheme from 'vitepress/theme'
import MyFeatures from './components/MyFeatures.vue' import MyFeatures from './components/MyFeatures.vue'
import CodeHeader from './components/content/CodeHeader.vue' import CodeHeader from './components/content/CodeHeader.vue'
import WikiImage from './components/content/WikiImage.vue' import WikiImage from './components/content/WikiImage.vue'
import Button from './components/content/Button.vue'
import FolderView from './components/content/FolderView/FolderView.vue'
import Checklist from './components/content/Checklist.vue'
export default { export default {
extends: DefaultTheme, extends: DefaultTheme,
@@ -9,5 +12,8 @@ export default {
app.component('MyFeatures', MyFeatures); app.component('MyFeatures', MyFeatures);
app.component('CodeHeader', CodeHeader); app.component('CodeHeader', CodeHeader);
app.component('WikiImage', WikiImage); app.component('WikiImage', WikiImage);
app.component('BButton', Button);
app.component('Checklist', Checklist);
app.component('FolderView', FolderView);
} }
} }

View File

@@ -3,27 +3,27 @@
layout: home layout: home
hero: hero:
name: "我的世界中国版 ModSDK" name: "我的世界中国版 ModSDK Wiki"
text: "" text: ""
tagline: "ModSDK 开发者文档镜像,但提供更优质的搜索引擎 🤩" tagline: "《我的世界》开发者文档,但提供更优质的搜索引擎 🤩"
actions: actions:
- theme: brand - theme: brand
text: 开始 text: 开始
link: /wiki/0-欢迎 link: /wiki/0-欢迎
features: features:
- icon: 🎯
title: BedrockWiki 中文镜像
details: 国际版社区的超优质文档,助你更快地找到你需要的内容,更深入地理解引擎机制。
link: /wiki
- icon: 🛠️ - icon: 🛠️
title: API文档 title: ModSDK API文档
details: API是构建缤纷方块世界的基石快来查查哪一个是你需要的。 details: 中国版 ModSDKPython2API 文档。相比于官网,我们提供了更优质的搜索引擎!
link: /mcdocs/0-欢迎 link: /mcdocs/0-欢迎
- icon: 📙 - icon: 📙
title: 开发指南 title: 中国版开发指南
details: 在开发指南中浏览每一个开发工具的使用说明,让它们更加得心应手。 details: 在开发指南中浏览每一个开发工具的使用说明,让它们更加得心应手。
link: /mcguide/0-欢迎 link: /mcguide/0-欢迎
- icon: 📝
title: 教学课程
details: 不断更新的系列课程,系统性地帮助您搭建开发知识体系。
link: /mconline/0-欢迎
--- ---
<br> <br>

View File

@@ -1,62 +0,0 @@
---
title: 实验性方块
category: 通用
tags:
- 信息
- 实验性
mentions:
- SmokeyStack
- MedicalJewel105
- QuazChick
---
# 实验性方块
<!--@include: @/wiki/bedrock-wiki-mirror.md-->
:::tip 格式版本 `1.20.30`
在创建自定义方块时使用最新格式版本,可获取最新功能和改进。本维基旨在分享自定义方块的最新信息,当前目标格式版本为 `1.20.30`
:::
本文作为索引文档,概述自定义方块功能的实验性要求。
## 方块组件
| 组件 | 所需实验性功能 |
| ------------------------------------------------------------------------------------------- | --------------------------------- |
| [`minecraft:collision_box`](/blocks/block-components#collision-box) | 无格式版本1.19.50及以上) |
| [`minecraft:crafting_table`](/blocks/block-components#crafting-table) | 无格式版本1.19.50及以上) |
| [`minecraft:destructible_by_explosion`](/blocks/block-components#destructible-by-explosion) | 无 |
| [`minecraft:destructible_by_mining`](/blocks/block-components#destructible-by-mining) | 无 |
| [`minecraft:display_name`](/blocks/block-components#display-name) | 无格式版本1.19.60及以上) |
| [`minecraft:flammable`](/blocks/block-components#flammable) | 无 |
| [`minecraft:friction`](/blocks/block-components#friction) | 无 |
| [`minecraft:geometry`](/blocks/block-components#geometry) | 无格式版本1.19.40及以上) |
| [`minecraft:light_dampening`](/blocks/block-components#light-dampening) | 无 |
| [`minecraft:light_emission`](/blocks/block-components#light-emission) | 无 |
| [`minecraft:loot`](/blocks/block-components#loot) | 无 |
| [`minecraft:map_color`](/blocks/block-components#map-color) | 无 |
| [`minecraft:material_instances`](/blocks/block-components#material-instances) | 无格式版本1.19.40及以上) |
| [`minecraft:placement_filter`](/blocks/block-components#placement-filter) | 无格式版本1.19.60及以上) |
| [`minecraft:selection_box`](/blocks/block-components#selection-box) | 无格式版本1.19.60及以上) |
| [`minecraft:transformation`](/blocks/block-components#transformation) | 无 |
| [`minecraft:unit_cube`](/blocks/block-components#unit-cube) | **`假日创作者功能Holiday Creator Features`** |
## 方块状态
_从实验性功能 **`假日创作者功能`** 中释放适用于格式版本1.19.70及以上。_
## 方块特性
| 特性 | 所需实验性功能 |
| ------------------------------------------------------------------------------- | --------------------------------- |
| [`minecraft:placement_direction`](/blocks/block-components#placement-direction) | 无格式版本1.20.20及以上) |
| [`minecraft:placement_position`](/blocks/block-components#placement-position) | 无格式版本1.20.20及以上) |
## 方块置换
_从实验性功能 **`假日创作者功能`** 中释放适用于格式版本1.19.70及以上。_
## 方块事件与触发器
**完整功能仍处于实验性阶段,需启用 `假日创作者功能`。**

View File

@@ -1,289 +0,0 @@
---
title: Custom Glazed Terracotta
category: Vanilla Re-Creations
tags:
- easy
mentions:
- Kaioga5
---
::: tip FORMAT & MIN ENGINE VERSION `1.20.40`
This tutorial assumes a basic understanding of blocks.
Check out the [blocks guide](/blocks/blocks-intro) before starting.
:::
## Introduction
Glazed Terracotta has its own rotation mechanism, enabling players to craft aesthetically pleasing patterns for walls, floors, and ceilings. This guide will instruct you on creating your own blocks resembling glazed terracotta.
## Custom Glazed Terracotta
This will create a vanilla-like custom glazed terracotta.
<CodeHeader>BP/blocks/custom_glazed_terracotta.json</CodeHeader>
```json
{
"format_version": "1.20.40",
"minecraft:block": {
"description": {
"identifier": "wiki:glazed_terracotta_template",
"menu_category": {
"category": "construction",
"group": "itemGroup.name.glazedTerracotta"
},
"traits": {
"minecraft:placement_direction": {
"enabled_states": [
"minecraft:cardinal_direction"
]
}
}
},
"permutations": [
{
"condition": "q.block_state('minecraft:cardinal_direction') == 'north'",
"components": {
"minecraft:transformation": { "rotation": [0, 0, 0] },
"minecraft:geometry": {
"identifier": "geometry.glazed_terracotta",
"bone_visibility": {
"bottom_1": false,
"bottom_2": false,
"bottom_3": false,
"bottom_4": true
}
}
}
},
{
"condition": "q.block_state('minecraft:cardinal_direction') == 'west'",
"components": {
"minecraft:transformation": { "rotation": [0, 90, 0] },
"minecraft:geometry": {
"identifier": "geometry.glazed_terracotta",
"bone_visibility": {
"bottom_1": false,
"bottom_2": false,
"bottom_3": true,
"bottom_4": false
}
}
}
},
{
"condition": "q.block_state('minecraft:cardinal_direction') == 'south'",
"components": {
"minecraft:transformation": { "rotation": [0, 180, 0] },
"minecraft:geometry": {
"identifier": "geometry.glazed_terracotta",
"bone_visibility": {
"bottom_1": false,
"bottom_2": true,
"bottom_3": false,
"bottom_4": false
}
}
}
},
{
"condition": "q.block_state('minecraft:cardinal_direction') == 'east'",
"components": {
"minecraft:transformation": { "rotation": [0, -90, 0] },
"minecraft:geometry": {
"identifier": "geometry.glazed_terracotta",
"bone_visibility": {
"bottom_1": true,
"bottom_2": false,
"bottom_3": false,
"bottom_4": false
}
}
}
}
],
"components": {
"minecraft:geometry": {
"identifier": "geometry.glazed_terracotta"
},
"minecraft:material_instances": {
"*": {
"texture": "purple_glazed_terracotta",
"render_method": "opaque"
}
}
}
}
}
```
## Geometry
Vanilla glazed terracotta rotates certain faces of the block with some specific values, which is what gives the block it's magic. Use the following geometry to replicate that behavior.
<Spoiler title="Geometry JSON">
<CodeHeader>RP/models/blocks/glazed_terracotta.geo.json</CodeHeader>
```json
{
"format_version": "1.12.0",
"minecraft:geometry": [
{
"description": {
"identifier": "geometry.glazed_terracotta",
"texture_width": 16,
"texture_height": 16,
"visible_bounds_width": 4,
"visible_bounds_height": 3.5,
"visible_bounds_offset": [0, 1.25, 0]
},
"bones": [
{
"name": "glazed_terracotta",
"pivot": [0, 0, 0]
},
{
"name": "top",
"parent": "glazed_terracotta",
"pivot": [0, 0, 0],
"cubes": [
{
"origin": [-8, 0, -8],
"size": [16, 16, 16],
"uv": {
"up": {"uv": [16, 16], "uv_size": [-16, -16]}
}
}
]
},
{
"name": "north",
"parent": "glazed_terracotta",
"pivot": [0, 8, 0],
"cubes": [
{
"origin": [-8, 0, -8],
"size": [16, 16, 0],
"pivot": [0, 8, 0],
"rotation": [180, 0, 90],
"uv": {
"north": {"uv": [16, 16], "uv_size": [-16, -16]}
}
}
]
},
{
"name": "south",
"parent": "glazed_terracotta",
"pivot": [0, 0, 0],
"cubes": [
{
"origin": [0, -8, 8],
"size": [16, 16, 0],
"pivot": [0, 0, 0],
"rotation": [180, 0, 270],
"uv": {
"south": {"uv": [0, 0], "uv_size": [16, 16]}
}
}
]
},
{
"name": "east",
"parent": "glazed_terracotta",
"pivot": [0, 0, 0],
"cubes": [
{
"origin": [-8, -16, -8],
"size": [0, 16, 16],
"pivot": [0, 0, 0],
"rotation": [0, 0, -180],
"uv": {
"east": {"uv": [16, 16], "uv_size": [-16, -16]}
}
}
]
},
{
"name": "west",
"parent": "glazed_terracotta",
"pivot": [-16, 0, 0],
"cubes": [
{
"origin": [-24, 0, -8],
"size": [0, 16, 16],
"pivot": [-16, 0, 0],
"rotation": [0, 180, 0],
"uv": {
"west": {"uv": [16, 16], "uv_size": [-16, -16]}
}
}
]
},
{
"name": "bottom",
"parent": "glazed_terracotta",
"pivot": [0, 0, 0]
},
{
"name": "bottom_1",
"parent": "bottom",
"pivot": [0, 0, 0],
"cubes": [
{
"origin": [-8, 0, -8],
"size": [16, 0, 16],
"uv": {
"down": {"uv": [0, 0], "uv_size": [16, 16]}
}
}
]
},
{
"name": "bottom_2",
"parent": "bottom",
"pivot": [0, 0, 0],
"cubes": [
{
"origin": [-8, 0, -8],
"size": [16, 0, 16],
"uv": {
"down": {"uv": [16, 16], "uv_size": [-16, -16]}
}
}
]
},
{
"name": "bottom_3",
"parent": "bottom",
"pivot": [0, 0, 0],
"cubes": [
{
"origin": [-8, 0, -8],
"size": [16, 0, 16],
"uv": {
"down": {"uv": [0, 0], "uv_size": [16, 16]}
}
}
]
},
{
"name": "bottom_4",
"parent": "bottom",
"pivot": [0, 0, 0],
"cubes": [
{
"origin": [-8, 0, -8],
"size": [16, 0, 16],
"uv": {
"down": {"uv": [16, 16], "uv_size": [-16, -16]}
}
}
]
}
]
}
]
}
```
</Spoiler>

View File

@@ -1,6 +1,6 @@
--- ---
title: 持续效果应用指南 title: 持续效果应用指南
category: 教程 category: 巧思案例
tags: tags:
- 实验性内容 - 实验性内容
- 初级难度 - 初级难度
@@ -16,7 +16,7 @@ mentions:
<!--@include: @/wiki/bedrock-wiki-mirror.md--> <!--@include: @/wiki/bedrock-wiki-mirror.md-->
::: tip 格式要求 & 最低引擎版本 `1.20.30` ::: tip 格式要求 & 最低引擎版本 `1.20.30`
本教程假设您已掌握[方块状态](/blocks/block-states)的基本概念。建议在开始前先阅读[方块基础指南](/blocks/blocks-intro)。 本教程假设您已掌握[方块状态](/wiki/blocks/block-states)的基本概念。建议在开始前先阅读[方块基础指南](/wiki/blocks/blocks-intro)。
::: :::
::: warning 实验性功能 ::: warning 实验性功能

View File

@@ -1,6 +1,6 @@
--- ---
title: 规避状态值上限 title: 规避状态值上限
category: 教程 category: 巧思案例
tags: tags:
- 专家 - 专家
mentions: mentions:

View File

@@ -1,7 +1,7 @@
--- ---
title: 方块组件 title: 方块组件
description: 方块组件用于改变方块在世界中的外观和功能。 description: 方块组件用于改变方块在世界中的外观和功能。
category: 常规 category: 基础
nav_order: 2 nav_order: 2
mentions: mentions:
- SirLich - SirLich
@@ -28,14 +28,14 @@ mentions:
在创建自定义方块时使用最新格式版本可获取最新功能和改进。本wiki旨在提供关于自定义方块的最新信息当前目标格式版本为`1.20.30` 在创建自定义方块时使用最新格式版本可获取最新功能和改进。本wiki旨在提供关于自定义方块的最新信息当前目标格式版本为`1.20.30`
::: :::
:::danger <nbsp/> :::danger <nbsp/>
每个组件在同一时间只能有一个实例生效。重复的组件将被最新的[permutation条件置换](/blocks/block-permutations)覆盖。 每个组件在同一时间只能有一个实例生效。重复的组件将被最新的[permutation条件置换](/wiki/blocks/block-permutations)覆盖。
::: :::
需要事件触发组件?[点击此处查看!](/blocks/block-events#event-triggers) 需要事件触发组件?[点击此处查看!](/wiki/blocks/block-events#event-triggers)
## 应用组件 ## 应用组件
方块组件用于改变方块在世界中的外观和功能。它们被应用在`minecraft:block`或其[permutation条件置换](/blocks/block-permutations)的`components`子项中。 方块组件用于改变方块在世界中的外观和功能。它们被应用在`minecraft:block`或其[permutation条件置换](/wiki/blocks/block-permutations)的`components`子项中。
::: code-group ::: code-group
@@ -264,7 +264,7 @@ _自实验性玩法`Holiday Creator Features`中发布适用于格式版本1.
隐藏模型中骨骼的直接子立方体。 隐藏模型中骨骼的直接子立方体。
**Molang表达式需遵守[条件置换限制](/blocks/block-permutations#permutation-conditions)。** **Molang表达式需遵守[条件置换限制](/wiki/blocks/block-permutations#permutation-conditions)。**
_自格式版本1.20.10起支持`bone_visibility`中的Molang表达式。_ _自格式版本1.20.10起支持`bone_visibility`中的Molang表达式。_
@@ -358,7 +358,7 @@ _自格式版本1.20.10起支持`bone_visibility`中的Molang表达式。_
- 所有实例必须使用相同的渲染方法 - 所有实例必须使用相同的渲染方法
- 与其他方块相交时,方块面会无条件变暗 - 与其他方块相交时,方块面会无条件变暗
材质实例可与`RP/blocks.json`条目结合使用,创建具有类不透明属性的方块。这主要用于在[自定义玻璃方块](/blocks/custom-glass-blocks)上启用面剔除。 材质实例可与`RP/blocks.json`条目结合使用,创建具有类不透明属性的方块。这主要用于在[自定义玻璃方块](/wiki/blocks/custom-glass-blocks)上启用面剔除。
_自实验性玩法`Holiday Creator Features`中发布适用于格式版本1.19.40及以上。_ _自实验性玩法`Holiday Creator Features`中发布适用于格式版本1.19.40及以上。_
@@ -458,7 +458,7 @@ _自实验性玩法`Holiday Creator Features`中发布适用于格式版本1.
``` ```
::: :::
查看[此页面](/blocks/block-tags)获取原版标签及相关方块列表。 查看[此页面](/wiki/blocks/block-tags)获取原版标签及相关方块列表。
## 选择箱 ## 选择箱
@@ -502,7 +502,7 @@ _自实验性玩法`Holiday Creator Features`中发布适用于格式版本1.
**变换后的模型不得超过[几何模型限制](#geometry)。** **变换后的模型不得超过[几何模型限制](#geometry)。**
:::tip :::tip
学习如何应用[可旋转方块](/blocks/rotatable-blocks),就像熔炉和生物头颅一样根据放置方向旋转! 学习如何应用[可旋转方块](/wiki/blocks/rotatable-blocks),就像熔炉和生物头颅一样根据放置方向旋转!
::: :::
::: code-group ::: code-group

View File

@@ -1,7 +1,7 @@
--- ---
title: 方块事件与触发器 title: 方块事件与触发器
description: 方块事件允许你在满足特定条件时操控游戏世界。 description: 方块事件允许你在满足特定条件时操控游戏世界。
category: 常规 category: 基础
nav_order: 8 nav_order: 8
tags: tags:
- 实验性功能 - 实验性功能
@@ -462,7 +462,7 @@ _此示例在实体踏上方块时生成战利品_
## 事件触发器 ## 事件触发器
事件触发器通过[组件](/blocks/block-components)定义,可通过[permutations](/blocks/block-permutations)动态添加、修改或移除。 事件触发器通过[组件](/wiki/blocks/block-components)定义,可通过[permutations](/wiki/blocks/block-permutations)动态添加、修改或移除。
- [`minecraft:on_fall_on`](#跌落触发) - [`minecraft:on_fall_on`](#跌落触发)
- [`minecraft:on_interact`](#交互触发) - [`minecraft:on_interact`](#交互触发)

View File

@@ -1,6 +1,6 @@
--- ---
title: 创建方块模型 title: 创建方块模型
category: 教程 category: 巧思案例
tags: tags:
- 新手 - 新手
- 简单 - 简单
@@ -12,9 +12,9 @@ mentions:
<!--@include: @/wiki/bedrock-wiki-mirror.md--> <!--@include: @/wiki/bedrock-wiki-mirror.md-->
尽管自定义方块无法使用原版的[方块形状](/blocks/block-shapes),但我们可以创建遵循类似实体模型格式的自定义模型。本教程将引导您使用[Blockbench](https://blockbench.net)为"纸袋"创建自定义方块模型。通过学习本教程您将掌握专为自定义方块设计的Minecraft几何体核心功能。 尽管自定义方块无法使用原版的[方块形状](/wiki/blocks/block-shapes),但我们可以创建遵循类似实体模型格式的自定义模型。本教程将引导您使用[Blockbench](https://blockbench.net)为"纸袋"创建自定义方块模型。通过学习本教程您将掌握专为自定义方块设计的Minecraft几何体核心功能。
**注意:** 自定义方块模型必须符合[模型尺寸限制](/blocks/block-components.html#geometry)。 **注意:** 自定义方块模型必须符合[模型尺寸限制](/wiki/blocks/block-components.html#geometry)。
## 模型设置 ## 模型设置

View File

@@ -1,18 +1,18 @@
--- ---
title: 方块变换(转体 title: 方块变换(置换
description: 方块变换数组提供了一种基于当前置换条件性应用组件的方法。 description: 方块变换数组提供了一种基于当前置换条件性应用组件的方法。
category: 常规 category: 基础
nav_order: 7 nav_order: 7
mentions: mentions:
- QuazChick - QuazChick
--- ---
# 方块变换(转体 # 方块变换(置换
<!--@include: @/wiki/bedrock-wiki-mirror.md--> <!--@include: @/wiki/bedrock-wiki-mirror.md-->
:::tip 格式要求 & 最低引擎版本 `1.20.30` :::tip 格式要求 & 最低引擎版本 `1.20.30`
在学习方块变换前,您应当已熟练掌握[方块状态](/blocks/block-states)知识。 在学习方块变换前,您应当已熟练掌握[方块状态](/wiki/blocks/block-states)知识。
使用方块状态时,请确保资源包清单中的`min_engine_version``1.20.20`或更高版本。 使用方块状态时,请确保资源包清单中的`min_engine_version``1.20.20`或更高版本。
::: :::
@@ -25,7 +25,7 @@ mentions:
`permutations`数组是`minecraft:block`的直接子项由包含组件的对象组成。当条件判断为真值非false或0相关组件将被应用。 `permutations`数组是`minecraft:block`的直接子项由包含组件的对象组成。当条件判断为真值非false或0相关组件将被应用。
**置换条件必须遵守其[Molang限制条件](#置换条件限制)。** **置换条件必须遵守其 [限制条件](#置换条件限制)。**
_自实验性玩法`Holiday Creator Features`发布支持格式版本1.19.70及更高。_ _自实验性玩法`Holiday Creator Features`发布支持格式版本1.19.70及更高。_

View File

@@ -1,7 +1,7 @@
--- ---
title: 方块状态 title: 方块状态
description: 方块状态允许你的方块拥有多种变体,每种变体通过使用置换具备独特的功能和外观。 description: 方块状态允许你的方块拥有多种变体,每种变体通过使用置换具备独特的功能和外观。
category: 常规 category: 基础
nav_order: 4 nav_order: 4
mentions: mentions:
- QuazChick - QuazChick
@@ -15,7 +15,7 @@ mentions:
使用方块状态时,请确保资源包清单中的 `min_engine_version` 设置为 `1.20.20` 或更高。 使用方块状态时,请确保资源包清单中的 `min_engine_version` 设置为 `1.20.20` 或更高。
::: :::
方块状态允许你的方块拥有多种变体,每种变体通过使用[置换](/blocks/block-permutations)具备独特的功能和外观。 方块状态允许你的方块拥有多种变体,每种变体通过使用[置换](/wiki/blocks/block-permutations)具备独特的功能和外观。
## 定义状态 ## 定义状态
@@ -23,7 +23,7 @@ mentions:
### 置换数量限制 ### 置换数量限制
**每个状态最多可定义 16 个有效值。所有可能的状态值组合([置换](/blocks/block-permutations))总数不应超过 65,536。** **每个状态最多可定义 16 个有效值。所有可能的状态值组合([置换](/wiki/blocks/block-permutations))总数不应超过 65,536。**
计算方块置换总数时,需将所有状态的有效值数量相乘。例如下方示例的计算公式为 3 × 2 × 3 × 6说明该方块具有 108 种可能的置换组合。 计算方块置换总数时,需将所有状态的有效值数量相乘。例如下方示例的计算公式为 3 × 2 × 3 × 6说明该方块具有 108 种可能的置换组合。
@@ -66,7 +66,7 @@ q.block_state('wiki:string_state_example') == 'blue'
### 命令参数 ### 命令参数
`execute``testforblock` 等命令中使用[方块状态参数](/commands/block-states)来检查状态值。 `execute``testforblock` 等命令中使用[方块状态参数](/wiki/commands/block-states)来检查状态值。
```c ```c
execute if block ~~~ wiki:custom_block["wiki:string_state_example"="blue", "wiki:integer_state_example"=4] run kill execute if block ~~~ wiki:custom_block["wiki:string_state_example"="blue", "wiki:integer_state_example"=4] run kill
@@ -88,7 +88,7 @@ customBlock.permutation.getState("wiki:integer_state_example") === 3
### 命令参数 ### 命令参数
`setblock``fill` 等命令中使用[方块状态参数](/commands/block-states)来修改默认状态值。 `setblock``fill` 等命令中使用[方块状态参数](/wiki/commands/block-states)来修改默认状态值。
```c ```c
setblock ~~~ wiki:custom_block["wiki:string_state_example"="blue", "wiki:integer_state_example"=4] setblock ~~~ wiki:custom_block["wiki:string_state_example"="blue", "wiki:integer_state_example"=4]
@@ -114,7 +114,7 @@ customBlock.setPermutation(
方块事件需启用 `Holiday Creator Features` 实验性玩法。 方块事件需启用 `Holiday Creator Features` 实验性玩法。
::: :::
使用 [`set_block_state`](/blocks/block-events#set-block-state) 事件响应可以修改自定义方块状态的值。 使用 [`set_block_state`](/wiki/blocks/block-events#set-block-state) 事件响应可以修改自定义方块状态的值。
::: code-group ::: code-group
```json [minecraft:block > events] ```json [minecraft:block > events]

View File

@@ -1,6 +1,6 @@
--- ---
title: 方块标签 title: 方块标签
category: 常规 category: 基础
nav_order: 3 nav_order: 3
mentions: mentions:
- SirLich - SirLich

View File

@@ -1,6 +1,6 @@
--- ---
title: 纹理变体 title: 纹理变体
category: 教程 category: 巧思案例
tags: tags:
- 中级 - 中级
mentions: mentions:

View File

@@ -1,7 +1,7 @@
--- ---
title: 方块特性 title: 方块特性
description: 方块特性可轻松为自定义方块应用原版方块状态(如朝向),无需借助事件和触发器。 description: 方块特性可轻松为自定义方块应用原版方块状态(如朝向),无需借助事件和触发器。
category: 常规 category: 基础
nav_order: 5 nav_order: 5
mentions: mentions:
- QuazChick - QuazChick
@@ -12,7 +12,7 @@ mentions:
<!--@include: @/wiki/bedrock-wiki-mirror.md--> <!--@include: @/wiki/bedrock-wiki-mirror.md-->
:::tip 格式要求 & 最低引擎版本 `1.20.30` :::tip 格式要求 & 最低引擎版本 `1.20.30`
在学习方块特性前,您应当已熟练掌握[方块状态](/blocks/block-states)知识。 在学习方块特性前,您应当已熟练掌握[方块状态](/wiki/blocks/block-states)知识。
使用方块状态时,请确保资源包清单中的`min_engine_version``1.20.20`或更高版本。 使用方块状态时,请确保资源包清单中的`min_engine_version``1.20.20`或更高版本。
::: :::

View File

@@ -0,0 +1,62 @@
---
title: 实验性方块
category: 基础
tags:
- 信息
- 实验性
mentions:
- SmokeyStack
- MedicalJewel105
- QuazChick
---
# 实验性方块
<!--@include: @/wiki/bedrock-wiki-mirror.md-->
:::tip 格式版本 `1.20.30`
在创建自定义方块时使用最新格式版本,可获取最新功能和改进。本维基旨在分享自定义方块的最新信息,当前目标格式版本为 `1.20.30`
:::
本文作为索引文档,概述自定义方块功能的实验性要求。
## 方块组件
| 组件 | 所需实验性功能 |
| ------------------------------------------------------------------------------------------- | --------------------------------- |
| [`minecraft:collision_box`](/wiki/blocks/block-components#collision-box) | 无格式版本1.19.50及以上) |
| [`minecraft:crafting_table`](/wiki/blocks/block-components#crafting-table) | 无格式版本1.19.50及以上) |
| [`minecraft:destructible_by_explosion`](/wiki/blocks/block-components#destructible-by-explosion) | 无 |
| [`minecraft:destructible_by_mining`](/wiki/blocks/block-components#destructible-by-mining) | 无 |
| [`minecraft:display_name`](/wiki/blocks/block-components#display-name) | 无格式版本1.19.60及以上) |
| [`minecraft:flammable`](/wiki/blocks/block-components#flammable) | 无 |
| [`minecraft:friction`](/wiki/blocks/block-components#friction) | 无 |
| [`minecraft:geometry`](/wiki/blocks/block-components#geometry) | 无格式版本1.19.40及以上) |
| [`minecraft:light_dampening`](/wiki/blocks/block-components#light-dampening) | 无 |
| [`minecraft:light_emission`](/wiki/blocks/block-components#light-emission) | 无 |
| [`minecraft:loot`](/wiki/blocks/block-components#loot) | 无 |
| [`minecraft:map_color`](/wiki/blocks/block-components#map-color) | 无 |
| [`minecraft:material_instances`](/wiki/blocks/block-components#material-instances) | 无格式版本1.19.40及以上) |
| [`minecraft:placement_filter`](/wiki/blocks/block-components#placement-filter) | 无格式版本1.19.60及以上) |
| [`minecraft:selection_box`](/wiki/blocks/block-components#selection-box) | 无格式版本1.19.60及以上) |
| [`minecraft:transformation`](/wiki/blocks/block-components#transformation) | 无 |
| [`minecraft:unit_cube`](/wiki/blocks/block-components#unit-cube) | **`假日创作者功能Holiday Creator Features`** |
## 方块状态
_从实验性功能 **`假日创作者功能`** 中释放适用于格式版本1.19.70及以上。_
## 方块特性
| 特性 | 所需实验性功能 |
| ------------------------------------------------------------------------------- | --------------------------------- |
| [`minecraft:placement_direction`](/wiki/blocks/block-components#placement-direction) | 无格式版本1.20.20及以上) |
| [`minecraft:placement_position`](/wiki/blocks/block-components#placement-position) | 无格式版本1.20.20及以上) |
## 方块置换
_从实验性功能 **`假日创作者功能`** 中释放适用于格式版本1.19.70及以上。_
## 方块事件与触发器
**完整功能仍处于实验性阶段,需启用 `假日创作者功能`。**

View File

@@ -1,7 +1,6 @@
--- ---
title: 方块入门 title: 方块入门
description: A "Hello world" guide in making blocks. Learn the block format and how to create basic custom blocks. category: 基础
category: General
nav_order: 1 nav_order: 1
--- ---
@@ -10,7 +9,7 @@ nav_order: 1
<!--@include: @/wiki/bedrock-wiki-mirror.md--> <!--@include: @/wiki/bedrock-wiki-mirror.md-->
:::tip 格式版本 & 最低引擎版本 `1.20.30` :::tip 格式版本 & 最低引擎版本 `1.20.30`
本页介绍基础方块特性。更多方块组件内容请访问[此处](/blocks/block-components)。 本页介绍基础方块特性。更多方块组件内容请访问[此处](/wiki/blocks/block-components)。
::: :::
:::danger <nbsp/> :::danger <nbsp/>
@@ -55,11 +54,11 @@ Minecraft 基岩版允许我们添加具有多种类原版特性的自定义方
- 配置方块的`menu_category`归属 - 配置方块的`menu_category`归属
- 可选参数`group``is_hidden_in_commands` - 可选参数`group``is_hidden_in_commands`
_方块描述还包含[状态](/blocks/block-states)和[特性](/blocks/block-traits)相关内容请参见对应页面。_ _方块描述还包含[状态](/wiki/blocks/block-states)和[特性](/wiki/blocks/block-traits)相关内容请参见对应页面。_
## 添加组件 ## 添加组件
目前我们的自定义方块使用的是默认组件值(可参考[此处](/blocks/block-components))。 目前我们的自定义方块使用的是默认组件值(可参考[此处](/wiki/blocks/block-components))。
现在开始自定义功能配置! 现在开始自定义功能配置!
@@ -93,15 +92,15 @@ _方块描述还包含[状态](/blocks/block-states)和[特性](/blocks/block-tr
``` ```
::: :::
- [`minecraft:destructible_by_mining`](/blocks/block-components#destructible-by-mining) 定义玩家破坏方块所需时间(目前无法为不同工具设置不同破坏时间) - [`minecraft:destructible_by_mining`](/wiki/blocks/block-components#destructible-by-mining) 定义玩家破坏方块所需时间(目前无法为不同工具设置不同破坏时间)
- [`minecraft:destructible_by_explosion`](/blocks/block-components#destructible-by-explosion) 定义抗爆性。值越高,被炸毁概率越低 - [`minecraft:destructible_by_explosion`](/wiki/blocks/block-components#destructible-by-explosion) 定义抗爆性。值越高,被炸毁概率越低
- [`minecraft:friction`](/blocks/block-components#friction) 定义方块摩擦系数。例如灵魂沙具有高摩擦值会减缓玩家,冰的低摩擦值则产生滑溜效果。经典方块(如木头/石头)的摩擦系数为`0.4` - [`minecraft:friction`](/wiki/blocks/block-components#friction) 定义方块摩擦系数。例如灵魂沙具有高摩擦值会减缓玩家,冰的低摩擦值则产生滑溜效果。经典方块(如木头/石头)的摩擦系数为`0.4`
- [`minecraft:map_color`](/blocks/block-components#map-color) 是地图上显示的代表色(十六进制)。`#ffffff`代表白色,可通过[在线取色器](https://www.google.com/search?q=hex+color+picker)获取其他颜色代码 - [`minecraft:map_color`](/wiki/blocks/block-components#map-color) 是地图上显示的代表色(十六进制)。`#ffffff`代表白色,可通过[在线取色器](https://www.google.com/search?q=hex+color+picker)获取其他颜色代码
- [`minecraft:light_dampening`](/blocks/block-components#light-dampening) 定义光线阻挡程度 - [`minecraft:light_dampening`](/wiki/blocks/block-components#light-dampening) 定义光线阻挡程度
- [`minecraft:light_emission`](/blocks/block-components#light-emission) 定义方块发光等级 - [`minecraft:light_emission`](/wiki/blocks/block-components#light-emission) 定义方块发光等级
- [`minecraft:loot`](/blocks/block-components#loot) 定义战利品表路径。若移除,方块将默认掉落自身。更多战利品表信息请访问[此处](/loot/loot-tables) - [`minecraft:loot`](/wiki/blocks/block-components#loot) 定义战利品表路径。若移除,方块将默认掉落自身。更多战利品表信息请访问[此处](/wiki/loot/loot-tables)
_更多组件配置请访问[方块组件手册](/blocks/block-components)!_ _更多组件配置请访问[方块组件手册](/wiki/blocks/block-components)!_
## 应用纹理 ## 应用纹理
@@ -109,12 +108,12 @@ _更多组件配置请访问[方块组件手册](/blocks/block-components)!_
`RP/blocks.json`会忽略命名空间。即使不写命名空间或随意填写也不会产生影响。若自定义方块与原版方块同名(仅命名空间不同)可能导致问题 `RP/blocks.json`会忽略命名空间。即使不写命名空间或随意填写也不会产生影响。若自定义方块与原版方块同名(仅命名空间不同)可能导致问题
::: :::
:::tip <nbsp/> :::tip <nbsp/>
[方块音效](/blocks/block-sounds)也可在`RP/blocks.json`中定义 [方块音效](/wiki/blocks/block-sounds)也可在`RP/blocks.json`中定义
::: :::
对于基础的16×16×16像素方块纹理应在`RP/blocks.json`中定义。 对于基础的16×16×16像素方块纹理应在`RP/blocks.json`中定义。
如需使用自定义模型,应使用[geometry几何组件](/blocks/block-components#geometry)和[material_instances材质实例](/blocks/block-components#material-instances)。 如需使用自定义模型,应使用[geometry几何组件](/wiki/blocks/block-components#geometry)和[material_instances材质实例](/wiki/blocks/block-components#material-instances)。
::: code-group ::: code-group
@@ -203,7 +202,7 @@ _更多组件配置请访问[方块组件手册](/blocks/block-components)!_
<br> <br>
若使用[材质实例](/blocks/block-components#material-instances),配置示例如下: 若使用[材质实例](/wiki/blocks/block-components#material-instances),配置示例如下:
::: code-group ::: code-group
@@ -277,7 +276,7 @@ tile.wiki:compass_block.name=指南针方块
``` ```
::: :::
更多本地化内容请访问[文本与翻译指南](/concepts/text-and-translations)。 更多本地化内容请访问[文本与翻译指南](/wiki/concepts/text-and-translations)。
## 成果总结 ## 成果总结

View File

@@ -13,7 +13,7 @@ mentions:
:::tip FORMAT & MIN ENGINE VERSION `1.20.30` :::tip FORMAT & MIN ENGINE VERSION `1.20.30`
This tutorial assumes a good understanding of blocks. This tutorial assumes a good understanding of blocks.
Check out the [blocks guide](/blocks/blocks-intro), [block states](/blocks/block-states) and [block permutations](/blocks/block-permutations) before starting. Check out the [blocks guide](/wiki/blocks/blocks-intro), [block states](/wiki/blocks/block-states) and [block permutations](/wiki/blocks/block-permutations) before starting.
::: :::
:::warning EXPERIMENTAL :::warning EXPERIMENTAL

View File

@@ -1,61 +1,62 @@
--- ---
title: Custom Fluids title: 自定义流体
category: Vanilla Re-Creations category: 原版再创作
tags: tags:
- experimental - 实验性
- intermediate - 中级
- scripting - 脚本
mentions: mentions:
- Provedule - Provedule
- JaylyDev - JaylyDev
- QuazChick - QuazChick
--- ---
::: tip FORMAT & MIN ENGINE VERSION `1.20.30` # 自定义流体
This tutorial assumes an advanced understanding of blocks and the execute command.
Check out the [blocks guide](/blocks/blocks-intro) before starting. ::: tip 格式要求 & 最低引擎版本 `1.20.30`
本教程假设您已具备方块和execute命令的高级知识。
开始前请先阅读[方块指南](/wiki/blocks/blocks-intro)。
::: :::
::: warning EXPERIMENTAL ::: warning 实验性功能
Requires `Holiday Creator Features` for use of block tag Molang queries and to trigger block events. 需要使用`假日创造者功能`来支持方块标签Molang查询和触发方块事件。
Requires `Beta APIs` to use [@minecraft/server](https://learn.microsoft.com/minecraft/creator/scriptapi/minecraft/server/minecraft-server) module version `1.6.0-beta`. 需要使用`Beta API`来调用版本号为`1.6.0-beta`[@minecraft/server](https://learn.microsoft.com/minecraft/creator/scriptapi/minecraft/server/minecraft-server)模块。
::: :::
Creating fluids that are identical to vanilla fluids is not currently possible, but you can make something similar! This template/tutorial is designed to assist you in creating a custom "semi-fluid". 目前尚无法创建与原版完全相同的流体,但您可以制作类似的效果!本模板/教程将指导您创建自定义的"半流体"。
## Flow Logic ## 流动逻辑
- The fluid block has states defining whether it is a source and its depth. - 流体方块具有定义是否为源方块及其深度的状态
- If there is air beneath fluid blocks, it will be converted into falling fluid. - 当流体方块下方存在空气时,会转化为下落的流体
- Fluids with a depth above `1` will spread horizontally with decreasing depths. - 深度大于`1`的流体会向四周扩散并递减深度
- This will not occur if there is falling fluid below. - 若下方存在下落的流体则不会扩散
- Flowing fluid block must have another fluid block adjacent to survive. - 流动方块必须与其他流体方块相邻才能维持存在
- Source blocks do not need to have other fluid blocks surrounding themselves. - 源方块不需要周围有其他流体方块
**This implementation does not include face culling due to its current complexity.** **当前实现因复杂度问题暂未包含面剔除功能**
<WikiImage <WikiImage
src="/assets/images/blocks/custom-fluids/fluid_display.png" src="/assets/images/blocks/custom-fluids/fluid_display.png"
alt="" alt="流体效果展示"
pixelated="true" pixelated="true"
width=608 width=608
/> />
## Source Fluid Block ## 源流体方块
Below is the code for a custom fluid. Copy and quick replace `custom_fluid` with your fluid's name. When the source block detects air in its surroundings, it replaces it with the outer fluid blocks. If the source block detects air beneath it, it will also place a falling fluid block underneath. 以下是自定义流体的基础代码。请将`custom_fluid`全局替换为您的流体名称。当源方块检测到周围存在空气时,会将其替换为外围流体方块。若源方块下方存在空气,则会在下方生成下落的流体方块。
<BButton <BButton
link="https://github.com/Bedrock-OSS/wiki-addon/blob/main/ma-custom_fluids/rp/models/blocks/fluid.geo.json" link="https://github.com/Bedrock-OSS/wiki-addon/blob/main/ma-custom_fluids/rp/models/blocks/fluid.geo.json"
color=blue color=blue
>Download Custom Fluid Geometry</BButton> >下载自定义流体模型</BButton>
<Spoiler title="Custom Fluid Block JSON"> <Spoiler title="自定义流体方块JSON">
<CodeHeader>BP/blocks/custom_fluid.json</CodeHeader> ::: code-group
```json [BP/blocks/custom_fluid.json]
```json
{ {
"format_version": "1.20.30", "format_version": "1.20.30",
"minecraft:block": { "minecraft:block": {
@@ -66,7 +67,7 @@ Below is the code for a custom fluid. Copy and quick replace `custom_fluid` with
}, },
"states": { "states": {
"wiki:source": [true, false], "wiki:source": [true, false],
// Depth of fluid - default to 4 // 流体深度 - 默认为4
"wiki:depth": [4, 5, 3, 2, 1] "wiki:depth": [4, 5, 3, 2, 1]
} }
}, },
@@ -75,17 +76,17 @@ Below is the code for a custom fluid. Copy and quick replace `custom_fluid` with
"minecraft:collision_box": false, "minecraft:collision_box": false,
"minecraft:selection_box": false, "minecraft:selection_box": false,
"minecraft:destructible_by_explosion": false, "minecraft:destructible_by_explosion": false,
// Trigger fluid spread // 触发流体扩散
"minecraft:queued_ticking": { "minecraft:queued_ticking": {
"looping": true, "looping": true,
"interval_range": [20, 20], // Fluid speed in ticks "interval_range": [20, 20], // 流体流速(单位:tick
"on_tick": { "on_tick": {
"event": "wiki:flow" "event": "wiki:flow"
} }
}, },
"minecraft:material_instances": { "minecraft:material_instances": {
"*": { "*": {
"texture": "custom_fluid", // Shortname defined in `RP/textures/terrain_texture.json` "texture": "custom_fluid", // `RP/textures/terrain_texture.json`中定义的短名称
"render_method": "blend", "render_method": "blend",
"ambient_occlusion": false, "ambient_occlusion": false,
"face_dimming": false "face_dimming": false
@@ -97,12 +98,12 @@ Below is the code for a custom fluid. Copy and quick replace `custom_fluid` with
"events": { "events": {
"wiki:flow": { "wiki:flow": {
"sequence": [ "sequence": [
// Dry out // 干涸检测
{ {
"condition": "!q.block_state('wiki:source') && ((q.block_state('wiki:depth') == 5 && !q.block_neighbor_has_any_tag(0, 1, 0, 'custom_fluid')) || (q.block_state('wiki:depth') == 1 && !(q.block_neighbor_has_any_tag(1, 0, 0, 'custom_fluid_2') || q.block_neighbor_has_any_tag(-1, 0, 0, 'custom_fluid_2') || q.block_neighbor_has_any_tag(0, 0, 1, 'custom_fluid_2') || q.block_neighbor_has_any_tag(0, 0, -1, 'custom_fluid_2')) || q.block_state('wiki:depth') == 2 && !(q.block_neighbor_has_any_tag(1, 0, 0, 'custom_fluid_3') || q.block_neighbor_has_any_tag(-1, 0, 0, 'custom_fluid_3') || q.block_neighbor_has_any_tag(0, 0, 1, 'custom_fluid_3') || q.block_neighbor_has_any_tag(0, 0, -1, 'custom_fluid_3'))) || (q.block_state('wiki:depth') == 3 && !(q.block_neighbor_has_any_tag(1, 0, 0, 'custom_fluid_4', 'custom_fluid_5') || q.block_neighbor_has_any_tag(-1, 0, 0, 'custom_fluid_4', 'custom_fluid_5') || q.block_neighbor_has_any_tag(0, 0, 1, 'custom_fluid_4', 'custom_fluid_5') || q.block_neighbor_has_any_tag(0, 0, -1, 'custom_fluid_4', 'custom_fluid_5'))))", "condition": "!q.block_state('wiki:source') && ((q.block_state('wiki:depth') == 5 && !q.block_neighbor_has_any_tag(0, 1, 0, 'custom_fluid')) || (q.block_state('wiki:depth') == 1 && !(q.block_neighbor_has_any_tag(1, 0, 0, 'custom_fluid_2') || q.block_neighbor_has_any_tag(-1, 0, 0, 'custom_fluid_2') || q.block_neighbor_has_any_tag(0, 0, 1, 'custom_fluid_2') || q.block_neighbor_has_any_tag(0, 0, -1, 'custom_fluid_2')) || q.block_state('wiki:depth') == 2 && !(q.block_neighbor_has_any_tag(1, 0, 0, 'custom_fluid_3') || q.block_neighbor_has_any_tag(-1, 0, 0, 'custom_fluid_3') || q.block_neighbor_has_any_tag(0, 0, 1, 'custom_fluid_3') || q.block_neighbor_has_any_tag(0, 0, -1, 'custom_fluid_3'))) || (q.block_state('wiki:depth') == 3 && !(q.block_neighbor_has_any_tag(1, 0, 0, 'custom_fluid_4', 'custom_fluid_5') || q.block_neighbor_has_any_tag(-1, 0, 0, 'custom_fluid_4', 'custom_fluid_5') || q.block_neighbor_has_any_tag(0, 0, 1, 'custom_fluid_4', 'custom_fluid_5') || q.block_neighbor_has_any_tag(0, 0, -1, 'custom_fluid_4', 'custom_fluid_5'))))",
"die": {} "die": {}
}, },
// Spread // 扩散逻辑
{ {
"condition": "q.block_state('wiki:depth') == 4", "condition": "q.block_state('wiki:depth') == 4",
"run_command": { "run_command": {
@@ -162,7 +163,7 @@ Below is the code for a custom fluid. Copy and quick replace `custom_fluid` with
] ]
} }
}, },
// Fall // 下落逻辑
{ {
"run_command": { "run_command": {
"command": "execute if block ~~-1~ air run setblock ~~-1~ wiki:custom_fluid [\"wiki:source\"=false,\"wiki:depth\"=5]" "command": "execute if block ~~-1~ air run setblock ~~-1~ wiki:custom_fluid [\"wiki:source\"=false,\"wiki:depth\"=5]"
@@ -189,7 +190,7 @@ Below is the code for a custom fluid. Copy and quick replace `custom_fluid` with
{ {
"condition": "q.block_state('wiki:source')", "condition": "q.block_state('wiki:source')",
"components": { "components": {
// Enables the block to be picked up by an item of choice // 允许通过指定物品拾取方块
"minecraft:selection_box": { "minecraft:selection_box": {
"origin": [-7.5, 0.5, -7.5], "origin": [-7.5, 0.5, -7.5],
"size": [15, 13, 15] "size": [15, 13, 15]
@@ -242,18 +243,18 @@ Below is the code for a custom fluid. Copy and quick replace `custom_fluid` with
} }
} }
``` ```
:::
</Spoiler> </Spoiler>
## Fluid Bucket ## 流体桶
To place your custom fluid you need a custom bucket item. Below is the JSON for the custom bucket. Replace any instance of `custom_fluid` with your fluid's name. 要放置自定义流体您需要自定义桶物品。以下是流体桶的JSON配置请将`custom_fluid`替换为您的流体名称。
<Spoiler title="Custom Bucket Item JSON"> <Spoiler title="自定义流体桶JSON">
<CodeHeader>BP/items/custom_fluid_bucket.json</CodeHeader> ::: code-group
```json [BP/items/custom_fluid_bucket.json]
```json
{ {
"format_version": "1.20.30", "format_version": "1.20.30",
"minecraft:item": { "minecraft:item": {
@@ -266,7 +267,7 @@ To place your custom fluid you need a custom bucket item. Below is the JSON for
"components": { "components": {
"minecraft:max_stack_size": 1, "minecraft:max_stack_size": 1,
"minecraft:icon": { "minecraft:icon": {
"texture": "custom_fluid_bucket" // Shortname defined in `RP/textures/item_texture.json` "texture": "custom_fluid_bucket" // `RP/textures/item_texture.json`中定义的短名称
}, },
"minecraft:block_placer": { "minecraft:block_placer": {
"block": "wiki:custom_fluid" "block": "wiki:custom_fluid"
@@ -275,16 +276,16 @@ To place your custom fluid you need a custom bucket item. Below is the JSON for
} }
} }
``` ```
:::
</Spoiler> </Spoiler>
## Scripts ## 脚本
The fluids use a script to add the ability for the player to float/sink in the fluid. The script also adds fog. To add your fluid to the script, put the ID of your new fluids in the `fluids` string array. 该脚本为流体添加了玩家漂浮/下沉功能及雾气效果。将您的新流体ID添加到`fluids`字符串数组中即可生效。
<CodeHeader>BP/manifest.json</CodeHeader> ::: code-group
```json [BP/manifest.json]
```json
{ {
"modules": [ "modules": [
... ...
@@ -304,12 +305,12 @@ The fluids use a script to add the ability for the player to float/sink in the f
] ]
} }
``` ```
:::
<Spoiler title="Fluid Movement & Fog Script"> <Spoiler title="流体运动与雾气脚本">
<CodeHeader>BP/scripts/fluids.js</CodeHeader> ::: code-group
```javascript [BP/scripts/fluids.js]
```javascript
import { system, world } from "@minecraft/server"; import { system, world } from "@minecraft/server";
const fluids = ["wiki:custom_fluid"]; const fluids = ["wiki:custom_fluid"];
@@ -318,7 +319,7 @@ system.runInterval(() => {
const players = world.getPlayers(); const players = world.getPlayers();
for (const player of players) { for (const player of players) {
// Fluid effects // 流体效果
if ( if (
fluids.includes(world.getDimension(player.dimension.id).getBlock({ ...player.location, y: player.location.y + 1 }).typeId) || fluids.includes(world.getDimension(player.dimension.id).getBlock({ ...player.location, y: player.location.y + 1 }).typeId) ||
fluids.includes(world.getDimension(player.dimension.id).getBlock(player.location).typeId) fluids.includes(world.getDimension(player.dimension.id).getBlock(player.location).typeId)
@@ -329,7 +330,7 @@ system.runInterval(() => {
player.addEffect("levitation", 3, { amplifier: 2, showParticles: false }); player.addEffect("levitation", 3, { amplifier: 2, showParticles: false });
} }
} }
// Fluid fog // 流体雾气
if (fluids.includes(world.getDimension(player.dimension.id).getBlock({ ...player.location, y: player.location.y + 1.63 }).typeId)) { if (fluids.includes(world.getDimension(player.dimension.id).getBlock({ ...player.location, y: player.location.y + 1.63 }).typeId)) {
player.runCommand("fog @s push wiki:custom_fluid_fog fluid_fog"); player.runCommand("fog @s push wiki:custom_fluid_fog fluid_fog");
} else { } else {
@@ -338,12 +339,13 @@ system.runInterval(() => {
} }
}); });
``` ```
:::
</Spoiler> </Spoiler>
## Result ## 最终成果
By the end your BP folder should look like this: 完成后的BP文件夹结构应如下所示
<FolderView <FolderView
:paths="[ :paths="[
@@ -354,11 +356,11 @@ By the end your BP folder should look like this:
]" ]"
></FolderView> ></FolderView>
## Download Example Pack ## 示例包下载
If anything goes wrong, or if you require all of the template files, they are available for download here. The pack includes everything necessary for a functional fluid. 如果遇到问题或需要完整模板文件,可在此下载。该资源包包含流体所需的所有必要文件。
<BButton <BButton
link="https://github.com/Bedrock-OSS/wiki-addon/releases/download/download/custom_fluids.mcaddon" link="https://github.com/Bedrock-OSS/wiki-addon/releases/download/download/custom_fluids.mcaddon"
color=blue color=blue
>Download MCADDON</BButton> >下载MCADDON</BButton>

View File

@@ -19,7 +19,7 @@ By the end you should be able to create something like this!
::: tip FORMAT VERSION `1.20.30` ::: tip FORMAT VERSION `1.20.30`
This example requires basic knowledge of blocks to understand. This example requires basic knowledge of blocks to understand.
Check out the [blocks guide](/blocks/blocks-intro) before starting. Check out the [blocks guide](/wiki/blocks/blocks-intro) before starting.
::: :::
This will create a custom glass block which appears the same as vanilla glass blocks! This will create a custom glass block which appears the same as vanilla glass blocks!
@@ -64,7 +64,7 @@ This will create a custom glass block which appears the same as vanilla glass bl
::: tip FORMAT & MIN ENGINE VERSION `1.20.30` ::: tip FORMAT & MIN ENGINE VERSION `1.20.30`
This example requires advanced knowledge of blocks and Molang to understand. This example requires advanced knowledge of blocks and Molang to understand.
Check out the [blocks guide](/blocks/blocks-intro), [block states](/blocks/block-states) and [Molang](/concepts/molang) before starting. Check out the [blocks guide](/wiki/blocks/blocks-intro), [block states](/wiki/blocks/block-states) and [Molang](/wiki/concepts/molang) before starting.
::: :::
::: warning EXPERIMENTAL ::: warning EXPERIMENTAL

View File

@@ -0,0 +1,150 @@
---
title: 自定义釉面陶瓦
category: 原版再创作
tags:
- 简单
mentions:
- Kaioga5
---
# 自定义釉面陶瓦
::: tip 格式要求 & 最低引擎版本 `1.20.40`
本教程需要基础的方块制作知识,建议先阅读[方块制作指南](/wiki/blocks/blocks-intro)。
:::
## 前言
釉面陶瓦拥有独特的旋转机制,允许玩家通过不同朝向组合出适用于墙面、地面和天花板的精美图案。本教程将指导您创建类似釉面陶瓦的自定义方块。
## 自定义釉面陶瓦配置
以下配置可实现类原版釉面陶瓦的旋转效果。
::: code-group
```json [BP/blocks/custom_glazed_terracotta.json]
{
"format_version": "1.20.40",
"minecraft:block": {
"description": {
"identifier": "wiki:glazed_terracotta_template",
"menu_category": {
"category": "construction",
"group": "itemGroup.name.glazedTerracotta"
},
"traits": {
"minecraft:placement_direction": {
"enabled_states": [
"minecraft:cardinal_direction"
]
}
}
},
"permutations": [
{
"condition": "q.block_state('minecraft:cardinal_direction') == 'north'",
"components": {
"minecraft:transformation": { "rotation": [0, 0, 0] },
"minecraft:geometry": {
"identifier": "geometry.glazed_terracotta",
"bone_visibility": {
"bottom_1": false,
"bottom_2": false,
"bottom_3": false,
"bottom_4": true
}
}
}
},
// 其他三个方向的配置结构类似
// 此处省略西/南/东方向的配置节以保持简洁
],
"components": {
"minecraft:geometry": {
"identifier": "geometry.glazed_terracotta"
},
"minecraft:material_instances": {
"*": {
"texture": "purple_glazed_terracotta",
"render_method": "opaque"
}
}
}
}
}
```
:::
## 几何结构配置
原版釉面陶瓦通过特殊数值实现方块面的旋转效果。使用以下几何结构配置可复现该特性。
<Spoiler title="几何结构JSON">
::: code-group
```json [RP/models/blocks/glazed_terracotta.geo.json]
{
"format_version": "1.12.0",
"minecraft:geometry": [
{
"description": {
"identifier": "geometry.glazed_terracotta",
"texture_width": 16,
"texture_height": 16,
"visible_bounds_width": 4,
"visible_bounds_height": 3.5,
"visible_bounds_offset": [0, 1.25, 0]
},
"bones": [
// 主要骨骼定义
{
"name": "glazed_terracotta",
"pivot": [0, 0, 0]
},
// 顶部面配置
{
"name": "top",
"parent": "glazed_terracotta",
"pivot": [0, 0, 0],
"cubes": [
{
"origin": [-8, 0, -8],
"size": [16, 16, 16],
"uv": {
"up": {"uv": [16, 16], "uv_size": [-16, -16}
}
}
]
},
// 其他四个方向面配置
// 此处省略北/南/东/西面的详细配置节
// 底部面配置组
{
"name": "bottom",
"parent": "glazed_terracotta",
"pivot": [0, 0, 0]
},
// 四个底部子面配置
{
"name": "bottom_1",
"parent": "bottom",
"pivot": [0, 0, 0],
"cubes": [
{
"origin": [-8, 0, -8],
"size": [16, 0, 16],
"uv": {
"down": {"uv": [0, 0], "uv_size": [16, 16]}
}
}
]
}
// 其他三个底部子面配置类似
]
}
]
}
```
:::
</Spoiler>

View File

@@ -1,36 +1,35 @@
--- ---
title: Custom Slabs title: 自定义台阶
category: Vanilla Re-Creations category: 原版再创作
tags: tags:
- experimental - 实验性
- easy - 简单
mentions: mentions:
- Kaioga5 - Kaioga5
- QuazChick - QuazChick
--- ---
::: tip FORMAT & MIN ENGINE VERSION `1.20.30` ::: tip 格式要求 & 最低引擎版本 `1.20.30`
This tutorial assumes a basic understanding of blocks. 本教程假设您已掌握方块制作基础知识。
Check out the [blocks guide](/blocks/blocks-intro) before starting. 开始前请先阅读[方块制作指南](/wiki/blocks/blocks-intro)
::: :::
::: warning EXPERIMENTAL ::: warning 实验性功能
Requires `Holiday Creator Features` to trigger block events and for use of the `minecraft:unit_cube` component. 需启用 `假日创造者功能` 来触发方块事件和使用 `minecraft:unit_cube` 组件。
::: :::
## Introduction ## 概述
Making custom slabs is a simple task, but if you find any drawbacks during recreating slabs, this tutorial will help you with it, and you'll be provided with a template for you to use. 制作自定义台阶看似简单,但在实际复刻过程中可能会遇到一些技术难点。本教程将为您提供解决方案,并附赠可直接使用的模板。
Issues: 已知问题:
- Your custom slab will appear vertically centred when carried. - 手持自定义台阶时模型会垂直居中显示
- Your custom slab may appear full-sized in item form (on the ground, in item frames, in hand) - 物品形态(地面掉落物/物品展示框/手持时)可能显示完整方块尺寸
## Custom Slab ## 自定义台阶实现
This will create a vanilla-like custom slab. 以下代码将创建与原版风格一致的自定义台阶。
<CodeHeader>BP/blocks/custom_slab.json</CodeHeader> ::: code-group
```json [BP/blocks/custom_slab.json]
```json
{ {
"format_version": "1.20.30", "format_version": "1.20.30",
"minecraft:block": { "minecraft:block": {
@@ -50,7 +49,7 @@ This will create a vanilla-like custom slab.
} }
}, },
"permutations": [ "permutations": [
// Bottom Slab // 下半台阶
{ {
"condition": "q.block_state('minecraft:vertical_half') == 'bottom' && !q.block_state('wiki:double')", "condition": "q.block_state('minecraft:vertical_half') == 'bottom' && !q.block_state('wiki:double')",
"components": { "components": {
@@ -68,7 +67,7 @@ This will create a vanilla-like custom slab.
} }
} }
}, },
// Top Slab // 上半台阶
{ {
"condition": "q.block_state('minecraft:vertical_half') == 'top' && !q.block_state('wiki:double')", "condition": "q.block_state('minecraft:vertical_half') == 'top' && !q.block_state('wiki:double')",
"components": { "components": {
@@ -86,7 +85,7 @@ This will create a vanilla-like custom slab.
} }
} }
}, },
// Double Slab // 双层台阶
{ {
"condition": "q.block_state('wiki:double')", "condition": "q.block_state('wiki:double')",
"components": { "components": {
@@ -128,21 +127,21 @@ This will create a vanilla-like custom slab.
"decrement_stack": {} "decrement_stack": {}
}, },
"wiki:destroy_double": { "wiki:destroy_double": {
"spawn_loot": {} // Spawns the block's default loot "spawn_loot": {} // 生成方块的默认战利品
} }
} }
} }
} }
``` ```
:::
## Geometry ## 几何模型
This will be the geometry used for your custom slabs. 以下是自定义台阶所需的几何模型配置。
<Spoiler title="Geometry JSON"> <Spoiler title="几何模型JSON">
<CodeHeader>RP/models/blocks/slab.geo.json</CodeHeader> ::: code-group
```json [RP/models/blocks/slab.geo.json]
```json
{ {
"format_version": "1.12.0", "format_version": "1.12.0",
"minecraft:geometry": [ "minecraft:geometry": [
@@ -197,5 +196,5 @@ This will be the geometry used for your custom slabs.
] ]
} }
``` ```
:::
</Spoiler> </Spoiler>

View File

@@ -1,6 +1,6 @@
--- ---
title: Custom Trapdoors title: 自定义活板门
category: Vanilla Re-Creations category: 原版再创作
tags: tags:
- experimental - experimental
- intermediate - intermediate
@@ -9,26 +9,27 @@ mentions:
- QuazChick - QuazChick
--- ---
::: tip FORMAT & MIN ENGINE VERSION `1.20.30` # 自定义活板门
This tutorial assumes a good understanding of blocks.
Check out the [blocks guide](/blocks/blocks-intro) before starting. ::: tip 格式与最低引擎版本 `1.20.30`
本教程假定您已具备基础的方块制作知识。
开始前请先阅读[方块制作指南](/wiki/blocks/blocks-intro)。
::: :::
::: warning EXPERIMENTAL ::: warning 实验性功能
Requires `Holiday Creator Features` to trigger block events. 需要启用`假日创作者功能`来触发方块事件。
::: :::
## Introduction ## 前言
Making custom trapdoors is an often difficult task to do, but after reading this tutorial you'll understand how they work in case you find any drawbacks during recreating them, and you'll be provided with a template for you to use. 制作自定义活板门通常是个复杂的任务,但通过本教程您将理解其运作原理(以便在复现过程中遇到任何问题时能够自主解决),同时我们也会提供可直接使用的模板。
## Custom Trapdoor ## 自定义活板门实现
This will create a vanilla-like custom trapdoor. 以下代码将创建具有原版风格的活板门。
<CodeHeader>BP/blocks/custom_trapdoor.json</CodeHeader> ::: code-group
```json [BP/blocks/custom_trapdoor.json]
```json
{ {
"format_version": "1.20.30", "format_version": "1.20.30",
"minecraft:block": { "minecraft:block": {
@@ -51,7 +52,7 @@ This will create a vanilla-like custom trapdoor.
} }
}, },
"permutations": [ "permutations": [
// Top Closed // 顶部关闭状态
{ {
"condition": "q.block_state('minecraft:vertical_half') == 'top' && q.block_state('minecraft:cardinal_direction') == 'north' && !q.block_state('wiki:open')", "condition": "q.block_state('minecraft:vertical_half') == 'top' && q.block_state('minecraft:cardinal_direction') == 'north' && !q.block_state('wiki:open')",
"components": { "components": {
@@ -76,7 +77,7 @@ This will create a vanilla-like custom trapdoor.
"minecraft:transformation": { "rotation": [180, 270, 0] } "minecraft:transformation": { "rotation": [180, 270, 0] }
} }
}, },
// Top Open // 顶部开启状态
{ {
"condition": "q.block_state('minecraft:vertical_half') == 'top' && q.block_state('minecraft:cardinal_direction') == 'north' && q.block_state('wiki:open')", "condition": "q.block_state('minecraft:vertical_half') == 'top' && q.block_state('minecraft:cardinal_direction') == 'north' && q.block_state('wiki:open')",
"components": { "components": {
@@ -103,7 +104,7 @@ This will create a vanilla-like custom trapdoor.
} }
} }
}, },
// Bottom Closed // 底部关闭状态
{ {
"condition": "q.block_state('minecraft:vertical_half') == 'bottom' && q.block_state('minecraft:cardinal_direction') == 'north' && !q.block_state('wiki:open')", "condition": "q.block_state('minecraft:vertical_half') == 'bottom' && q.block_state('minecraft:cardinal_direction') == 'north' && !q.block_state('wiki:open')",
"components": { "components": {
@@ -128,7 +129,7 @@ This will create a vanilla-like custom trapdoor.
"minecraft:transformation": { "rotation": [0, -270, 0] } "minecraft:transformation": { "rotation": [0, -270, 0] }
} }
}, },
// Bottom Open // 底部开启状态
{ {
"condition": "q.block_state('minecraft:vertical_half') == 'bottom' && q.block_state('minecraft:cardinal_direction') == 'north' && q.block_state('wiki:open')", "condition": "q.block_state('minecraft:vertical_half') == 'bottom' && q.block_state('minecraft:cardinal_direction') == 'north' && q.block_state('wiki:open')",
"components": { "components": {
@@ -200,16 +201,16 @@ This will create a vanilla-like custom trapdoor.
} }
} }
``` ```
:::
## Geometry ## 几何模型
This will be the geometry used for your custom trapdoors. 这是活板门所需的几何模型文件。
<Spoiler title="Geometry JSON"> <Spoiler title="几何模型JSON">
<CodeHeader>RP/models/blocks/trapdoor.geo.json</CodeHeader> ::: code-group
```json [RP/models/blocks/trapdoor.geo.json]
```json
{ {
"format_version": "1.12.0", "format_version": "1.12.0",
"minecraft:geometry": [ "minecraft:geometry": [
@@ -246,9 +247,10 @@ This will be the geometry used for your custom trapdoors.
] ]
} }
``` ```
:::
</Spoiler> </Spoiler>
:::tip :::tip
Vanilla trapdoors have a few issues in the direction of the texture in certain faces and having a height of 2.95 when it should be 3. This block template and geometry fixes both of those issues. 原版活板门存在两个问题部分面纹理方向错误以及实际高度应为3却显示为2.95。本模板及配套几何模型已修复这两个问题。
::: :::

View File

@@ -11,7 +11,7 @@ mentions:
::: tip FORMAT & MIN ENGINE VERSION `1.20.30` ::: tip FORMAT & MIN ENGINE VERSION `1.20.30`
This tutorial assumes an advanced understanding of blocks. This tutorial assumes an advanced understanding of blocks.
Check out the [blocks guide](/blocks/blocks-intro) before starting. Check out the [blocks guide](/wiki/blocks/blocks-intro) before starting.
::: :::
::: warning EXPERIMENTAL ::: warning EXPERIMENTAL

View File

@@ -1,6 +1,6 @@
--- ---
title: 伪方块 title: 伪方块
category: 教程 category: 巧思案例
tags: tags:
- 中级 - 中级
mentions: mentions:
@@ -25,7 +25,7 @@ mentions:
## 创建碰撞箱 ## 创建碰撞箱
[固体实体教程](/entities/solid-entities)中介绍了四种创建碰撞箱的方式,涉及 `runtime_identifiers`、方块和组件组合方案。 [固体实体教程](/wiki/entities/solid-entities)中介绍了四种创建碰撞箱的方式,涉及 `runtime_identifiers`、方块和组件组合方案。
## 基础组件 ## 基础组件

View File

@@ -1,7 +1,6 @@
--- ---
title: 纹理动画 title: 纹理动画
category: category: 巧思案例
- 教程
tags: tags:
- 中级 - 中级
mentions: mentions:

12
docs/wiki/blocks/index.md Normal file
View File

@@ -0,0 +1,12 @@
---
title: 方块 Blocks
categories:
- title: 基础
color: blue
- title: 巧思案例
color: green
- title: 原版再创作
color: orange
- title: 文档
color: red
---

View File

@@ -1,6 +1,6 @@
--- ---
title: 矿石战利品表 title: 矿石战利品表
category: 教程 category: 巧思案例
tags: tags:
- 简单 - 简单
mentions: mentions:
@@ -21,7 +21,7 @@ mentions:
::: tip 格式版本 `1.20.30` ::: tip 格式版本 `1.20.30`
本教程假设您已具备方块基础知识。 本教程假设您已具备方块基础知识。
开始前请先查阅[方块指南](/blocks/blocks-intro)。 开始前请先查阅[方块指南](/wiki/blocks/blocks-intro)。
::: :::
::: warning 实验性功能 ::: warning 实验性功能

View File

@@ -1,6 +1,6 @@
--- ---
title: 精确旋转 title: 精确旋转
category: 教程 category: 巧思案例
tags: tags:
- experimental - experimental
- expert - expert
@@ -14,7 +14,7 @@ mentions:
::: tip 格式与最低引擎版本 `1.20.30` ::: tip 格式与最低引擎版本 `1.20.30`
本教程假定您已具备方块的进阶知识与Molang基础。 本教程假定您已具备方块的进阶知识与Molang基础。
开始前建议先阅读[方块指南](/blocks/blocks-intro)。 开始前建议先阅读[方块指南](/wiki/blocks/blocks-intro)。
::: :::
::: warning 实验性功能 ::: warning 实验性功能
@@ -23,7 +23,7 @@ mentions:
本教程将引导您实现可支持次级方位旋转的方块(如爬行者头颅与告示牌),通过一个包含此类旋转类型的"贝壳"方块作为实例进行讲解。 本教程将引导您实现可支持次级方位旋转的方块(如爬行者头颅与告示牌),通过一个包含此类旋转类型的"贝壳"方块作为实例进行讲解。
*查看常规旋转方式?请前往[此页面](/blocks/rotatable-blocks)* *查看常规旋转方式?请前往[此页面](/wiki/blocks/rotatable-blocks)*
![随机朝向的自定义贝壳方块](/assets/images/blocks/precise-rotation/showcase.png) ![随机朝向的自定义贝壳方块](/assets/images/blocks/precise-rotation/showcase.png)
@@ -309,7 +309,7 @@ return t.rotation != 16 ? t.rotation;
<br> <br>
接着,使用[置换](/blocks/block-permutations)定义基础朝向旋转,由模型中的精细骨骼进一步细化。 接着,使用[置换](/wiki/blocks/block-permutations)定义基础朝向旋转,由模型中的精细骨骼进一步细化。
按顺序在方块JSON中添加以下置换条件 按顺序在方块JSON中添加以下置换条件

View File

@@ -1,6 +1,6 @@
--- ---
title: 可旋转方块 title: 可旋转方块
category: 教程 category: 巧思案例
mentions: mentions:
- Ultr4Anubis - Ultr4Anubis
- SmokeyStack - SmokeyStack
@@ -15,8 +15,8 @@ mentions:
<!--@include: @/wiki/bedrock-wiki-mirror.md--> <!--@include: @/wiki/bedrock-wiki-mirror.md-->
::: tip 格式与最低引擎版本 `1.20.30` ::: tip 格式与最低引擎版本 `1.20.30`
本教程假设您已掌握方块基础知识,包括[方块状态](/blocks/block-states)与[方块特性](/blocks/block-traits)。 本教程假设您已掌握方块基础知识,包括[方块状态](/wiki/blocks/block-states)与[方块特性](/wiki/blocks/block-traits)。
开始前请先阅读[方块指南](/blocks/blocks-intro)。 开始前请先阅读[方块指南](/wiki/blocks/blocks-intro)。
::: :::
## 旋转类型 ## 旋转类型
@@ -41,7 +41,7 @@ mentions:
- 适用于原木和玄武岩 - 适用于原木和玄武岩
- 3个轴对齐方向 - 3个轴对齐方向
- ### [精确旋转](/blocks/precise-rotation) - ### [精确旋转](/wiki/blocks/precise-rotation)
- 适用于头颅、告示牌和旗帜 - 适用于头颅、告示牌和旗帜
- 16个方向以22.5度递增) - 16个方向以22.5度递增)
- 4个侧面附着方向 - 4个侧面附着方向

View File

@@ -1,6 +1,6 @@
--- ---
title: 方块故障排除 title: 方块故障排除
category: 常规 category: 基础
tags: tags:
- help - help
mentions: mentions:
@@ -17,7 +17,7 @@ mentions:
<!--@include: @/wiki/bedrock-wiki-mirror.md--> <!--@include: @/wiki/bedrock-wiki-mirror.md-->
:::tip :::tip
本页包含关于_方块_的故障排除信息。在继续阅读前建议先查阅我们的[全局故障排除指南](/guide/troubleshooting)。 本页包含关于_方块_的故障排除信息。在继续阅读前建议先查阅我们的[全局故障排除指南](/wiki/guide/troubleshooting)。
::: :::
## 0.0 - 常见问题 ## 0.0 - 常见问题

View File

@@ -1,54 +1,57 @@
--- ---
title: MBE - Max's Block Entity title: MBE - Max的方块实体
category: Techniques category: 技术
mention: mention:
- BedrockCommands - BedrockCommands
- zheaEvyline - zheaEvyline
tags: tags:
- system - 系统
--- ---
## Introduction # MBE - Max的方块实体
[Sourced By Bedrock Commands Community Discord](https://discord.gg/SYstTYx5G5) <!--@include: @/wiki/bedrock-wiki-mirror.md-->
This method, developed by Reddit user [u/Maxed_Out10](https://www.reddit.com/user/Maxed_Out10/) allows you to create near-perfect entity replications of any Minecraft block using armour stands and some sequential `/playanimation` commands. ## 简介
To preserve credits to the creator, the community termed this method as "Max's Block Entity" or MBE for short. [源自Bedrock Commands社区Discord](https://discord.gg/SYstTYx5G5)
### Points to Note 此方法由Reddit用户[u/Maxed_Out10](https://www.reddit.com/user/Maxed_Out10/)开发,通过使用盔甲架和连续的`/playanimation`命令可以近乎完美地复刻Minecraft中任意方块的实体形态。
1. This method uses 1 armour stand per block entity. Therefore, too many armour stands (like any entity) can contribute to server lag. 为保留原创者荣誉,社区将此方法命名为"Max's Block Entity"简称MBE
2. Players will still be able to pass through them as well as interact with them if not restricted.
3. While the block entity may appear in one spot, it's actual hitbox will have a slight offset.
## Video Demonstration ### 注意事项
1. 每个方块实体需使用1个盔甲架过多盔甲架如同其他实体可能导致服务器卡顿
2. 玩家仍可穿过未加限制的MBE实体并进行交互
3. 方块实体的实际碰撞箱会与视觉位置存在细微偏移
## 视频演示
<YouTubeEmbed <YouTubeEmbed
id="kb8rz9ItE_M" id="kb8rz9ItE_M"
/> />
## Setup ## 设置步骤
*To be typed in chat:* *在聊天栏输入:*
1. `/summon armor_stand Grumm` 1. `/summon armor_stand Grumm`
- It is necessary to name it 'Grumm' to avoid inverted block textures. - 必须命名为'Grumm'以避免纹理倒置
2. `/execute as @e [type= armor_stand, name=Grumm, c=1] at @s run tp @s ~~~ 260` 2. `/execute as @e [type= armor_stand, name=Grumm, c=1] at @s run tp @s ~~~ 260`
- This will align the MBE to the normal Minecraft block grid. - 用于将MBE对齐标准方块网格
:::tip :::tip
- Crouch & right-click (on mcpe: long press) the armor stand 6 times to place it in Pose 7 - 潜行并右键点击手机版长按盔甲架6次进入Pose 7
- Doing this negates the need to use the 2nd command in the system. - 此操作可替代系统中的第二条命令
- **Only use this if you wish to reduce one command from the system.** - **仅在需要精简系统命令时使用**
::: :::
## System ## 系统命令
> Note: adding a delay of 100-200 ticks is recommended. > 注意:建议添加100-200 Tick的延迟
<CodeHeader>mcfunction</CodeHeader> ::: code-group
```yaml [mcfunction]
```yaml
/effect @e [type= armor_stand, name=Grumm] invisibility 999999 1 true /effect @e [type= armor_stand, name=Grumm] invisibility 999999 1 true
/playanimation @e [type= armor_stand, name=Grumm] animation.armor_stand.entertain_pose null 0 "0" align.arms /playanimation @e [type= armor_stand, name=Grumm] animation.armor_stand.entertain_pose null 0 "0" align.arms
/playanimation @e [type= armor_stand, name=Grumm] animation.player.move.arms.zombie null 0 "0" size.mini_block /playanimation @e [type= armor_stand, name=Grumm] animation.player.move.arms.zombie null 0 "0" size.mini_block
@@ -56,118 +59,119 @@ To preserve credits to the creator, the community termed this method as "Max's B
/playanimation @e [type= armor_stand, name=Grumm] animation.fireworks_rocket.move null 0 "0" align.full_block /playanimation @e [type= armor_stand, name=Grumm] animation.fireworks_rocket.move null 0 "0" align.full_block
/execute as @e [type= armor_stand, name=Grumm] at @s run tp ~~~ /execute as @e [type= armor_stand, name=Grumm] at @s run tp ~~~
``` ```
:::
![commandBlockChain6](/assets/images/commands/commandBlockChain/6.png) ![commandBlockChain6](/assets/images/commands/commandBlockChain/6.png)
### Purpose Of Each Command ### 命令功能解析
1. Hides the armour stand body. 1. 隐藏盔甲架本体
2. Automatically sets the armour stand pose to 7 for arms alignment. Skip this command you prefer to do it manually. 2. 自动设置盔甲架为Pose 7手臂对齐手动设置时可跳过
3. __Required command__. Increases size to present as mini-block. 3. __必要命令__ 调整为迷你方块尺寸
4. *Optional command.* Increases size to present as full-block. 4. *可选命令* 调整为完整方块尺寸
5. *Optional command.* Aligns the full-block size MBE properly. 5. *可选命令* 对齐完整方块尺寸
- Skip 4 & 5 if you do not need full-block size MBE. - 若不需要完整方块尺寸可跳过4、5
6. Locks in place to prevent fall in case block underneath is removed. 6. 锁定位置防止下方方块被破坏时坠落
## Rotations & Alignments ## 旋转与对齐
> Note: These rotation commands are to be executed only once through a command block. > 注意:以下旋转命令应通过命令方块单次执行
<Spoiler title="Full MBE"> <Spoiler title="完整方块MBE">
```yaml ```yaml
# Face North # 朝北
/tp @e [type=armor_stand, name=Grumm, c=1] ~-1.1245 ~0.2260 ~-0.097 81 /tp @e [type=armor_stand, name=Grumm, c=1] ~-1.1245 ~0.2260 ~-0.097 81
# Face South # 朝南
/tp @e [type=armor_stand, name=Grumm, c=1] ~1.1245 ~0.2260 ~0.097 260 /tp @e [type=armor_stand, name=Grumm, c=1] ~1.1245 ~0.2260 ~0.097 260
# Face East # 朝东
/tp @e [type=armor_stand, name=Grumm, c=1] ~0.097 ~0.2260 ~-1.1245 171 /tp @e [type=armor_stand, name=Grumm, c=1] ~0.097 ~0.2260 ~-1.1245 171
# Face West # 朝西
/tp @e [type=armor_stand, name=Grumm, c=1] ~-0.097 ~0.2260 ~1.1245 350 /tp @e [type=armor_stand, name=Grumm, c=1] ~-0.097 ~0.2260 ~1.1245 350
``` ```
</Spoiler> </Spoiler>
<Spoiler title="迷你方块MBE">
<Spoiler title="Mini MBE">
```yaml ```yaml
# Face North # 朝北
/tp @e [type=armor_stand, name=Grumm, c=1] ~-0.417~-0.5 ~-0.035 81 /tp @e [type=armor_stand, name=Grumm, c=1] ~-0.417~-0.5 ~-0.035 81
# Face South # 朝南
/tp @e [type=armor_stand, name=Grumm, c=1] ~0.417 ~-0.5 ~0.035 260 /tp @e [type=armor_stand, name=Grumm, c=1] ~0.417 ~-0.5 ~0.035 260
# Face East # 朝东
/tp @e [type=armor_stand, name=Grumm, c=1] ~0.035 ~-0.5 ~-0.417 171 /tp @e [type=armor_stand, name=Grumm, c=1] ~0.035 ~-0.5 ~-0.417 171
# Face West # 朝西
/tp @e [type=armor_stand, name=Grumm, c=1] ~-0.035 ~-0.5 ~0.417 350 /tp @e [type=armor_stand, name=Grumm, c=1] ~-0.035 ~-0.5 ~0.417 350
``` ```
</Spoiler> </Spoiler>
<Spoiler title="Stair MBE"> <Spoiler title="阶梯MBE">
```yaml ```yaml
# Face North # 朝北
/tp @e [type=armor_stand, name=Grumm, c=1] ~-0.097 ~0.2325 ~1.1245 350 /tp @e [type=armor_stand, name=Grumm, c=1] ~-0.097 ~0.2325 ~1.1245 350
# Face South # 朝南
/tp @e [type=armor_stand, name=Grumm, c=1] ~0.097 ~0.2325 ~-1.1245 171 /tp @e [type=armor_stand, name=Grumm, c=1] ~0.097 ~0.2325 ~-1.1245 171
# Face East # 朝东
/tp @e [type=armor_stand, name=Grumm, c=1] ~-1.1245 ~0.2325 ~-0.097 81 /tp @e [type=armor_stand, name=Grumm, c=1] ~-1.1245 ~0.2325 ~-0.097 81
# Face West # 朝西
/tp @e [type=armor_stand, name=Grumm, c=1] ~1.1245 ~0.2325 ~0.097 260 /tp @e [type=armor_stand, name=Grumm, c=1] ~1.1245 ~0.2325 ~0.097 260
``` ```
</Spoiler> </Spoiler>
<Spoiler title="Bottom Slab MBE"> <Spoiler title="下半砖MBE">
```yaml ```yaml
# Face North # 朝北
/tp @e [type=armor_stand, name=Grumm, c=1] ~-0.097 ~0.2325 ~1.1245 350 /tp @e [type=armor_stand, name=Grumm, c=1] ~-0.097 ~0.2325 ~1.1245 350
# Face South # 朝南
/tp @e [type=armor_stand, name=Grumm, c=1] ~0.097 ~0.2325 ~-1.1245 171 /tp @e [type=armor_stand, name=Grumm, c=1] ~0.097 ~0.2325 ~-1.1245 171
# Face East # 朝东
/tp @e [type=armor_stand, name=Grumm, c=1] ~-1.1245 ~0.2325 ~-0.097 81 /tp @e [type=armor_stand, name=Grumm, c=1] ~-1.1245 ~0.2325 ~-0.097 81
# Face West # 朝西
/tp @e [type=armor_stand, name=Grumm, c=1] ~1.1245 ~0.2325 ~0.097 260 /tp @e [type=armor_stand, name=Grumm, c=1] ~1.1245 ~0.2325 ~0.097 260
``` ```
</Spoiler> </Spoiler>
<Spoiler title="Top Slab MBE"> <Spoiler title="上半砖MBE">
```yaml ```yaml
# Face North # 朝北
/tp @e [type=armor_stand, name=Grumm, c=1] ~-1.1245 ~0.484 ~-0.097 81 /tp @e [type=armor_stand, name=Grumm, c=1] ~-1.1245 ~0.484 ~-0.097 81
# Face South # 朝南
/tp @e [type=armor_stand, name=Grumm, c=1] ~1.1245 ~0.484 ~0.097 260 /tp @e [type=armor_stand, name=Grumm, c=1] ~1.1245 ~0.484 ~0.097 260
# Face East # 朝东
/tp @e [type=armor_stand, name=Grumm, c=1] ~0.097 ~0.484 ~-1.1245 171 /tp @e [type=armor_stand, name=Grumm, c=1] ~0.097 ~0.484 ~-1.1245 171
# Face West # 朝西
/tp @e [type=armor_stand, name=Grumm, c=1] ~-0.097 ~0.484 ~1.1245 350 /tp @e [type=armor_stand, name=Grumm, c=1] ~-0.097 ~0.484 ~1.1245 350
``` ```
</Spoiler> </Spoiler>
## Saving & Loading MBE ## 保存与加载MBE
1. To save run: 1. 保存命令:
- `/execute as @e [type=armor_stand, name=Grumm, c=1] at @s run structure save MBE ~~~ ~~~` - `/execute as @e [type=armor_stand, name=Grumm, c=1] at @s run structure save MBE ~~~ ~~~`
2. To load run: 2. 加载命令:
- `/structure load MBE <coordinates>` - `/structure load MBE <坐标>`
> Note: structure name `MBE` can be changed to your preference. > 注意:结构名称`MBE`可根据需要更改

View File

@@ -1,118 +1,125 @@
--- ---
title: Block States title: 方块状态
category: General category: 基础
mentions: mentions:
- BedrockCommands - BedrockCommands
- zheaEvyline - zheaEvyline
- SmokeyStack - SmokeyStack
- ThomasOrs - ThomasOrs
tags: tags:
- info - 信息
--- ---
## Introduction # 方块状态
[Sourced by Bedrock Commands Community Discord](https://discord.gg/SYstTYx5G5) <!--@include: @/wiki/bedrock-wiki-mirror.md-->
Block States or Block Properties are additional data that defines how the block appears or behaves. Such as the direction it is facing, it's color, it's variant, whether it is powered or unpowered and so on. ## 引言
This is used in a multitude of commands such as `/clone`, `/execute`, `/fill`, `/setblock` and `/testforblock` [由Bedrock Commands社区Discord提供](https://discord.gg/SYstTYx5G5)
In Bedrock Edition we used Aux values (also known as Metadata) to define a block. However; as of 1.19.70 and beyond this is no longer supported and have been fully replaced with Block States instead. 方块状态Block States或方块属性Block Properties是用于定义方块外观或行为的附加数据。例如方块的朝向、颜色、变种、是否充能等特性。
<CodeHeader>example</CodeHeader> 这些数据被广泛应用于多个命令中,包括但不限于:
- `/clone`
- `/execute`
- `/fill`
- `/setblock`
- `/testforblock`
```yaml 在基岩版中我们曾使用辅助值Aux Values也称元数据来定义方块。然而自1.19.70版本起,该机制已被全面弃用,并由方块状态完全取代。
#Aux Value Example:
::: code-group
```yaml [辅助值]
#辅助值示例:
/setblock ~ ~ ~ wool 1 /setblock ~ ~ ~ wool 1
#It's Block State equivalent: #等效的方块状态写法:
/setblock ~ ~ ~ wool ["color"="orange"] /setblock ~ ~ ~ wool ["color"="orange"]
``` ```
:::
- Any command block using aux values will continue to function as it is however block states will need to be adopted when updating them. - 使用辅助值的命令方块仍可继续工作,但在更新时需要改用方块状态
- Similarly any commands using aux values in behaviour or function packs with `min_engine_version` 1.19.63 or below will also continue to function however block states must be adopted if the `min_engine_version` is updated to 1.19.70 or above. - 同理,在行为包或功能包中使用辅助值的命令,若`min_engine_version`设置为1.19.63或更低版本仍可正常工作但若将最低引擎版本更新至1.19.70或更高则必须改用方块状态
## Block State Examples & Syntax ## 方块状态示例与语法
<CodeHeader>Examples</CodeHeader> ::: code-group
```yaml [示例]
```yaml
/setblock ~ ~ ~ wool ["color"="white"] /setblock ~ ~ ~ wool ["color"="white"]
/setblock ~ ~ ~ wheat ["growth"=0] /setblock ~ ~ ~ wheat ["growth"=0]
/setblock ~ ~ ~ wood ["wood_type"="birch","stripped_bit"=true] /setblock ~ ~ ~ wood ["wood_type"="birch","stripped_bit"=true]
/setblock ~ ~ ~ wool [] /setblock ~ ~ ~ wool []
``` ```
:::
- Block states are enclosed in square brackets ` [ ] ` - 方块状态需用方括号 `[ ]` 包裹
- When specifying multiple block states a comma ` , ` is used to separate them. - 多个状态间用逗号 `,` 分隔
- Quotation marks ` " " ` are used around strings such as `"birch", "spruce" etc..` - 字符串值需使用双引号包裹,如 `"birch"`、`"spruce"` 等
- Integer values `0, 1, 2..` and boolean values `true/false` do not use quotation marks. - 整数值 `0, 1, 2...` 和布尔值 `true/false` 无需引号
- Leaving the brackets blank is also a correct syntax, it will simply default to 0. - 空括号 `[]` 是有效语法表示使用默认值0
- `wool 0` is white wool hence you may simply write it as `wool []` instead of `wool ["color"="white"]` - `wool 0` 对应白色羊毛,因此可简写为 `wool []` 替代 `wool ["color"="white"]`
### Notes For Beginners ### 新手须知
- **Integers** are whole numbers. They are used to define a block from a 'range' of values. - **整数(Integer**:用于定义数值范围
- Example: Redstone power 1 to 15 - 示例红石信号强度1-15
- `["redstone_power"=10]` - `["redstone_power"=10]`
- **Boolean** is a programming term which refers to `true/false` values. You can simply understand it as yes or no questions. - **布尔值(Boolean**:表示二值状态(真/假)
- Is this piston powered? `yes/no` - 是否被激活?是否被按下?是否去皮?
- Is this button pressed? `yes/no` - `["stripped_bit"=true]`
- Is this log stripped? `yes/no`
- `["stripped_bit"=true]`
- **Strings** are unique 'text' inputs. You can simply understand it as multiple choice questions. - **字符串(String**:用于多选类型
- What color is this wool? `"white"`, `"orange"`, `"brown"` etc.. - 羊毛颜色?原木种类?
- What wood type is this log? `"spruce"`, `"birch"`, `"acacia"` etc.. - `["wood_type"="spruce"]`
- `["wood_type"="spruce"]`
## 方块状态列表
完整方块状态清单可访问微软官方文档:
## Block States List
A list of all the block states currently available within Bedrock can be found at:
https://learn.microsoft.com/en-us/minecraft/creator/reference/content/blockreference/examples/blockstateslist https://learn.microsoft.com/en-us/minecraft/creator/reference/content/blockreference/examples/blockstateslist
Note: In the site block states may be written as one word but make sure to separate them with underscores `_` when typing in commands. 注意:文档中可能出现连写的状态名称,但在命令中需使用下划线 `_` 分隔
Example: `buttonPressedBit``"button_pressed_bit"` 示例:`buttonPressedBit` → `"button_pressed_bit"`
## Converting Aux Values to Block States ## 辅助值与方块状态转换
For your convenience; download any of the excel sheet below to find the full list of block IDs, their aux values and equivalent block states in Bedrock. *Shared by kayla@Mojang* 可通过下方表格下载完整转换对照表(由kayla@Mojang提供):
<BButton <BButton
link="https://github.com/BedrockCommands/bedrockcommands.github.io/files/10987839/Aux-Value_to_Block-States_Map.xlsx" link="https://github.com/BedrockCommands/bedrockcommands.github.io/files/10987839/Aux-Value_to_Block-States_Map.xlsx"
color=white color=white
>Download Sheet 1</BButton> >下载表格1</BButton>
Note: the above sheet was quickly generated and contains some minor errors. Boolean values `0` should be replaced with `false` and `1` should be replaced with `true` since the game doesn't recognize the syntax otherwise. 注意:此表格为快速生成版本,布尔值需手动将`0`改为`false``1`改为`true`
Alternate sheet: *Shared by @ItsRichHeart* 替代表格(由@ItsRichHeart提供):
<BButton <BButton
link="https://github.com/BedrockCommands/bedrockcommands.github.io/files/11069804/All.Block-Item.List.Bedrock.pdf" link="https://github.com/BedrockCommands/bedrockcommands.github.io/files/11069804/All.Block-Item.List.Bedrock.pdf"
color=white color=white
>Download Sheet 2</BButton> >下载表格2</BButton>
You may also use this [Lookup Table](https://auxval-to-blockstates.netlify.app/) instead not needing to download any files. 也可使用在线[查询工具](https://auxval-to-blockstates.netlify.app/)免下载转换
## Known Issue ## 已知问题
Detecting blocks using commands such as `/execute` or `/testforblock` requires __all__ or __none__ of the block states specified else the command returns an error. 使用 `/execute` 或 `/testforblock` 检测方块时,必须指定全部或完全不指定方块状态,否则会报错
Example; detecting a pressed stone button on ground facing up: 示例:检测朝上方向被按下的石质按钮:
<CodeHeader></CodeHeader>
::: code-group
```yaml ```yaml
#✅ Accepted: #✅ 有效写法:
/execute if block ~~~ stone_button [“button_pressed_bit”=true,”facing_direction”=1] run say success /execute if block ~~~ stone_button [“button_pressed_bit”=true,”facing_direction”=1] run say success
/execute if block ~~~ stone_button run say success /execute if block ~~~ stone_button run say success
# ❌ Not Accepted: # ❌ 无效写法:
/execute if block ~~~ stone_button [“button_pressed_bit”=true] run say success /execute if block ~~~ stone_button [“button_pressed_bit”=true] run say success
/execute if block ~~~ stone_button [“facing_direction”=1] run say success /execute if block ~~~ stone_button [“facing_direction”=1] run say success
``` ```
Though block states have replaced aux values, we still cannot detect blocks based on specific filters yet like we do with selector arguments. :::
### Related Bug Reports 虽然方块状态已取代辅助值,但目前仍无法像选择器参数那样进行精确过滤
### 相关漏洞报告
- [MCPE-133360](https://bugs.mojang.com/browse/MCPE-133360) - [MCPE-133360](https://bugs.mojang.com/browse/MCPE-133360)
- [MCPE-168391](https://bugs.mojang.com/browse/MCPE-168391) - [MCPE-168391](https://bugs.mojang.com/browse/MCPE-168391)

View File

@@ -1,8 +1,8 @@
--- ---
title: Damage title: 伤害指令
category: Commands category: 命令
tags: tags:
- info - 信息
mentions: mentions:
- BedrockCommands - BedrockCommands
- cda94581 - cda94581
@@ -10,87 +10,100 @@ mentions:
- zheaEvyline - zheaEvyline
--- ---
## Introduction # 伤害指令
[Sourced By Bedrock Commands Community Discord](https://discord.gg/SYstTYx5G5) <!--@include: @/wiki/bedrock-wiki-mirror.md-->
Introduced in Minecraft Release `1.18.10`, the /damage command deals precise damage to specified entities. With this change, the clunky methods like using `/effect` command to damage entities are rendered obsolete, making maps and other creations more powerful. ## 概述
## Syntax [源自Bedrock Commands社区Discord](https://discord.gg/SYstTYx5G5)
- There are two ways the damage command can be used: `/damage` 指令于Minecraft基岩版 `1.18.10` 版本加入,可对指定实体造成精确伤害。这一改进使得原先使用 `/effect` 指令等笨拙的伤害方式成为历史,为地图制作和其他创作提供了更强大的工具。
- `/damage <Target> <Amount> [Cause]`
- `/damage <Target> <Amount> <Cause> entity <Damager>`
## Arguments ## 语法结构
- Phrases not contained in angle <> or square [] brackets instruct you to type it as-is. - 该指令有两种使用方式:
- Phrases contained within brackets are variables, these need to be replaced: - `/damage <目标> <伤害值> [伤害原因]`
- **` <> `** Angle brackets mean the variable is required. - `/damage <目标> <伤害值> <伤害原因> entity <伤害源实体>`
- **` [] `** Square brackets mean the variable is optional.
## Variables ## 参数说明
- **` Target `** This is your typical entity selector, such as `@s` , `@e` , or `"cda94581"` . Multiple entities may be selected at a time to deal the damage to multiple targets. - 未包含在尖括号 `<>` 或方括号 `[]` 中的短语需按原样输入
- 括号内内容为可变参数,需要替换为实际值:
- **` <> `** 尖括号表示必填参数
- **` [] `** 方括号表示可选参数
- **` Amount `** This is a whole number, which specifies the amount of damage to deal to the targets. The minimum value is `0` and the maximum value is `2147483647`, or the signed 32-bit integer limit. ## 参数详解
- **` Cause `** This specifies the "reason" the damage was dealt. This cause will appear in death messages (`X hit the ground too hard for cause: fall`) be used in damage calculation with armor (`the value dealt in Amount may be different depending on the worn armor`), and used in a large variety of other things, such as in Behavior Pack/Add-ons. A full list of all the damage causes can be found [below](/commands/damage#damage-cause-list) - **` 目标 `**
常规实体选择器,如 `@s``@e``"cda94581"`。支持同时选择多个实体进行群体伤害。
- **` Damager `** If Cause was something to do with entities `(such as entity_attack)`, this specifies where the damage came from `(the entity that dealt the attack)`. This is limited to only 1 target. An error will be thrown if multiple targets are found from the selector. - **` 伤害值 `**
整数类型,指定造成的伤害数值。最小值为 `0`最大值为32位有符号整数上限 `2147483647`
> Note: the `<Cause> entity <Damager>` is only required when the Cause has to do with another entity `(entity_attack)`. Otherwise, follow the first syntax. - **` 伤害原因 `**
决定伤害来源类型。该参数将影响:
- 死亡提示信息(如 `X因坠落伤害而亡`
- 护甲减伤计算(实际伤害值会根据护甲属性变化)
- 行为包/附加包中的伤害处理逻辑
完整伤害原因列表详见[下方章节](/wiki/commands/damage#damage-cause-list)
## Examples - **` 伤害源实体 `**
当伤害原因与实体相关时(如 `entity_attack`),此参数指定伤害来源实体。该选择器仅支持单个目标,若返回多个实体会报错。
<CodeHeader>mcfunction</CodeHeader> > 注意:`<伤害原因> entity <伤害源实体>` 语法仅在伤害原因涉及其他实体时使用(如实体攻击)。其他情况请使用基础语法。
```yaml
#Deal 4 damage to all players ## 使用示例
::: code-group
```yaml [mcfunction]
# 对所有玩家造成4点伤害
/damage @a 4 /damage @a 4
#Deal 3 'fire' damage to all entities of type 'sheep' # 对所有绵羊造成3点火焰伤害
/damage @e [type=sheep] 3 fire /damage @e[type=sheep] 3 fire
#Deal 40 'entity attack' damage from a random player to all entities of type 'sheep' # 让随机玩家对所有绵羊造成40点实体攻击伤害
/damage @a 40 entity_attack entity @r [type=sheep] /damage @e[type=sheep] 40 entity_attack entity @r
``` ```
:::
## Damage Cause List ## 伤害原因列表
Listed below are all the 'damage sources' in MCBE for the `/damage` command currently available: 以下是MCBE中 `/damage` 指令当前支持的所有伤害原因:
```
anvil
attack
block_explosion
charging
contact
drowning
entity_attack
entity_explosion
fall
falling_block
fatal
fire
fire_tick
fireworks
fly_into_wall
freezing
lava
lightning
magic
magma
none
override
piston
projectile
sonic_boom
stalactite
stalagmite
starve
suffocation
suicide
temperature
thorns
void
wither
``` ```
anvil # 铁砧
attack # 普通攻击
block_explosion # 方块爆炸
charging # 冲锋(如幻翼)
contact # 接触伤害(如仙人掌)
drowning # 溺水
entity_attack # 实体攻击
entity_explosion # 实体爆炸
fall # 坠落
falling_block # 下坠方块
fatal # 致命伤害
fire # 火焰
fire_tick # 燃烧伤害
fireworks # 烟花
fly_into_wall # 飞行撞墙(鞘翅)
freezing # 冰冻
lava # 岩浆
lightning # 闪电
magic # 魔法
magma # 岩浆块
none # 无来源
override # 强制覆盖
piston # 活塞
projectile # 弹射物
sonic_boom # 监守者音波
stalactite # 钟乳石
stalagmite # 石笋
starve # 饥饿
suffocation # 窒息
suicide # 自杀
temperature # 温度伤害
thorns # 荆棘
void # 虚空
wither # 凋零
```

View File

@@ -1,77 +1,83 @@
--- ---
title: Entity Counter title: 实体计数器
category: Scoreboard Systems category: 计分板系统
mentions: mentions:
- BedrockCommands - BedrockCommands
- zheaEvyline - zheaEvyline
nav_order: 3 nav_order: 3
tags: tags:
- system - 系统
--- ---
## Introduction # 实体计数器
[Sourced By Bedrock Commands Community Discord](https://discord.gg/SYstTYx5G5) <!--@include: @/wiki/bedrock-wiki-mirror.md-->
This system allows you to track how many players/entities are there on your world and run your desired commands based on the values obtained. ## 前言
> Note: you cannot track entities in unloaded chunks though players can still be tracked regardless. [源自Bedrock Commands社区Discord](https://discord.gg/SYstTYx5G5)
## Setup 本系统可用于追踪世界中玩家/实体的数量,并根据获取的数值执行自定义命令。
*To be typed in Chat:* > 注意:无法追踪未加载区块中的实体,但玩家无论是否在加载区块中都可被追踪。
## 初始化设置
*在聊天栏输入:*
`/scoreboard objectives add total dummy` `/scoreboard objectives add total dummy`
If you prefer to have the objective added automatically on world initialisation, follow the process outlined in [On First World Load.](/commands/on-first-world-load) 若希望在世界初始化时自动添加该计分项,请参照[首次世界加载](/wiki/commands/on-first-world-load)中的流程进行设置。
## System ## 核心系统
<CodeHeader>BP/functions/entity_counter.mcfunction</CodeHeader> ::: code-group
```yaml [BP/functions/entity_counter.mcfunction]
```yaml
scoreboard players set onlinePlayers total 0 scoreboard players set onlinePlayers total 0
execute as @e [type=player] run scoreboard players add onlinePlayers total 1 execute as @e [type=player] run scoreboard players add onlinePlayers total 1
#Your Commands Here (examples) # 在此处添加你的命令(示例)
execute if score onlinePlayers total matches 4.. run title @a actionbar Enough players to start game. execute if score onlinePlayers total matches 4.. run title @a actionbar 玩家数量已满足游戏条件。
execute if score onlinePlayers total matches ..3 run title @a actionbar Not enough players. execute if score onlinePlayers total matches ..3 run title @a actionbar 玩家数量不足。
``` ```
:::
![commandBlockChain3](/assets/images/commands/commandBlockChain/3.png) ![commandBlockChain3](/assets/images/commands/commandBlockChain/3.png)
本示例使用名为`onlinePlayers`的虚拟玩家分数,通过选择器`@e [type=player]`追踪当前在线玩家数量。您可以根据需求使用任意虚拟玩家名称和实体类型,例如`@e [type=creeper]`来追踪苦力怕数量。
Here we have used a FakePlayer name `onlinePlayers` and targeting `@e [type=player]` to track how many players are currently on the world. However you may use any FakePlayer name and target any entity you might need. Such as `@e [type=creeper]` 示例中使用的`/title`命令演示了两种条件判断:
- a) 当玩家数≥4时触发 `4..`
- b) 当玩家数≤3时触发 `..3`
Similarly we're running a `/title` command as an example: 您可根据实际需求修改这些条件。
- a) when there are 4 or more players `4..`
- b) when there are 3 players or less `..3`
You can edit this as well to suit your need. ## 系统原理
## Explanation - 系统中的前两条命令将虚拟玩家分数(此处为`onlinePlayers`重置为0然后通过遍历每个已加载的目标实体此处为`type=player`)来累计分数
- The first two commands in the system sets the FakePlayer name's score to 0 (here `onlinePlayers`) and from each loaded entity we want to track (here `type=player`) it will add a score to the specified FakePlayer name (here `onlinePlayers`) 通过获取的数值,我们可以使用`/execute if score`命令在满足特定条件时执行自定义操作:
- **` n `** 精确匹配数值n
- **` n.. `** 数值≥n时触发
- **` ..n `** 数值≤n时触发
- **` n1..n2 `** 数值在n1到n2区间时触发
Now based on the values obtained we can use the `/execute if score` command to run our desired commands when certain values are met. ## 循环执行配置
- **` n `** any number n
- **` n.. `** any number n and above
- **` ..n `** any number n and below
- **` n1..n2 `** any number n1 to any number n2.
## Tick JSON 若使用函数替代命令方块,需将`entity_counter`函数添加至`tick.json`以实现循环持续执行。通过在字符串后添加逗号分隔,可将多个文件添加至`tick.json`。更多信息请参考[函数文档](/wiki/commands/mcfunctions#tick-json)。
If you are using functions instead of command blocks, the ` entity_counter ` function must be added to the ` tick.json ` in order to loop and run it continuously. Multiple files can be added to the ` tick.json ` by placing a comma after each string. Refer to [Functions](/commands/mcfunctions#tick-json) documentation for further info. ::: code-group
```json [BP/functions/tick.json]
<CodeHeader>BP/functions/tick.json</CodeHeader>
```json
{ {
"values": [ "values": [
"entity_counter" "entity_counter"
] ]
} }
``` ```
:::
If using functions, your pack folder structure will be be as follows: 使用函数时,资源包文件夹结构如下所示:
<FolderView <FolderView
:paths="[ :paths="[
@@ -84,6 +90,6 @@ If using functions, your pack folder structure will be be as follows:
]" ]"
></FolderView> ></FolderView>
> **Note:** the scoreboard names (in this case: 'total') may end up being used by other people. Appending ` _ ` and a set of randomly generated characters after would be a choice that reduces the probability of collisions. Similar technique can be employed for the ` .mcfunction ` filenames. Ex: > **注意:** 计分项名称(本例中的'total')可能被他人重复使用。建议在名称后追加`_`和随机字符组合来降低冲突概率,此方法同样适用于`.mcfunction`文件名。例如:
> - ` total_0fe678 ` > - `total_0fe678`
> - ` entity_counter_0fe678.mcfunction ` > - `entity_counter_0fe678.mcfunction`

View File

@@ -1,14 +1,14 @@
--- ---
title: Commands title: 命令 Commands
categories: categories:
- title: General - title: 基础
color: green color: green
- title: Commands - title: 命令
color: green color: green
- title: On Event Systems - title: 事件系统
color: blue color: blue
- title: Scoreboard Systems - title: 计分板系统
color: blue color: blue
- title: Techniques - title: 技术
color: orange color: orange
--- ---

View File

@@ -1,6 +1,6 @@
--- ---
title: Intro to Command Blocks title: 命令方块入门
category: General category: 基础
mentions: mentions:
- BedrockCommands - BedrockCommands
- zheaEvyline - zheaEvyline
@@ -10,132 +10,122 @@ tags:
- info - info
--- ---
## Introduction # 命令方块入门
[Sourced By Bedrock Commands Community Discord](https://discord.gg/SYstTYx5G5) <!--@include: @/wiki/bedrock-wiki-mirror.md-->
Command Blocks are special blocks in Minecraft. The same commands (cheats) you type in chat can be run automatically using command blocks and it can be reused without needing to type all over again. ## 简介
They can only be placed or destroyed by a player with the Operator permission level in gamemode Creative. [由 Bedrock Commands 社区 Discord 提供](https://discord.gg/SYstTYx5G5)
## Obtaining 命令方块是 Minecraft 中的特殊方块。通过在聊天栏输入的指令(作弊命令)可以通过命令方块自动执行,无需重复输入即可复用。
1. Open your world settings. 只有拥有操作员权限的创造模式玩家才能放置或破坏命令方块。
2. Under Cheats, toggle "Activate Cheats" setting ON.
3. Run `/give @s command_block` command in chat.
## Command Block UI ## 获取方式
1. 打开世界设置
2. 在「作弊」选项下启用「激活作弊」
3. 在聊天栏输入 `/give @s command_block`
## 命令方块界面
![commandBlockUI](/assets/images/commands/commandBlockUI.png) ![commandBlockUI](/assets/images/commands/commandBlockUI.png)
## Command Block Types ## 命令方块类型
![impulseCommandBlock](/assets/images/commands/impulseCommandBlock.png) **Impulse** runs the command __once__ each time it is powered. ![impulseCommandBlock](/assets/images/commands/impulseCommandBlock.png) **脉冲型** 在被激活时__单次__执行命令
![chainCommandBlock](/assets/images/commands/chainCommandBlock.png) **Chain** runs the command in a sequence, ie. only after the previous command block it is connecting from was run. ![chainCommandBlock](/assets/images/commands/chainCommandBlock.png) **连锁型** 按顺序执行命令,即仅在前置方块执行后触发
![repeatingCommandBlock](/assets/images/commands/repeatingCommandBlock.png) **Repeat** runs the command every game tick. There are approximately 20 ticks per second. A delay can be applied to adjust how often the command is executed, explained [below](/commands/intro-to-command-blocks#command-block-tick-delay). ![repeatingCommandBlock](/assets/images/commands/repeatingCommandBlock.png) **循环型** 每游戏刻执行一次命令每秒约20刻。可通过[下文](#命令方块刻延迟)介绍的延迟设置调整执行频率
## Command Block Conditions ## 命令方块条件
**Conditional** command blocks will run the command only if the previous command block it was connecting from had an output that was `true` (successful) **条件制约型** 仅当连接的前置方块输出结果为`true`(成功)时执行命令
> Conditional command block states are shown by a small indent into the command block's texture, as shown below: > 条件制约型方块在材质上会显示凹陷箭头标识:
> - ![pasteCommandButton](/assets/images/commands/impulseConditionalCommandBlock.png) Impulse Conditional Command Block > - ![pasteCommandButton](/assets/images/commands/impulseConditionalCommandBlock.png) 脉冲条件制约型
> - ![chainConditionalCommandBlock](/assets/images/commands/chainConditionalCommandBlock.png) Chain Conditional Command Block > - ![chainConditionalCommandBlock](/assets/images/commands/chainConditionalCommandBlock.png) 连锁条件制约型
> - ![repeatingConditionalCommandBlock](/assets/images/commands/repeatingConditionalCommandBlock.png) Repeating Conditional Command Block > - ![repeatingConditionalCommandBlock](/assets/images/commands/repeatingConditionalCommandBlock.png) 循环条件制约型
**Unconditional** command blocks will run the command regardless. Whether the previous command block it was connecting from had an output that was `true` (succesful), `false` (failed) or even if it came with a syntax error the command block will still run the command. **无条件型** 无论前置方块输出结果如何都会执行命令(包括`true`成功、`false`失败甚至语法错误)
## Command Block Redstone States ## 命令方块红石状态
**Needs Redstone** command block can only be activated with redstone power. Using buttons, levers, redstone torch etc.. **需要红石** 必须通过红石信号激活(按钮、拉杆、红石火把等)
**Always Active** command block will be activated as soon as you close the command block UI. **保持开启** 关闭命令方块界面后立即持续激活
## Command Block Tick Delay ## 命令方块刻延迟
In this option you may specify how much delay you want there to be before the command block runs the command. 设置命令执行前的延迟时间。刻Tick是 Minecraft 的时间单位现实1秒约等于20游戏刻。
The ticks refer to Minecraft game ticks. A **tick** is simply a unit of measure for time in games. 1 second in real life is approximately 20 game ticks in Minecraft.
:::tip :::tip
![gametick.png](/assets/images/commands/gametick.png) ![gametick.png](/assets/images/commands/gametick.png)
::: :::
## Command Block Hover Note ## 悬浮提示文本
This option allows you to put a hovering text on your command blocks. It's useful for giving short-names for easy identification when working with many command blocks. 可为命令方块添加悬浮备注,便于在多命令方块系统中快速识别。
When a command is run, the hover note will be displayed with the output in chat if gamerule `commandblockoutput` is enabled. `commandblockoutput`游戏规则启用时,命令执行后会在聊天栏显示备注信息。
![hover_note](/assets/images/commands/hover_note.png) ![hover_note](/assets/images/commands/hover_note.png)
## Paste Button ## 粘贴按钮
![pasteCommandButton](/assets/images/commands/pasteCommandButton.png) ![pasteCommandButton](/assets/images/commands/pasteCommandButton.png)
The paste button allows you to paste commands from your clipboard to the 'Command Input' box. 支持将剪贴板内容粘贴至命令输入框
## Command Block Output ## 命令输出管理
- Toggle the 'Previous Output' button in the command block UI to see command output and block details. - 通过界面中的「上一个输出」按钮查看执行记录
- 命令方块中无需输入开头的`/`符号(输入也不会报错)
- 红石比较器可读取输出强度成功时输出1-15信号
- 在聊天栏测试命令:红色文字表示`false`或语法错误,白色表示`true`
- 也可通过实际效果判断命令是否成功
- 输出值`0`通常表示失败
- The ` / ` you type before the whole command is not required in a command block but doing so won't cause any errors. ### 禁用命令提示
在聊天栏输入:
- `/gamerule commandblockoutput false` 关闭命令方块提示
- `/gamerule sendcommandfeedback false` 关闭聊天指令反馈
- A redstone comparator can read command blocks outputs. If output is true, it will send anywhere from 1 to 15 redstone signals depending on the output value. ## 命令方块布局技巧
- You can check if a command output is `true`/`false` by running it in chat. A red output will be a `false` output or a syntax error. A white output means command was run successfully. 搭建连锁系统时,确保箭头方向正确连接。箭头朝向可通过方块材质判断。
- You can also tell if a command was `true`/`false` by checking whether action was performed or not. **✅ 正确布局**
- An output with a value of `0` is usually a false output.
### Disabling Command Messages In Chat
Run in Chat:
- `/gamerule commandblockoutput false` to disable command block messages in chat.
- `/gamerule sendcommandfeedback false` to disable feedback from commands entered in chat.
## Command Block Placement
When placing command blocks in a line (arranged to work together) for any system, make sure the consecutive command blocks connect/start from the head of the arrow.
The arrow/facing direction can be observed from the command block texture.
**✅ Correct Placement**
![correctCommandBlockPlacement](/assets/images/commands/correctCommandBlockPlacement.png) ![correctCommandBlockPlacement](/assets/images/commands/correctCommandBlockPlacement.png)
**Incorrect Placement** **错误布局**
![incorrectCommandBlockPlacement](/assets/images/commands/incorrectCommandBlockPlacement.png) ![incorrectCommandBlockPlacement](/assets/images/commands/incorrectCommandBlockPlacement.png)
## Troubleshooting Command Blocks ## 故障排除指南
- In world settings, under **Cheats**, make sure command blocks have not been disabled. - 检查世界设置中是否禁用命令方块
- 确保`maxcommandchainlength`游戏规则不为0
- 排除意外红石信号干扰(红石线、拉杆、火把等)
- 切换「需要红石」与「保持开启」模式
- 仔细检查方块类型、条件和命令语法,重新激活后查看输出
- 确保区块已加载(可使用[常加载区域](/wiki/commands/tickingarea)
- Make sure gamerule `maxcommandchainlength` is **not** set to 0 若仍无法解决,可尝试拆除并重新放置命令方块
- Make sure there are no unwanted redstone power that is interfering with the command block. It can be from redstone dust, lever, redstone torch etc.. ## 学习要点
- Try switching between Always Active & Needs Redstone. :::tip 学习要点:
- 游戏内获取命令方块的方法
- Double check the block type, condition & the command syntax. Check 'Previous Output' after powering it once again. - 各类命令方块的特性与外观识别
- 条件设置、红石状态与延迟配置
- Just like redstone, command blocks must also be in loaded chunks for them to work. You can use a tickingarea to keep them loaded when players are not nearby. Refer to [/tickingarea](https://learn.microsoft.com/en-us/minecraft/creator/documents/tickingareacommand) command documentation for more info. - 通过红石与聊天信息获取输出数据
- 正确排列命令方块链的技巧
If nothing seems to work simply break and place that command block again. - 常见故障解决方案
## What you have learned
:::tip What you have learned:
- How to obtain a command block in game.
- How the different types of command blocks behave and what they look like.
- What the different command block options are (including conditional, state and delay.)
- How command blocks output data by redstone and chat messages.
- How to properly place command block chains.
- How to resolve 'command block not working'
::: :::
To put what you have learned into practice, try making this simple [Entity Counter](/commands/entity-counter) system. 实践建议:尝试制作简易的[实体计数器系统](/wiki/commands/entity-counter)
> Note: when setting up command block systems, always the first command will be ![repeatingCommandBlock](/assets/images/commands/repeatingCommandBlock.png) **`Unconditional Always Active`** and the rest will be ![chainCommandBlock](/assets/images/commands/chainCommandBlock.png) **`Unconditional Always Active`** (all 0 ticks delay) *unless specified otherwise.* > 注意:常规命令链的首个方块应为![repeatingCommandBlock](/assets/images/commands/repeatingCommandBlock.png) **无条件保持开启**,后续使用![chainCommandBlock](/assets/images/commands/chainCommandBlock.png) **无条件保持开启**默认0刻延迟
> >
> ![commandBlockChain4](/assets/images/commands/commandBlockChain/4.png) > ![commandBlockChain4](/assets/images/commands/commandBlockChain/4.png)
**(Recommended) Read Next: [Understanding Selectors](/commands/selectors)** **(推荐延伸阅读)[选择器详解](/wiki/commands/selectors)**

View File

@@ -1,6 +1,6 @@
--- ---
title: Functions title: 函数 mcfunction
category: General category: 基础
mentions: mentions:
- Bedrock Commands - Bedrock Commands
- cda94581 - cda94581
@@ -8,19 +8,24 @@ mentions:
- jordanparki7 - jordanparki7
nav_order: 3 nav_order: 3
tags: tags:
- info - 信息
--- ---
## Introduction
[Sourced By Bedrock Commands Community Discord](https://discord.gg/SYstTYx5G5) # 函数 mcfunction
Functions are `.mcfunction` files which contain multiple lines of commands. They are run with the `/function` command in-game. <!--@include: @/wiki/bedrock-wiki-mirror.md-->
Functions are created in a **Behavior Pack**, nested within the **functions** folder. A function pack creates a system using solely function files. ## 简介
Functions are useful in many ways to reduce the time spent going from command block to command block debugging a system. They also help with packaging systems for use in multiple worlds and provide many functions that can change how everything works. [源自 Bedrock Commands 社区 Discord](https://discord.gg/SYstTYx5G5)
## Function Pack Folder Structure 函数是包含多行命令的 `.mcfunction` 文件,可通过游戏中的 `/function` 命令运行。
函数需要创建在**行为包**的 **functions** 文件夹内。纯函数包系统完全由函数文件构成。
函数在多个方面非常有用,可以减少逐个命令方块调试系统所花费的时间。同时也便于将系统打包用于多个世界,并提供了许多可以改变整体运行方式的函数。
## 函数包目录结构
<FolderView <FolderView
:paths="[ :paths="[
@@ -34,47 +39,46 @@ Functions are useful in many ways to reduce the time spent going from command bl
]" ]"
></FolderView> ></FolderView>
## Notes For Beginners ## 新手须知
<CodeHeader>mcfunction</CodeHeader> ::: code-group
```yaml [mcfunction]
```yaml #生成效果
#Spawn Effects
effect @a [tag=atSpawn] regeneration 12 255 true effect @a [tag=atSpawn] regeneration 12 255 true
effect @a [tag=atSpawn] saturation 12 255 true effect @a [tag=atSpawn] saturation 12 255 true
effect @a [tag=atSpawn] weakness 12 255 true effect @a [tag=atSpawn] weakness 12 255 true
``` ```
- Each new line in a function file represents a new command. You may start a line with # to add comments. Commands in a function do not need to begin with a slash `/`, however doing so will not cause any errors. :::
- All commands in a function are run in the *same tick*. Because of this, a function which causes large changes may cause a sudden lag spike and it is helpful to delegate some commands across multiple ticks, if possible. - 函数文件中每一新行代表一个新命令。可以使用 `#` 开头添加注释。函数内的命令不需要以斜杠 `/` 开头,但添加了也不会报错。
Commands in a function are still run in the same order, however.
- Minecraft can **not** run more than 10,000 lines of commands in one function file. This includes any other function files that are executed inside of the original file. - 函数中的所有命令会在**同一游戏刻**内执行。因此,包含大量变更操作的函数可能导致突然的卡顿,建议尽可能将命令分摊到多个游戏刻中执行。但函数内的命令仍会按顺序依次运行。
- It is not possible to run conditional commands. Those will still need to utilize command blocks in some way, or could utilize the 1.19.50 execute syntax. - Minecraft **无法**在一个函数文件中运行超过10,000行命令这包括原始文件中调用的其他函数文件。
- Running commands with a specified delay in a function would involve using scoreboard timers to incrementally count up every tick (to a certain point), and executing at certain scores along the file. You may refer to [Scoreboard Timers](/commands/scoreboard-timers) system to learn how to set it up. - 无法执行条件型命令。这类命令仍需通过命令方块实现或使用1.19.50版本的execute语法。
## Creating a Function - 要在函数中实现延迟执行命令,需使用计分板计时器逐刻计数(达到指定值),并在特定分数时执行命令。可参考[计分板计时器](/wiki/commands/scoreboard-timers)系统了解设置方法。
1. Locate the `📁 com.mojang` folder and navigate to `📁 development_behavior_packs` ## 创建函数
- The development folders are used for quick reloading of packs, as the packs aren't cached to the world files.
2. Create a folder (of any name) for the function pack. This will be referred to as Behavior Pack or BP. 1. 找到 `📁 com.mojang` 文件夹并进入 `📁 development_behavior_packs`
- 开发文件夹用于快速重载资源包,因为这些包不会被缓存到世界文件中。
3. Create a `📄 manifest.json` file and a `🖼 pack_icon.png` file (optional) within the BP folder. 2. 为函数包创建任意名称的文件夹称为行为包或BP
- A manifest file contains all the information needed to register a pack, while a pack icon displays visually in the pack menu. A pack icon is typically a 128x128 or a 256x256 image, though any power-of-2 resolution will do, they will be upscaled and downscaled accordingly.
<Spoiler title="Sample 📄 manifest.json"> 3. 在BP文件夹内创建 `📄 manifest.json` 文件和 `🖼 pack_icon.png` 文件(可选)
- 清单文件包含注册资源包所需的所有信息包图标则用于在资源包菜单中显示。包图标建议使用128x128或256x256分辨率支持2次幂分辨率会自动缩放
<CodeHeader>BP/manifest.json</CodeHeader> <Spoiler title="示例 📄 manifest.json">
```json ::: code-group
```json [BP/manifest.json]
{ {
"format_version": 2, "format_version": 2,
"header": { "header": {
"description": "Write Your Pack Description Here", "description": "在此填写资源包描述",
"name": "Write Your Pack Name Here", "name": "在此填写资源包名称",
"uuid": "00000000-0000-0000-0000-000000000000", "uuid": "00000000-0000-0000-0000-000000000000",
"version": [ 1, 0, 0 ], "version": [ 1, 0, 0 ],
"min_engine_version": [ 1, 19, 73 ] "min_engine_version": [ 1, 19, 73 ]
@@ -89,45 +93,44 @@ Commands in a function are still run in the same order, however.
] ]
} }
``` ```
:::
Note that the uuid field needs to be replaced with an actual uuid, and the two generated must be different from one another. You can generate a uuid at https://uuidgenerator.net/ 注意uuid字段需要替换为实际值且两个uuid必须不同。可通过 https://uuidgenerator.net/ 生成
</Spoiler> </Spoiler>
<Spoiler title="Sample 🖼 pack_icon.png"> <Spoiler title="示例 🖼 pack_icon.png">
Sample A: 示例A
![pack_icon.png](/assets/images/commands/pack_icon.png) ![pack_icon.png](/assets/images/commands/pack_icon.png)
Sample B: 示例B
![pack_icon.png](/assets/images/guide/project-setup/pack_icon.png) ![pack_icon.png](/assets/images/guide/project-setup/pack_icon.png)
</Spoiler> </Spoiler>
4. Create a `📁 functions` folder. Any file within this folder that ends with **.mcfunction** will be registered as a function in-game, which can be run with `/function <function_name>`. 4. 创建 `📁 functions` 文件夹。该文件夹内所有以 **.mcfunction** 结尾的文件都将注册为游戏内可用的函数,可通过 `/function <函数名称>` 运行。
- Nested functions are allowed, simply list the file path in relation to the functions folder as shown in the function pack folder structure. - 支持嵌套函数,只需按函数包目录结构示例中的方式组织文件路径即可。
5. Apply the behavior pack in-game and try out the functions. Function file changes can be reflected in the world by running `/reload` or by simply relogging. 5. 在游戏中应用行为包并测试函数。修改函数文件后可通过执行 `/reload` 或重新登录来刷新改动。
:::tip NOTE :::tip 注意
Functions are versioned; therefore, they will run in the version listed in the `📄 manifest.json`, such as: 函数具有版本依赖性,将运行在 `📄 manifest.json` 中声明的版本环境下:
- `min_engine_version` 1.19.50 or above will adopt the new execute syntax. - `min_engine_version` 1.19.50+ 将采用新版execute语法
- `min_engine_version` 1.19.70 or above will require aux values be replaced with block states. - `min_engine_version` 1.19.70+ 需将aux值替换为方块状态
::: :::
## Execution ## 执行方式
Functions can be executed in-game by typing `/function name_of_function`. This will execute all the commands in the function file, all in a single tick. 在游戏中输入 `/function 函数名称` 即可执行函数文件内的所有命令(同一游戏刻内完成)。例如嵌套函数 `BP/functions/lobby/items/1.mcfunction` 需使用路径 `/function lobby/items/1` 调用。
Nested functions, for example `BP/functions/lobby/items/1.mcfunction` can be run using the nested folder path, in this case `/function lobby/items/1`
## tick.json ## tick.json
The final file within a function is the **tick.json** file. This specifies functions to run server-side on every game tick, (similar to a repeating command block.) It is located in the `BP/functions` folder. By default, functions running in this file execute at origin `0, 0, 0` in the overworld. **tick.json** 是函数包中的特殊文件,用于指定服务器每游戏刻自动运行的函数(类似循环命令方块)。该文件位于 `BP/functions` 文件夹中,默认在主世界原点坐标 `0, 0, 0` 处执行。
<CodeHeader>BP/functions/tick.json</CodeHeader> ::: code-group
```json ```json [BP/functions/tick.json]
{ {
"values": [ "values": [
"function_1", "function_1",
@@ -135,24 +138,26 @@ The final file within a function is the **tick.json** file. This specifies funct
] ]
} }
``` ```
> Note: functions in this file are run as soon as the world is *initialized*, regardless of whether or not the player has been *loaded*. This may cause unintended behavior if used incorrectly. :::
## Sample Function Pack > 注意:该文件中的函数会在世界初始化后立即运行(无论玩家是否加载完毕),使用不当可能导致意外行为。
## 示例函数包
<CardLink <CardLink
imgsrcLight="assets/images/commands/BClogo.png" imgsrcLight="assets/images/commands/BClogo.png"
title="Download Sample Function Pack" title="下载示例函数包"
link="https://github.com/Bedrock-OSS/wiki-addon/releases/download/download/functions_sample.mcpack" link="https://github.com/Bedrock-OSS/wiki-addon/releases/download/download/functions_sample.mcpack"
/> />
## Troubleshooting Functions ## 函数排错指南
Your functions may not appear within the command suggestions when using `/function`. This is normally due to an error with one or more commands in the function. 使用 `/function` 时若未出现命令建议,通常是由于函数中存在错误命令导致。
Enabling the [Content Log](/guide/troubleshooting#content-log) in creator settings will allow you to see if there are any errors in your function pack, in which function the error is in, at which line and exactly what the syntax error for that command is. 在创作者设置中启用[内容日志](/wiki/guide/troubleshooting#content-log)可查看函数包中的具体错误信息,包括错误所在函数、行号及语法问题。
The list of errors will be generated every time you load a world or run `/reload` to reflect changes after editing files. The list can be viewed on-screen for a few seconds as well as in the content log history in settings. 每次加载世界或执行 `/reload` 后都会生成错误列表,可在屏幕上短暂查看或通过设置中的内容日志历史记录查阅。
![contentLogToggles](/assets/images/commands/contentLogToggles.png) ![contentLogToggles](/assets/images/commands/contentLogToggles.png)
![contentLogHistory](/assets/images/commands/contentLogHistory.png) ![contentLogHistory](/assets/images/commands/contentLogHistory.png)

File diff suppressed because one or more lines are too long

View File

@@ -1,8 +1,8 @@
--- ---
title: New Execute title: 全新execute命令
category: Commands category: 命令
tags: tags:
- easy - 简单
mentions: mentions:
- JaylyDev - JaylyDev
- Sprunkles137 - Sprunkles137
@@ -12,236 +12,243 @@ mentions:
- zheaEvyline - zheaEvyline
--- ---
## Introduction # 全新execute命令
With the release of 1.19.50, the `/execute` command was given a syntax overhaul. While the syntax is now more verbose and longer to write, it allows much finer control over the contextual components of commands and adds support for conditions to commands, superseding the use of commands like `/testfor`, `/testforblock`, and `/testforblocks`. <!--@include: @/wiki/bedrock-wiki-mirror.md-->
Before we dive into the syntax and how to write it, we need to understand how the old `/execute` command worked, and what changed and why. This will make explaining the concepts found in the syntax easier. ## 引言
## Understanding Execution Context 随着1.19.50版本的发布,`/execute`命令迎来了语法革新。虽然新语法需要书写更长的指令,但它能更精细地控制命令的上下文组件,并为命令添加了条件支持,从而取代了`/testfor``/testforblock``/testforblocks`等命令。
For both beginners to commands and those well versed in how old `/execute` behaved, it may be a good idea to review the concept of a command's **execution context**. 在深入解析语法细节之前,我们需要理解旧版`/execute`的工作原理及其演变逻辑,这将有助于更好地理解新语法中的概念。
In short, these are the parameters that affects how a command runs. Who the command will run as, also known as its executor; where the command will run, and in which dimension; and the rotation applied to the command are all parameters that can be changed. ## 理解执行上下文
Every command has this context applied to it, and this context changes depending on how the command runs. Commands fired from command blocks do not have an executor, and the position is set to that command block; commands ran from chat define the executor as the player, and it runs at the player's position. 无论是命令新手还是熟悉旧版`/execute`的开发者,都有必要重新审视命令的**执行上下文**概念。
## Execute, and Why it Changed 简而言之,这些参数决定了命令的运行方式:命令的执行者(即由谁执行)、执行位置、所在维度以及执行时的视角旋转角度等。
The `/execute` command executes a command on behalf of one or more entities. The old syntax used to be this: 每个命令都携带这样的上下文,且上下文会根据命令的运行方式动态变化。从命令方块触发的命令没有明确执行者,位置固定在命令方块处;通过聊天框执行的命令则以玩家为执行者,并在玩家当前位置运行。
## Execute命令的演变逻辑
`/execute`命令允许通过一个或多个实体代理执行命令。旧版语法结构如下:
``` ```
/execute <target> <position> <command> /execute <目标> <位置> <命令>
/execute <target> <position> detect <position> <block> <data value> <command> /execute <目标> <位置> detect <位置> <方块> <数据值> <命令>
``` ```
You specified a target to execute as, then the command's context would change to run as that target, and at that target. Any position changes were then always relative to that target. 旧语法指定目标后,命令的上下文将切换至该目标的位置执行。所有位置偏移都默认相对于该目标。
While this is useful in most cases, it also forces the fact that a command's target and its position are always tied together (unless you were to manually insert world coordinates in place of `<position>`). It is also not very malleable in regards to making conditional statements, as you have to execute as an entity every time. 虽然这在多数情况下很实用,但也强制绑定了命令目标与执行位置(除非手动输入世界坐标)。同时,在构建条件语句时缺乏灵活性,因为每次都需要通过实体执行。
Back in the Summer of 2017 during the Update Aquatic's development, the developers of Minecraft: Java Edition were getting feedback from the community on how they can improve the `/execute` command's syntax, and the basic concept that was conceived is this: `/execute` takes an unlimited number of **subcommands** that manipulate certain aspects of the command in the order you specify, then a "run" subcommand is placed at the end to fire a command. 在2017年夏季水域更新的开发阶段Minecraft Java版开发团队收集了社区反馈后,提出了全新设计理念:`/execute`可以串联无限个**子命令**来按序调整命令的不同上下文维度,最后通过"run"子命令触发实际命令。
This allows for much greater control for what `/execute` can do to a command, and allows splitting up the executor and the command's position. 这种设计大幅提升了`/execute`的上下文控制能力,实现了执行者与执行位置的分离。
## New Syntax ## 新语法解析
Now, let us review the new `/execute` syntax. They are as follows: 现在让我们系统梳理新版`/execute`语法结构:
### `/execute as` ### `/execute as`
Changes the executor of the command, or what the target selector `@s` will select. 更改命令执行者,即影响目标选择器`@s`的指向。
``` ```
/execute as <origin: target> -> execute /execute as <origin: 目标> -> execute
``` ```
This does not change the position, rotation, or dimension context of the command. 此命令不会改变执行位置、视角或维度上下文。
If multiple targets are specified then a command is ran once for each target, where `@s` selects each entity in turn. 若指定多个目标,则依次以每个目标为`@s`执行命令。
### `/execute at` ### `/execute at`
Changes where the command runs, setting the command's position, rotation, and dimension context to the entity. 更改命令执行位置,将命令的坐标、视角和维度同步至目标实体。
``` ```
/execute at <origin: target> -> execute /execute at <origin: 目标> -> execute
``` ```
This does not change the executor of the command, so `@s` will remain as whoever was targeted last. 此命令不会改变执行者身份,故`@s`仍指向最近一次指定的目标。
If multiple targets are specified then a command is ran once for each target, setting the position, rotation, and dimension context to each target. 若指定多个目标,则依次在目标位置执行命令。
### `/execute in` ### `/execute in`
Sets the dimension in which the command should run. 设置命令执行的维度环境。
``` ```
/execute in <dimension: string> -> execute /execute in <dimension: 字符串> -> execute
``` ```
Currently accepted values are `overworld`, `nether`, and `the_end`. 当前可用维度标识符为`overworld``nether``the_end`
This change in dimension will respect that dimension's scale; going from the Overworld to The Nether will apply a scale of x0.125 to the position, and vice versa will apply a x8 scale to the position. 维度切换时会自动换算坐标比例如主世界至下界应用x0.125缩放反之则x8放大
### `/execute positioned` ### `/execute positioned`
Directly sets the position context of the command. 直接设定命令执行坐标。
``` ```
/execute positioned <position: x y z> -> execute /execute positioned <position: x y z> -> execute
``` ```
Sets the position of the command to specific values. [Relative and local coordinates](/commands/relative-coordinates) are based around the current position of the command. 将命令位置设为指定坐标。[相对坐标与局部坐标](/wiki/commands/relative-coordinates)基于当前命令位置计算。
``` ```
/execute positioned as <origin: target> -> execute /execute positioned as <origin: 目标> -> execute
``` ```
Sets the position of the command to a target's location. This is similar to how `/execute at` works, but it only sets the command's position and not its rotation or dimension. 将命令位置同步至目标坐标。功能类似`/execute at`,但仅改变位置不改变视角与维度。
If multiple targets are specified then a command is ran once for each target, setting the position context to the target's position. 若指定多个目标,则依次在目标位置执行命令。
### `/execute align` ### `/execute align`
Aligns the current position of the command to the block grid. 将当前命令位置对齐至方块网格。
``` ```
/execute align <axes: swizzle> -> execute /execute align <axes: 轴组合> -> execute
``` ```
Aligning a position will floor it. This subcommand accepts any non-repeating combination of the letters "x", "y", and "z", and will floor the position along each axis specified. 对齐操作将坐标向下取整。本子命令接受由"x""y"、"z"组成的非重复组合,对指定轴进行取整。
### `/execute anchored` ### `/execute anchored`
Sets the anchor of the command to the executor's feet or eyes. Changing the anchor will affect the position where local coordinates will start at. 设置命令的锚点位置(脚部或眼部),影响局部坐标基准。
``` ```
/execute anchored (eyes|feet) -> execute /execute anchored (eyes|feet) -> execute
``` ```
The default anchor when executing at a target is their feet. 默认锚点为脚部。
When the anchor is set to `eyes`, the command's local position is offset by some amount corresponding to the "eye height" of the current executor. 当锚点设为`eyes`时,命令的局部坐标会根据执行者的"眼高"进行偏移。
This offset should only apply to local coordinates, but it currently affects relative coordinates due to a bug: [MCPE-162681](https://bugs.mojang.com/browse/MCPE-162681). 注意:由于漏洞[MCPE-162681](https://bugs.mojang.com/browse/MCPE-162681),当前该设置会影响相对坐标。
### `/execute rotated` ### `/execute rotated`
Directly sets the rotation context of the command. 直接设定命令执行视角。
``` ```
/execute rotated <yaw: value> <pitch: value> -> execute /execute rotated <yaw: > <pitch: > -> execute
``` ```
Sets the rotation of the command to specific values. Relative and local coordinates are based around the current rotation of the command. This defaults to 0 for both pitch and yaw, unless the rotation was changed prior. 设置具体视角参数。相对坐标与局部坐标基于当前视角计算默认值为0若未变更过视角
``` ```
/execute rotated as <origin: target> -> execute /execute rotated as <origin: 目标> -> execute
``` ```
Sets the rotation of the command to a target's rotation. 同步目标实体的视角参数。
If multiple targets are specified then a command is ran once for each target, setting the rotation context to the target's rotation. 若指定多个目标,则依次应用目标视角执行命令。
### `/execute facing` ### `/execute facing`
Sets the rotation of the command to face some position. This rotation is calculated based on the current position of the command. 设置命令视角朝向特定坐标或实体部位。
``` ```
/execute facing <position: x y z> -> execute /execute facing <position: x y z> -> execute
``` ```
Sets the rotation to face a block position. Relative and local coordinates are based around the current position of the command. 使命令视角朝向指定方块坐标,基于当前命令位置计算。
``` ```
/execute facing entity <origin: target> (eyes|feet) -> execute /execute facing entity <origin: 目标> (eyes|feet) -> execute
``` ```
Sets the rotation to face a target's position. Setting the anchor to `feet` will aim the rotation to face where they are currently standing, while setting the anchor to `eyes` will aim the command up at the "eye position" of that target (see [`/execute anchored`](/commands/new-execute#execute-anchored)). 使命令视角朝向目标实体部位。选择`feet`锚点将瞄准脚部位置,`eyes`则瞄准眼部(参考[`/execute anchored`](/wiki/commands/new-execute#execute-anchored))。
If multiple targets are specified then a command is ran once for each target, setting the rotation context to face that target. 若指定多个目标,则依次应用目标朝向执行命令。
### `/execute (if|unless)` ### `/execute (if|unless)`
Prevents running a command based on a condition. If the condition is true then the command will continue, or stop otherwise. 根据条件判断是否执行命令。`if`在条件为真时继续,`unless`则相反。
`/execute unless` acts as the opposite, testing if the condition is false in order to continue.
``` ```
/execute if entity <target: target> -> execute /execute if entity <target: 目标> -> execute
``` ```
Acts like `/testfor`. Returns true if the targets exist. 类似`/testfor`,检测目标是否存在。
``` ```
/execute if block <position: x y z> <block: string> -> execute /execute if block <position: x y z> <block: 字符串> -> execute
``` ```
Acts like `/testforblock`. Returns true if the block at the specified location exists. 类似`/testforblock`,检测指定位置方块。
A data value or block state may additionally be specified, otherwise it ignores block states (acts as if it were set to `-1`). 可附加数据值或方块状态参数,否则忽略状态(等效于`-1`)。
``` ```
/execute if blocks <begin: x y z> <end: x y z> <destination: x y z> (all|masked) -> execute /execute if blocks <begin: x y z> <end: x y z> <destination: x y z> (all|masked) -> execute
``` ```
Acts like `/testforblocks`. It constructs a volume between the beginning and end positions, and returns true if the volume at the destination matches the original volume. 类似`/testforblocks`,比对源区域与目标区域的方块布局。
The parameter `all` tests that all blocks must match, while `masked` will ignore air blocks. `all`参数要求完全匹配,`masked`忽略空气方块。
``` ```
/execute if score <target: target> <objective: string> matches <range: integer range> -> execute /execute if score <target: 目标> <objective: 字符串> matches <range: 整数范围> -> execute
``` ```
Tests if a specified score is a certain value. This uses the integer range syntax. 检测指定分数是否符合数值范围(使用整数区间语法)。
``` ```
/execute if score <target: target> <objective: string> (=|<|<=|>|>=) <source: target> <objective: string> -> execute /execute if score <target: 目标> <objective: 字符串> (=|<|<=|>|>=) <source: 目标> <objective: 字符串> -> execute
``` ```
Tests if a specified score matches some logical comparison to another score. Operators are equals (`=`), greater than (`>`), greater than or equal to (`>=`), less than (`<`), and less than or equal to (`<=`). 比对两个分数的逻辑关系,支持等于(`=`)、大于(`>`)、大于等于(`>=`)、小于(`<`)、小于等于(`<=`)。
### `/execute run` ### `/execute run`
``` ```
/execute run <command: command> /execute run <command: 命令>
``` ```
Runs a command using all of the currently applied context modifications. This subcommand always goes last in one `/execute` command. 应用所有上下文修改后执行指定命令。本子命令必须作为`/execute`链的末尾。
This subcommand is not always required however; an `/execute` command ending with an `if` or `unless` subcommand is valid too, and will return the success of the test it performed. 注意:当`/execute`链以`if``unless`结尾时,可不带`run`直接返回检测结果。
## Examples and Upgrading Old Commands ## 实例解析与旧指令升级
Since subcommands can be chained limitlessly, there really is a nearly infinite combination of arguments for an `/execute` command and they cannot all be listed. Instead, listed here are some common examples of commands. 由于子命令可无限串联,实际组合方式近乎无限。以下列举典型应用场景:
The old functionality of `/execute` can be replicated with `as <target> at @s`. If you need a positional offset relative to the entity, add `positioned`. If you want to detect if a block is present, add `if block`. Here are some equivalents: 旧版`/execute`功能可通过`as <目标> at @s`复现。如需相对位置偏移,添加`positioned`;如需方块检测,添加`if block`。示例如下:
``` ::: code-group
# Teleport with an offset ```mcfunction [旧版偏移传送]
/execute @p ~ ~1.62 ~ teleport @s ^ ^ ^3 /execute @p ~ ~1.62 ~ teleport @s ^ ^ ^3
```
```mcfunction [新版等效]
/execute as @p at @s positioned ~ ~1.62 ~ run teleport @s ^ ^ ^3 /execute as @p at @s positioned ~ ~1.62 ~ run teleport @s ^ ^ ^3
``` ```
:::
``` ::: code-group
# Chaining multiple '/execute's ```mcfunction [旧版链式检测]
/execute @e[type=sheep] ~ ~ ~ execute @e[type=item,r=5] ~ ~ ~ detect ~ ~-1 ~ stone 0 kill @s /execute @e[type=sheep] ~ ~ ~ execute @e[type=item,r=5] ~ ~ ~ detect ~ ~-1 ~ stone 0 kill @s
```
```mcfunction [新版等效]
/execute at @e[type=sheep] as @e[type=item,r=5] at @s if block ~ ~-1 ~ stone 0 run kill @s /execute at @e[type=sheep] as @e[type=item,r=5] at @s if block ~ ~-1 ~ stone 0 run kill @s
``` ```
:::
(Note that we do not use `as @e[type=sheep] at @s` because we do not need to execute as the sheep; only the position here is required.) (注意此处使用`at @e[type=sheep]`而非`as`,因为只需位置信息)
Now for some examples of things that were not possible to do in one command, or were more difficult to perform before the new syntax was introduced. 新版语法还支持许多旧版难以实现的功能:
``` ::: code-group
# Testing a fake player's score ```mcfunction [检测虚拟玩家分数]
/execute if score game_settings var matches 3.. run say [Game] Difficulty set to Hard. /execute if score game_settings var matches 3.. run say [游戏] 难度已设为困难。
# Comparing if two scores are equal ```mcfunction [分数比对]
/execute as @a if score @s x = @s y run say My X is equal to my Y. /execute as @a if score @s x = @s y run say 我的X值等于Y值。
# Test for an entity without targeting it ```mcfunction [非选中实体检测]
/execute as @a at @s if entity @e[type=armor_stand,r=10] run gamemode survival @s /execute as @a at @s if entity @e[type=armor_stand,r=10] run gamemode survival @s
``` ```
:::

View File

@@ -1,61 +1,64 @@
--- ---
title: On First Join title: 首次进入时
category: On Event Systems category: 事件系统
mentions: mentions:
- BedrockCommands - BedrockCommands
- zheaEvyline - zheaEvyline
- SmokeyStack - SmokeyStack
nav_order: 1 nav_order: 1
tags: tags:
- system - 系统
--- ---
## Introduction # 首次进入时
[Sourced By Bedrock Commands Community Discord](https://discord.gg/SYstTYx5G5) <!--@include: @/wiki/bedrock-wiki-mirror.md-->
This system will run your desired commands on the event that a player joins the world for the first time. ## 简介
[由Bedrock Commands社区Discord提供](https://discord.gg/SYstTYx5G5)
本系统将在玩家首次进入世界时执行你预设的命令。
## System ## 系统实现
<CodeHeader>BP/functions/on_first_join.mcfunction</CodeHeader>
```yaml ::: code-group
#Your Commands Here (examples) ```yaml [BP/functions/on_first_join.mcfunction]
give @a [tag=!joined] stone_pickaxe # 在此处输入你的命令(示例)
give @a [tag=!joined] bread 16 1 give @a[tag=!joined] stone_pickaxe
tag @a [tag=!joined] add joined give @a[tag=!joined] bread 16 1
tag @a[tag=!joined] add joined
``` ```
:::
![commandBlockChain3](/assets/images/commands/commandBlockChain/3.png) ![命令方块链示意图3](/assets/images/commands/commandBlockChain/3.png)
我们以两个`give`命令为例,你可以根据需求使用任意命令组合。请确保遵循以下要点:
- 保持示例中的执行顺序
- 在选择器参数中正确添加`tag=!joined`条件
Here we have used 2 `give` commands as example but you can use any command you prefer and as many as you require. ## 原理说明
Just make sure to follow the given order and properly add the selector argument ` tag=!joined ` as shown for your desired commands. 当玩家首次加入世界时,他们不会携带`joined`标签。系统通过检测未拥有该标签的玩家执行预设命令后,会立即为其添加标签以防止重复执行。
## Explanation 若需要重置玩家状态,可通过以下命令移除标签:
`tag <玩家名> remove joined`
When the player joins the world for the first time, they will not have the joined tag. ## 时钟函数配置
Once we run our desired commands for players without the tag, they will be given the tag immediately and the commands will not repeat for them again unless we remove their tag with: 若使用函数替代命令方块,需将`on_first_join`函数添加至`tick.json`以实现循环检测。多个函数可通过逗号分隔添加,详见[函数文档](/wiki/commands/mcfunctions#tick-json)。
`tag <player> remove joined`
## Tick JSON ::: code-group
```json [BP/functions/tick.json]
If you are using functions instead of command blocks, the ` on_first_join ` function must be added to the ` tick.json ` in order to loop and run it continuously. Multiple files can be added to the ` tick.json ` by placing a comma after each string. Refer to [Functions](/commands/mcfunctions#tick-json) documentation for further info.
<CodeHeader>BP/functions/tick.json</CodeHeader>
```json
{ {
"values": [ "values": [
"on_first_join" "on_first_join"
] ]
} }
``` ```
:::
If using functions, your pack folder structure will be be as follows: 使用函数时资源包结构如下:
<FolderView <FolderView
:paths="[ :paths="[
@@ -68,6 +71,6 @@ If using functions, your pack folder structure will be be as follows:
]" ]"
></FolderView> ></FolderView>
> **Note:** the tag names (in this case: 'joined') may end up being used by other people. Appending ` _ ` and a set of randomly generated characters after would be a choice that reduces the probability of collisions. Similar technique can be employed for the ` .mcfunction ` filenames. Ex: > **注意:** 标签名称(如本例中的'joined')可能与其他开发者重复。建议在名称后追加`_`和随机字符组合来降低冲突概率,此方法同样适用于函数文件名。例如:
> - ` joined_0fe678 ` > - `joined_0fe678`
> - ` on_first_join_0fe678.mcfunction ` > - `on_first_join_0fe678.mcfunction`

View File

@@ -1,6 +1,6 @@
--- ---
title: On First World Load title: 首次世界加载时
category: On Event Systems category: 事件系统
mentions: mentions:
- BedrockCommands - BedrockCommands
- zheaEvyline - zheaEvyline
@@ -8,59 +8,62 @@ mentions:
- cda94581 - cda94581
nav_order: 6 nav_order: 6
tags: tags:
- system - 系统
--- ---
## Introduction # 首次世界加载时
[Sourced By Bedrock Commands Community Discord](https://discord.gg/SYstTYx5G5) <!--@include: @/wiki/bedrock-wiki-mirror.md-->
This system will run your desired commands on the event that the world is loaded for the first time. [由Bedrock Commands社区提供](https://discord.gg/SYstTYx5G5)
> **Note:** a [Function](/commands/mcfunctions) Pack is required to achieve this system since it is the `tick.json` file which allows us to run commands as soon as the world is initialised.
此系统将在世界首次加载时运行你指定的命令。
> **注意:** 实现本系统需要[函数包](/wiki/commands/mcfunctions),因为需要依赖 `tick.json` 文件在游戏初始化时立即执行命令。
## Tick Json ## Tick配置文件
<CodeHeader>BP/functions/tick.json</CodeHeader> ::: code-group
```json ```json [BP/functions/tick.json]
{ {
"values": [ "values": [
"initialise" "initialise"
] ]
} }
``` ```
:::
## System ## 系统实现
<CodeHeader>BP/functions/initialise.mcfunction</CodeHeader> ::: code-group
```yaml ```yaml [BP/functions/initialise.mcfunction]
scoreboard objectives add world dummy scoreboard objectives add world dummy
scoreboard players add initialised world 0 scoreboard players add initialised world 0
#Your Commands Here (example) # 在此处添加你的命令(示例)
execute if score initialised world matches 0 run say New world created! execute if score initialised world matches 0 run say 新世界已创建!
scoreboard players set initialised world 1 scoreboard players set initialised world 1
``` ```
:::
Here we have used an `execute - say` command as an example but you can use any command you prefer and as many as you require. 示例中使用的是 `execute - say` 命令组合,你可以根据需求自由替换为任意命令,并添加任意数量的命令。
Just make sure to follow the given order and properly use the `execute if score` command as shown to run the commands you need. 请确保遵循给定的命令顺序,并正确使用示例中演示的 `execute if score` 条件判断来执行你的命令。
## Explanation ## 运行原理
- **` initialised=0 `** this means the world has just initialised and we are yet to run the initlisation commands. - **`initialised=0`** 表示世界刚刚初始化,尚未执行初始化命令
- **` initialised=1 `** this means the world has been initialised and we have already run the initialisation commands. - **`initialised=1`** 表示世界已完成初始化,且初始化命令已执行完毕
An objective of the name `world` is added for us to save scores to it so that we can track whether the world has been initialised or not. This also allows us to structure our commands to only execute at world initialisation. 我们通过名为 `world` 的计分板目标来存储分数值,以此追踪世界是否已经过初始化。这种机制可以确保初始化命令仅在首次加载时执行。
Following the creation of the objective, a score of `0` is added to the FakePlayer name `initialised`. This will register it to the objective and enable us to use the `execute if score` command structure to run our desired commands. 创建计分板目标后,我们为虚拟玩家 `initialised` 设置初始分数 `0`。这会将虚拟玩家注册到计分板中,便于后续使用 `execute if score` 条件判断。
Finally the score for `initialised` is set to 1 after all the commands are run in order to prevent it from executing more than once. 最后在所有命令执行完毕后,将 `initialised` 的分数设置为 `1`,防止初始化命令重复执行。
## Folder Structure ## 文件结构
<FolderView <FolderView
:paths="[ :paths="[
@@ -73,6 +76,6 @@ Finally the score for `initialised` is set to 1 after all the commands are run i
]" ]"
></FolderView> ></FolderView>
> **Note:** the scoreboard names (in this case: 'world') may end up being used by other people. Appending ` _ ` and a set of randomly generated characters after would be a choice that reduces the probability of collisions. Similar technique can be employed for the ` .mcfunction ` filenames. Ex: > **注意:** 计分板名称(本例中的'world')可能与其他开发者重复。建议在名称后追加 `_` 和随机字符组合来降低冲突概率,此技巧同样适用于 `.mcfunction` 文件名。例如:
> - ` world_0fe678 ` > - `world_0fe678`
> - ` initialise_0fe678.mcfunction ` > - `initialise_0fe678.mcfunction`

View File

@@ -1,75 +1,77 @@
--- ---
title: On Player Death title: 玩家死亡事件
category: On Event Systems category: 事件系统
mentions: mentions:
- BedrockCommands - BedrockCommands
- zheaEvyline - zheaEvyline
nav_order: 4 nav_order: 4
tags: tags:
- system - 系统
--- ---
## Introduction # 玩家死亡事件
[Sourced By Bedrock Commands Community Discord](https://discord.gg/SYstTYx5G5) <!--@include: @/wiki/bedrock-wiki-mirror.md-->
This system will run your desired commands on the event that a player dies. ## 系统介绍
## Setup [由Bedrock Commands社区Discord提供](https://discord.gg/SYstTYx5G5)
*To be typed in Chat:* 本系统将在玩家死亡时执行你预设的命令。
## 系统配置
*在聊天栏输入以下指令:*
`/scoreboard objectives add alive dummy` `/scoreboard objectives add alive dummy`
If you prefer to have the objective added automatically on world initialisation, follow the process outlined in [On First World Load.](/commands/on-first-world-load) 若希望在世界初始化时自动创建计分板,请参考[首次世界加载事件](/wiki/commands/on-first-world-load)中的操作流程。
## System ## 系统实现
<CodeHeader>BP/functions/on_player_death.mcfunction</CodeHeader> ::: code-group
```yaml [BP/functions/on_player_death.mcfunction]
```yaml
scoreboard players set @a [scores={alive=!2}] alive 0 scoreboard players set @a [scores={alive=!2}] alive 0
scoreboard players set @e [type=player] alive 1 scoreboard players set @e [type=player] alive 1
#Your Commands Here (example) #在此处添加你的命令(示例)
execute as @a [scores={alive=0}] run say I died execute as @a [scores={alive=0}] run say 我死了
scoreboard players set @a [scores={alive=0}] alive 2 scoreboard players set @a [scores={alive=0}] alive 2
``` ```
![commandBlockChain4](/assets/images/commands/commandBlockChain/4.png) ![命令方块链4](/assets/images/commands/commandBlockChain/4.png)
我们以`/execute - say`指令为例,你可以根据需求替换为任意指令并自由扩展数量。
请严格遵循给定顺序,并确保在目标指令中正确添加选择器参数`scores={alive=0}`。
## 系统原理
- **`alive=0`** 表示玩家处于死亡状态
- **`alive=1`** 表示玩家处于存活状态
- **`alive=2`** 表示已对死亡玩家执行过预设命令
Here we have used an `/execute - say` command as an example but you can use any command you prefer and as many as you require. - **`@a`** 选择器会选中所有玩家无论生死因此我们用它将所有玩家标记为0死亡
- 注意需要排除已标记为2的玩家否则会导致命令在死亡玩家身上重复执行
Just make sure to follow the given order and properly add the selector argument ` scores={alive=0} ` as shown for your desired commands.
## Explanation
- **` alive=0 `** this means player is dead.
- **` alive=1 `** this means player is alive.
- **` alive=2 `** this means player is dead and we have run our desired commands on/from them.
- **` @a `** selector will target all players alive/dead so we use it to mark everyone as 0 'dead.' - **`@e`** 选择器仅会选中存活玩家因此我们用它将所有存活玩家标记为1存活
- Note: we will ignore 2 or it will end up making the commands execute on dead players again. We only want our commands to execute once.
- **` @e `** selector on the other hand will only target players who are alive, so we can use this to mark all alive players 1 'alive.' - 通过上述标记我们可以在死亡玩家标记0身上执行预设命令
- 执行后需将其分数设为2否则命令会在玩家复活前持续执行
- Now that dead players are 0 and alive players are 1 we can use this knowledge to run our desired commands on the dead players. ## 循环执行配置
- Keep in mind we need to set their score to 2 after or otherwise the commands will keep executing till they respawn.
若使用函数实现,需将`on_player_death`函数添加至`tick.json`以实现循环执行。多个函数可通过逗号分隔添加,详见[函数文档](/wiki/commands/mcfunctions#tick-json)。
## Tick JSON ::: code-group
```json [BP/functions/tick.json]
If you are using functions instead of command blocks, the ` on_player_death ` function must be added to the ` tick.json ` in order to loop and run it continuously. Multiple files can be added to the ` tick.json ` by placing a comma after each string. Refer to [Functions](/commands/mcfunctions#tick-json) documentation for further info.
<CodeHeader>BP/functions/tick.json</CodeHeader>
```json
{ {
"values": [ "values": [
"on_player_death" "on_player_death"
@@ -77,7 +79,7 @@ If you are using functions instead of command blocks, the ` on_player_death ` fu
} }
``` ```
If using functions, your pack folder structure will be be as follows: 使用函数时,资源包文件夹结构如下:
<FolderView <FolderView
:paths="[ :paths="[
@@ -90,6 +92,6 @@ If using functions, your pack folder structure will be be as follows:
]" ]"
></FolderView> ></FolderView>
> **Note:** the scoreboard names (in this case: 'alive') may end up being used by other people. Appending ` _ ` and a set of randomly generated characters after would be a choice that reduces the probability of collisions. Similar technique can be employed for the ` .mcfunction ` filenames. Ex: > **注意:** 计分板名称(如本例中的'alive')可能被他人重复使用。建议在名称后追加`_`和随机字符来降低冲突概率,函数文件名也可采用相同策略。例如:
> - ` alive_0fe678 ` > - `alive_0fe678`
> - ` on_player_death_0fe678.mcfunction ` > - `on_player_death_0fe678.mcfunction`

View File

@@ -1,6 +1,6 @@
--- ---
title: On Player Join title: 玩家加入事件响应
category: On Event Systems category: 事件系统
mentions: mentions:
- BedrockCommands - BedrockCommands
- zheaEvyline - zheaEvyline
@@ -9,66 +9,72 @@ tags:
- system - system
--- ---
## Introduction # 玩家加入事件响应
[Sourced By Bedrock Commands Community Discord](https://discord.gg/SYstTYx5G5) <!--@include: @/wiki/bedrock-wiki-mirror.md-->
This system will run your desired commands on the event that a players joins the world. ## 简介
## Setup [由Bedrock Commands社区Discord提供](https://discord.gg/SYstTYx5G5)
*To be typed in Chat:* 本系统可在玩家加入世界时触发预设命令的执行。
## 设置
*在聊天栏输入以下指令:*
`/scoreboard objectives add joined dummy` `/scoreboard objectives add joined dummy`
If you prefer to have the objective added automatically on world initialisation, follow the process outlined in [On First World Load.](/commands/on-first-world-load) 若需实现世界初始化时自动创建记分板项,请参照[首次世界加载事件响应](/wiki/commands/on-first-world-load)的操作流程。
## System ## 系统实现
<CodeHeader>BP/functions/on_player_join.mcfunction</CodeHeader> ::: code-group
```yaml [BP/functions/on_player_join.mcfunction]
```yaml
scoreboard players add @a joined 0 scoreboard players add @a joined 0
#Your Commands Here (example) #在此处添加你的命令(示例)
tp @a[scores={joined=0}] 0 65 0 tp @a[scores={joined=0}] 0 65 0
scoreboard players reset * joined scoreboard players reset * joined
scoreboard players set @a joined 1 scoreboard players set @a joined 1
``` ```
:::
![commandBlockChain4](/assets/images/commands/commandBlockChain/4.png) ![命令方块链4](/assets/images/commands/commandBlockChain/4.png)
示例中使用了`tp`传送命令,您可以根据实际需求替换为任意命令,并自由扩展命令数量。
Here we have used a `tp` command as an example but you can use any command you prefer and as many as you require. 请确保保持现有执行顺序,并为目标命令正确添加选择器参数 `scores={joined=0}`。
Just make sure to follow the given order and properly add the selector argument ` scores={joined=0} ` as shown for your desired commands. ## 原理说明
## Explanation 当玩家加入时系统会为其记分板项赋初始值0这使我们能够通过`scores`选择器参数定位新加入玩家。
When the player joins, a 0 is added to their objective, this allows us to run commands from them using the 'scores' selector argument. 在命令执行完毕后立即执行以下操作:
1. 使用通配符`*`重置所有玩家的记分板值
2. 为保持在线状态的玩家设置值1
Immediately after the commands are run, we reset all the scores on the objective using wildcard **` * `** and only players who stayed online will have their score set to 1. 通过这种机制由于所有命令仅针对记分板值为0的玩家已在线玩家不会重复触发响应除非他们退出后重新加入或手动执行
And this way, since our commands only target players with the score 0, the commands won't repeat again for the players who stayed unless they leave and rejoin or if we run:
`/scoreboard players set <player> joined 0` `/scoreboard players set <player> joined 0`
## Tick JSON ## 时钟函数配置
If you are using functions instead of command blocks, the ` on_player_join ` function must be added to the ` tick.json ` in order to loop and run it continuously. Multiple files can be added to the ` tick.json ` by placing a comma after each string. Refer to [Functions](/commands/mcfunctions#tick-json) documentation for further info. 若使用函数替代命令方块,需将`on_player_join`函数添加至`tick.json`以实现循环执行。多个函数可通过逗号分隔添加,详见[函数文档](/wiki/commands/mcfunctions#tick-json)。
<CodeHeader>BP/functions/tick.json</CodeHeader> ::: code-group
```json ```json [BP/functions/tick.json]
{ {
"values": [ "values": [
"on_player_join" "on_player_join"
] ]
} }
``` ```
:::
If using functions, your pack folder structure will be be as follows: 使用函数时资源包目录结构如下:
<FolderView <FolderView
:paths="[ :paths="[
@@ -81,6 +87,6 @@ If using functions, your pack folder structure will be be as follows:
]" ]"
></FolderView> ></FolderView>
> **Note:** the scoreboard names (in this case: 'joined') may end up being used by other people. Appending ` _ ` and a set of randomly generated characters after would be a choice that reduces the probability of collisions. Similar technique can be employed for the ` .mcfunction ` filenames. Ex: > **注意:** 记分板名称(本例中的'joined')可能与其他开发者重复使用。建议在名称后追加`_`和随机字符组合以降低冲突概率,函数文件名也可采用类似处理方式。例如:
> - ` joined_0fe678 ` > - `joined_0fe678`
> - ` on_player_join_0fe678.mcfunction ` > - `on_player_join_0fe678.mcfunction`

View File

@@ -1,87 +1,89 @@
--- ---
title: On Player Leave title: 玩家离开事件系统
category: On Event Systems category: 事件系统
mentions: mentions:
- BedrockCommands - BedrockCommands
- zheaEvyline - zheaEvyline
nav_order: 3 nav_order: 3
tags: tags:
- system - 系统
--- ---
## Introduction # 玩家离开事件系统
[Sourced By Bedrock Commands Community Discord](https://discord.gg/SYstTYx5G5) <!--@include: @/wiki/bedrock-wiki-mirror.md-->
This system will run your desired commands on the event that a player leaves the world. ## 简介
> **Note:** you cannot execute commands on the *players* that leave using selectors. However; you may use the [On Player Join](/commands/on-player-join) system to execute when they join back. [由 Bedrock Commands 社区 Discord 提供](https://discord.gg/SYstTYx5G5)
## Setup 本系统可在玩家离开世界时运行你指定的命令。
*To be typed in Chat:* > **注意:** 无法通过选择器对离开的玩家本体执行命令。但你可以使用[玩家加入事件系统](/wiki/commands/on-player-join)在他们重新加入时执行命令。
## 系统搭建
*在聊天栏输入以下指令:*
`/scoreboard objectives add total dummy` `/scoreboard objectives add total dummy`
If you prefer to have the objective added automatically on world initialisation, follow the process outlined in [On First World Load.](/commands/on-first-world-load) 若希望在世界初始化时自动添加计分项,请参照[首次世界加载事件系统](/wiki/commands/on-first-world-load)的操作流程。
## System ## 系统核心
<CodeHeader>BP/functions/on_player_leave.mcfunction</CodeHeader> ::: code-group
```yaml [BP/functions/on_player_leave.mcfunction]
```yaml
scoreboard players reset new total scoreboard players reset new total
execute as @a run scoreboard players add new total 1 execute as @a run scoreboard players add new total 1
scoreboard players operation new total -= old total scoreboard players operation new total -= old total
#Your Commands Here (example) #在此处输入你的命令(示例)
execute if score new total matches ..-1 run say a player has left the world execute if score new total matches ..-1 run say 有玩家离开了世界
scoreboard players reset old total scoreboard players reset old total
execute as @a run scoreboard players add old total 1 execute as @a run scoreboard players add old total 1
``` ```
![commandBlockChain6](/assets/images/commands/commandBlockChain/6.png) ![命令方块链6](/assets/images/commands/commandBlockChain/6.png)
Here we have used a **`/say`** command as an example but you can use any command you prefer and as many as you require. 此处我们以 **`/say`** 命令作为示例,你可以根据需要替换为任意命令并自由扩展。
Just make sure to follow the given order and properly use the `/execute if score` command as shown to run the commands you need. 请严格按照给定顺序排列命令,并正确使用示例中的 `/execute if score` 命令结构来触发你的自定义命令。
## Explanation ## 原理说明
- **` new `** this FakePlayer name means the total number of players on the world in the current game tick. - **` new `** 这个虚拟玩家名称表示当前游戏刻中世界内的玩家总数
- **` old `** this FakePlayer name means the total number of players that were on the world in the previous game tick but also saves the values to be used in the *next* game tick. - **` old `** 这个虚拟玩家名称表示前一游戏刻的玩家总数,同时会将数值保存供下一游戏刻使用
These values are obtained using the [Entity Counter](/commands/entity-counter) system. It may be beneficial to refer to that doc for better understanding this one. 这些数值通过[实体计数系统](/wiki/commands/entity-counter)获取,建议结合该文档以获得更深入的理解。
By subtracting 'old' total from 'new' total we will be able to identify if player count has: 通过从'new'总数中减去'old'总数,我们可以判断玩家数量是否发生:
- decreased ` ..-1 ` - 减少 ` ..-1 `
- increased ` 1.. ` - 增加 ` 1.. `
- or if it's unchanged ` 0 ` - 或保持不变 ` 0 `
If it has decreased; we know that 1 or more players have left the game. 当检测到数值减少时(即得分为-1或更低我们就能确定有1名或更多玩家离开了游戏。
With this knowledge we can run our desired commands from 'new' if it's score is -1 or less. - 示例原有10名玩家时有人离开
- ie, if there were 10 players and someone leaves: - 计算式为 ` new - old `
- that is ` new - old ` - 即 ` 9 - 10 = -1 `
- which is ` 9 - 10 = -1 ` - 因此通过 ` ..-1 ` 条件检测
- hence we will detect by ` ..-1 `
- The 'new' total value is obtained first, subtraction is performed after that to run your desired commands and lastly the 'old' total value is obtained to be used in the next game tick. - 系统首先获取'new'总数,执行减法运算后运行你的自定义命令,最后获取'old'总数供下一游戏刻使用
:::tip :::tip 游戏刻解析
All commands involved in a command-block-chain or function will only run in a sequence one after the other but it all still happens in the same tick regardless of the number of commands involved. We are able to achieve this system due to the fact that commands run along the end of a game tick after all events such as player log in, log out, death etc.. occur. 所有在命令方块链或函数中运行的指令都会在同一游戏刻内按顺序依次执行。由于命令执行发生在游戏刻的末端(包含所有玩家登录、登出、死亡等事件之后),本系统得以精准运作。
![gametick](/assets/images/commands/gametick.png) ![游戏刻示意图](/assets/images/commands/gametick.png)
::: :::
## Tick JSON ## Tick JSON 配置
If you are using functions instead of command blocks, the ` on_player_leave ` function must be added to the ` tick.json ` in order to loop and run it continuously. Multiple files can be added to the ` tick.json ` by placing a comma after each string. Refer to [Functions](/commands/mcfunctions#tick-json) documentation for further info. 若使用函数替代命令方块,需将 ` on_player_leave ` 函数添加至 ` tick.json ` 以实现循环执行。通过在字符串后添加逗号分隔,可将多个文件添加至 ` tick.json `。更多信息请参考[函数文档](/wiki/commands/mcfunctions#tick-json)。
<CodeHeader>BP/functions/tick.json</CodeHeader> ::: code-group
```json ```json [BP/functions/tick.json]
{ {
"values": [ "values": [
"on_player_leave" "on_player_leave"
@@ -89,7 +91,7 @@ If you are using functions instead of command blocks, the ` on_player_leave ` fu
} }
``` ```
If using functions, your pack folder structure will be be as follows: 使用函数时,资源包文件夹结构如下:
<FolderView <FolderView
:paths="[ :paths="[
@@ -102,6 +104,6 @@ If using functions, your pack folder structure will be be as follows:
]" ]"
></FolderView> ></FolderView>
> **Note:** the scoreboard names (in this case: 'total') may end up being used by other people. Appending ` _ ` and a set of randomly generated characters after would be a choice that reduces the probability of collisions. Similar technique can be employed for the ` .mcfunction ` filenames. Ex: > **注意:** 计分项名称(本例中的'total')可能与他人重复。建议在名称后追加 ` _ ` 和随机字符组合来降低冲突概率,此技巧同样适用于 ` .mcfunction ` 文件名。例如:
> - ` total_0fe678 ` > - ` total_0fe678 `
> - ` on_player_leave_0fe678.mcfunction ` > - ` on_player_leave_0fe678.mcfunction `

View File

@@ -1,6 +1,6 @@
--- ---
title: On Player Respawn title: 玩家重生事件
category: On Event Systems category: 事件系统
mentions: mentions:
- BedrockCommands - BedrockCommands
- zheaEvyline - zheaEvyline
@@ -9,66 +9,71 @@ tags:
- system - system
--- ---
## Introduction # 玩家重生事件
[Sourced By Bedrock Commands Community Discord](https://discord.gg/SYstTYx5G5) <!--@include: @/wiki/bedrock-wiki-mirror.md-->
This system will run your desired commands on the event that a player respawns from death state. ## 前言
## Setup [由Bedrock Commands社区Discord提供](https://discord.gg/SYstTYx5G5)
*To be typed in Chat:* 当玩家从死亡状态重生时,该系统将执行您指定的命令。
## 初始化设置
*在聊天栏输入以下指令:*
`/scoreboard objectives add respawn dummy` `/scoreboard objectives add respawn dummy`
If you prefer to have the objective added automatically on world initialisation, follow the process outlined in [On First World Load.](/commands/on-first-world-load) 若希望在世界初始化时自动添加计分板,请参照[首次世界加载](/wiki/commands/on-first-world-load)指南操作。
## System ## 系统实现
<CodeHeader>on_player_respawn.mcfunction</CodeHeader> ::: code-group
```yaml [on_player_respawn.mcfunction]
```yaml # 在此处添加你的命令(示例)
#Your Commands Here (example) execute as @e [scores={respawn=1}] run say 我已死亡并重生。
execute as @e [scores={respawn=1}] run say I died and respawned.
scoreboard players set @a respawn 1 scoreboard players set @a respawn 1
scoreboard players set @e [type=player] respawn 0 scoreboard players set @e [type=player] respawn 0
``` ```
![commandBlockChain3](/assets/images/commands/commandBlockChain/3.png) :::
![命令方块链3](/assets/images/commands/commandBlockChain/3.png)
Here we have used an `/execute - say` command as an example but you can use any command you prefer and as many as you require. 本例中使用`/execute - say`指令作为示例,您可以根据需求替换为任意指令,数量不限。
Just make sure to follow the given order and properly use the selector argument ` @e [scores={respawn=1}] ` as shown for your desired commands. 请严格遵循指令顺序,并正确使用选择器参数` @e [scores={respawn=1}] `来定位目标玩家。
## Explanation ## 运行原理
- **` respawn=0 `** this means the player is alive or had already respawned. - **` respawn=0 `** 表示玩家存活或已完成重生
- **` respawn=1 `** this means the player died and is now respawning, ie. respawned *just now*, in the current gametick. - **` respawn=1 `** 表示玩家死亡且正在重生(即当前游戏刻内刚触发重生)
- **` @a `** selector will target all players alive/dead so we use it to mark everyone as 1 'respawning' - **` @a `** 选择器将定位所有玩家(包括存活/死亡用于标记全体玩家为1正在重生状态
- **` @e `** selector on the other hand will only target players who are alive, so we can use this to mark all alive players 0 'respawned' - **` @e `** 选择器仅定位存活玩家用于重置存活玩家为0已完成重生状态
Now that *respawning* players are 1 and *respawned* players are 0 we can use this knowledge to run our desired commands on the players respawning. 通过此机制我们可以精准捕捉到刚刚重生的玩家分数为1的玩家来执行指定命令。
In the system, your desired commands must come before the other 2 commands because players change from death state to alive state along the start of the gametick before commands are run. 在系统文件中,自定义命令必须放置在最后两条计分板操作指令之前,因为玩家状态会在游戏刻开始时立即从死亡转为存活。
Hence; if we were to put them at the end then the other 2 commands would set respawning players score to 0 first and then the commands you want to run won't be able to select those players as our selector argument is ` @e [scores={respawn=1}] ` not 0. Using 0 would not work as then it would repeat endlessly even on players who have already respawned. 若将自定义命令置于末尾计分板操作会先将重生玩家的分数重置为0此时通过` @e [scores={respawn=1}] `选择器将无法定位到目标玩家。若使用分数0作为条件则会导致指令在已重生玩家身上重复触发。
## Tick JSON ## 游戏刻函数配置
If you are using functions instead of command blocks, the ` on_player_respawn ` function must be added to the ` tick.json ` in order to loop and run it continuously. Multiple files can be added to the ` tick.json ` by placing a comma after each string. Refer to [Functions](/commands/mcfunctions#tick-json) documentation for further info. 若使用函数而非命令方块,需将` on_player_respawn `函数添加至` tick.json `以实现循环检测。多个函数可通过逗号分隔添加,详见[函数文档](/wiki/commands/mcfunctions#tick-json)。
<CodeHeader>BP/functions/tick.json</CodeHeader> ::: code-group
```json ```json [BP/functions/tick.json]
{ {
"values": [ "values": [
"on_player_respawn" "on_player_respawn"
] ]
} }
``` ```
:::
If using functions, your pack folder structure will be be as follows: 函数包的文件结构如下所示:
<FolderView <FolderView
:paths="[ :paths="[
@@ -81,6 +86,6 @@ If using functions, your pack folder structure will be be as follows:
]" ]"
></FolderView> ></FolderView>
> **Note:** the scoreboard names (in this case: 'respawn') may end up being used by other people. Appending ` _ ` and a set of randomly generated characters after would be a choice that reduces the probability of collisions. Similar technique can be employed for the ` .mcfunction ` filenames. Ex: > **注意:** 计分板名称(本例中的'respawn')可能与其他开发者冲突。建议在名称后追加` _ `和随机字符组合来降低重复概率,函数文件名也可采用相同策略。例如:
> - ` respawn_0fe678 ` > - ` respawn_0fe678 `
> - ` on_player_respawn_0fe678.mcfunction ` > - ` on_player_respawn_0fe678.mcfunction `

View File

@@ -1,79 +1,84 @@
--- ---
title: Playsound title: 播放音效
category: Commands category: 命令
mentions: mentions:
- BedrockCommands - BedrockCommands
- zheaEvyline - zheaEvyline
- jordanparki7 - jordanparki7
tags: tags:
- info - 信息
--- ---
## Introduction # 播放音效
[Sourced By Bedrock Commands Community Discord](https://discord.gg/SYstTYx5G5) <!--@include: @/wiki/bedrock-wiki-mirror.md-->
You can use the `/playsound` command to play sound effects to players present anywhere in the world whenever you like. ## 简介
## Syntax [由 Bedrock Commands 社区 Discord 提供](https://discord.gg/SYstTYx5G5)
你可以使用`/playsound`命令在世界任意位置为玩家播放音效。
## 语法
`/playsound <sound> [player] [position] [volume] [pitch] [minimumVolume]` `/playsound <sound> [player] [position] [volume] [pitch] [minimumVolume]`
## Definitions ## 参数定义
### Sound ### sound
- It is the sound effect you wish to play. - 需要播放的音效ID
- You can find the list of sound IDs currently available at: - 当前可用音效列表可参考:
- https://www.digminecraft.com/lists/sound_list_pe.php - https://www.digminecraft.com/lists/sound_list_pe.php
### Player ### player
- This is an optional argument. - 可选参数
- It refers to your typical target selectors (whom you want to play the sound to) ` @a `, ` @r `, ` @p `, ` Technoblade `, etc.. - 目标选择器参数(接收音效的玩家)` @a `, ` @r `, ` @p `, ` Technoblade `
### Position ### position
- This is an optional argument. - 可选参数
- It refers to the `x y z` position from where the sound will be played, ie. the center of the playsound radius. - 音效播放的坐标 `x y z`,即音效可听范围的圆心坐标
### Volume ### volume
- This is an optional argument. - 可选参数
- It determines the size of the sphere in which the sound effect can be heard. - 决定音效可听范围的半径
- ` 0.0 ` is the minimum size. - 最小值是 `0.0`
- Sound & audible sphere size increases as `volume` value is increased. - 该值越大,音效传播范围越广
- Playaound volume of `1` is equal to an audible sphere of radius 16 blocks. - 音量 `1` 对应半径16方块的球形范围
- Similarly; volume of `4` would be equal to 64 blocks. - 音量 `4` 对应半径64方块的球形范围
### Pitch ### pitch
- This is an optional aegument. - 可选参数
- It determines the pitch for the sound effect. - 控制音效的音调高低
- It can be a value between ` 0.0 ` and ` 256.0 ` - 取值范围 `0.0` `256.0`
- The higher the value, the higher the pitch. - 数值越高音调越尖锐
- Values less than or equal to `0.0` makes the sound inaudible. - 数值小于等于 `0.0` 时音效不可闻
> Note: pitch affects the speed at which the audio is played. For example, a pitch of `0.5` would mean the audio is played at ` 0.5× ` speed. > 注意:音调参数会影响音频播放速度。例如音调 `0.5` 表示以 0.5 倍速播放音频
### Minimum Volume ### minimumVolume
- This is an optional argument. - 可选参数
- It determines the minimum volume at which the sound will be heard outside of the audible sphere. - 设置可听范围外的最小音量
- It can be a value between ` 0.0 ` and ` 1.0 ` - 取值范围 `0.0` `1.0`
## Examples ## 使用示例
<CodeHeader>mcfunction</CodeHeader> ::: code-group
```yaml ```yaml [mcfunction]
#Play a random explosion sound effect to closest player. # 对最近的玩家播放随机爆炸音效
/playsound random.explode @p /playsound random.explode @p
#Play a random orb sound effect to all players at their relative position with a volume of 10000 # 为所有玩家在其当前位置播放随机经验球音效(音量范围10000
/execute as @a at @s playsound random.orb @s ~ ~ ~ 10000 /execute as @a at @s playsound random.orb @s ~ ~ ~ 10000
``` ```
:::
Note: since the playsound command is positonal, it is helpful to use an execute command structure as shown in the second example to prevent the sound effect from cutting off in special cases such as playing a sound effect following a `/tp` command. You may increase volume when covering large distances to reduce failures. 注意:由于播放音效命令具有位置依赖性,在特殊场景(如使用`/tp`传送后)建议采用第二个示例中的`execute`命令结构来避免音效中断。当需要覆盖远距离时,可以适当增大音量参数来确保播放效果。
**(Recommended) Read Next: [Sounds](/concepts/sounds)** **(推荐)延伸阅读:[声音系统](/wiki/concepts/sounds)**

View File

@@ -1,6 +1,6 @@
--- ---
title: Coordinate System title: 坐标系系统
category: General category: 基础
mentions: mentions:
- MedicalJewel105 - MedicalJewel105
- Sprunkles137 - Sprunkles137
@@ -9,38 +9,55 @@ mentions:
- TheItsNameless - TheItsNameless
--- ---
## The Coordinate System # 坐标系系统
Minecraft stores the locations of blocks and entities in the world using a system of three-dimensional coordinates, each representing a value in a one-dimensional axis. They are stored in the format of X, then Y, and lastly Z. Whether you are placing structures and blocks, or teleporting and summoning entities, you can, and are sometimes required to, put in coordinates. They don't need to always be real values however; you can substitute world coordinates for relative values, either based in world space or local space. <!--@include: @/wiki/bedrock-wiki-mirror.md-->
![image](https://user-images.githubusercontent.com/64864915/134789891-85644dd7-e30f-4e02-966c-df2bf17a7879.png) ## 坐标系基础
_You may already be familiar with coordinates if you've enabled the Show Coordinates world option!_ Minecraft使用三维坐标系来存储世界中方块和实体的位置每个坐标代表一维轴上的数值。坐标以X、Y、Z的顺序存储。无论是放置结构方块还是传送/召唤实体,你都可以(有时必须)使用坐标值。不过坐标不限于绝对数值,你可以使用相对坐标系——既可以选择基于世界空间的相对坐标,也可以选择基于局部空间的本地坐标。
## Relative Coordinates (~) ![坐标系示意图](https://user-images.githubusercontent.com/64864915/134789891-85644dd7-e30f-4e02-966c-df2bf17a7879.png)
Relative coordinates are represented using tildes in place of real coordinates, and represent a position that is relative to the world coordinates its located at. You may insert numbers after a tilde to add an offset to the current position. These can be mixed with world coordinates, but cannot be mixed with local coordinates. _如果你启用了"显示坐标"世界选项,可能已经对坐标系统有所了解!_
Examples: ## 相对坐标 (~)
- `~ ~ ~`: Current position with no changes.
- `~5 ~-2 ~`: Current position with a 5-block X offset and a negative 2-block Y offset.
### Rotations 相对坐标使用波浪符号`~`代替具体数值,表示相对于当前所处世界坐标的位置。在波浪符后添加数字可以指定偏移量。相对坐标可与世界坐标混合使用,但不能与局部坐标混用。
Relative coordinates can also be used in the context of rotations, where they represent a rotation that is relative to the current rotation it inherits from. These may also accept numbers after the tilde to add an offset to the current rotation. 示例:
- `~ ~ ~`: 保持当前位置不变
- `~5 ~-2 ~`: 当前位置X轴正方向偏移5格Y轴负方向偏移2格
Example: `~90 ~` will add 90° to the current yaw (y-rotation) value. ### 旋转角度中的应用
## Local Coordinates (^) 相对坐标也可用于表示旋转角度,这时表示相对于当前继承的旋转角度。同样可以在波浪符后添加数字来指定偏移量。
Local coordinates are similar to relative coordinates, but represent a position in local space, where the axes are based off of rotation. They take the form `^left ^up ^forward`; you can think of this as `~x ~y ~z` if both your yaw and pitch rotations are 0 (facing straight ahead, due south). 示例:`~90 ~` 表示在当前偏航角Y轴旋转基础上增加90度
Like relative coordinates, you can insert numbers to produce an offset of the current position, in local space. If there is no entity to copy rotation from, the x- and y-rotations are assumed to be 0. ## 局部坐标 (^)
Examples: 局部坐标与相对坐标类似,但表示基于实体朝向的局部空间坐标,采用`^左 ^上 ^前`的格式。当实体偏航角和俯仰角均为0面朝正南平视可以将其理解为`~x ~y ~z`坐标系。
- `^10 ^ ^`: Current position with a 10-block offset to the left.
- `^ ^1.5 ^1`: Current position with a 1.5-block offset upward and a 1-block offset forward.
## Additional Notes 与相对坐标类似可以添加数字来指定局部空间中的偏移量。如果没有可供参考旋转角度的实体则默认X/Y旋转角度为0。
- The player's eye level is 1.62 blocks above their feet. (~ ~1.62 ~) 示例:
- `^10 ^ ^`: 当前位置左侧偏移10格
- `^ ^1.5 ^1`: 当前位置上方偏移1.5格前方偏移1格
## 注意事项
- 玩家眼部高度位于脚部上方1.62格处(对应相对坐标`~ ~1.62 ~`
::: code-group
```json [示例配置]
// 此处保持代码原样,仅翻译注释
// 玩家传送指令示例
{
"command": "tp @s ~ ~5 ~", // 将玩家垂直提升5格
"comment": "使用相对坐标进行垂直传送"
}
```
:::
_注意本地坐标(^)系统在实体具有复杂旋转角度时会产生非直观的位移效果,建议在建筑类命令中使用世界相对坐标(~)系统在实体局部操作时使用本地坐标系。_

View File

@@ -1,6 +1,6 @@
--- ---
title: Scoreboard Operations title: 记分板操作
category: General category: 基础
mentions: mentions:
- Sprunkles137 - Sprunkles137
- Luthorius - Luthorius
@@ -8,128 +8,131 @@ mentions:
- Hatchibombotar - Hatchibombotar
--- ---
Scoreboards can be used to perform complex operations, similar to [Molang](/concepts/molang). Operations come in two flavors: mathematical, and logical. # 记分板操作
## Overview <!--@include: @/wiki/bedrock-wiki-mirror.md-->
Operations are performed using the `/scoreboard players operation` command. The full syntax is laid out below:
记分板可用于执行复杂运算,其功能类似于[Molang](/wiki/concepts/molang)。运算分为两类:数学运算和逻辑运算。
## 概述
使用`/scoreboard players operation`命令执行运算。完整语法如下:
``` ```
/scoreboard players operation <targetScore> <objective> <operation> <sourceScore> <objective> /scoreboard players operation <目标分数> <记分项> <运算符> <源分数> <记分项>
``` ```
The command consists of two score holders: The target score, and the source score. The target score is the value being operated on, and the source score is the value affecting the operation. The result of the operation is written into the target score, and the source score's value is not touched, save for [one operation](/commands/scoreboard-operations#swap-operator). 该命令包含两个分数持有者:目标分数和源分数。目标分数是被操作的值,源分数是参与运算的值。运算结果将写入目标分数,源分数的值不会被修改(除[交换运算符](/wiki/commands/scoreboard-operations#swap-operator)外)。
## Mathematical Operators ## 数学运算符
Mathematical operators use arithmetic to affect the target score. There are five mathematical operations available: addition, subtraction, multiplication, floor division, and floor modulo division. 数学运算符通过算术运算影响目标分数。共有五种数学运算:加法、减法、乘法、向下取整除法和向下取整模除。
For each of the following examples below, assume that score holder `A var` equals 25, and `B var` equals 10. 以下示例均假设分数持有者`A var`的值为25`B var`的值为10
### Addition ### 加法
Operator: **+=** 运算符:**+=**
This operation adds the target score and source scores together, then stores the sum into the target score. 将目标分数与源分数相加,结果存入目标分数。
``` ```
/scoreboard players operation A var += B var /scoreboard players operation A var += B var
``` ```
`A = A + B`, and as such `25 + 10 = 35`. `A = A + B`,运算结果为`25 + 10 = 35`
### Subtraction ### 减法
Operator: **-=** 运算符:**-=**
This operation subtracts the target score by the source score, then stores the difference into the target score. 从目标分数中减去源分数,结果存入目标分数。
``` ```
/scoreboard players operation A var -= B var /scoreboard players operation A var -= B var
``` ```
`A = A - B`, and as such `25 - 10 = 15`. `A = A - B`,运算结果为`25 - 10 = 15`
### Multiplication ### 乘法
Operator: **\*=** 运算符:***=**
This operation multiplies the target score by the source score, then stores the product into the target score. 将目标分数乘以源分数,结果存入目标分数。
``` ```
/scoreboard players operation A var *= B var /scoreboard players operation A var *= B var
``` ```
`A = A * B`, and as such `25 * 10 = 250`. `A = A * B`,运算结果为`25 * 10 = 250`
### Floored Division ### 向下取整除法
Operator: **/=** 运算符:**/=**
This operation divides the target score by the source score, then stores the quotient into the target score. Because score values can only be integers, the value is floored, or rounded down. 将目标分数除以源分数,结果向下取整后存入目标分数(由于分数值只能是整数)。
``` ```
/scoreboard players operation A var /= B var /scoreboard players operation A var /= B var
``` ```
`A = floor(A / B)`, and as such `floor(25 / 10) = 2`. `A = floor(A / B)`,运算结果为`floor(25 / 10) = 2`
### Floored Modulo Division ### 向下取整模除
Operator: **%=** 运算符:**%=**
This operation also divides the target score by the source score, but instead returns the remainder after the division into the target score. This is also floored. 将目标分数除以源分数后取余数,结果向下取整后存入目标分数。
``` ```
/scoreboard players operation A var %= B var /scoreboard players operation A var %= B var
``` ```
`A = floor(mod(A, B))`, and as such `floor(mod(25, 10)) = 5`. `A = floor(mod(A, B))`,运算结果为`floor(mod(25, 10)) = 5`
## Logical Operators ## 逻辑运算符
Logical operations use logic gates and assignments to affect the target score. There are four logical operations available: assignment, less than, greater than, and swap. 逻辑运算符使用逻辑门和赋值操作来影响目标分数。共有四种逻辑运算:赋值、最小值、最大值和交换。
Similar to the above, assume that score holder `A var` equals 25, and `B var` equals 10. 同样假设分数持有者`A var`的值为25`B var`的值为10
### Assignment Operator ### 赋值运算符
Operator: **=** 运算符:**=**
This operation sets the target score equal to the source score. 将目标分数设置为源分数的值。
``` ```
/scoreboard players operation A var = B var /scoreboard players operation A var = B var
``` ```
`A = B`, and as such the result is `10`. `A = B`,运算结果为`10`
### Minimum Operator ### 最小值运算符
Operator: **<** 运算符:**<**
This operation returns the smallest of the input scores, and stores it into the target score. 比较两个分数后,将较小值存入目标分数。
``` ```
/scoreboard players operation A var < B var /scoreboard players operation A var < B var
``` ```
`A = min(A, B)`, and as such `min(25, 10) = 10`. `A = min(A, B)`,运算结果为`min(25, 10) = 10`
### Maximum Operator ### 最大值运算符
Operator: **>** 运算符:**>**
This operation returns the largest of the input scores, and stores it into the target score. 比较两个分数后,将较大值存入目标分数。
``` ```
/scoreboard players operation A var > B var /scoreboard players operation A var > B var
``` ```
`A = max(A, B)`, and as such `max(25, 10) = 25`. `A = max(A, B)`,运算结果为`max(25, 10) = 25`
### Swap Operator ### 交换运算符
Operator: **><** 运算符:**><**
This operation swaps the target score and source scores with each other. This is the only operation that affects the source score. 交换目标分数和源分数的值。这是唯一会影响源分数的运算符。
``` ```
/scoreboard players operation A var >< B var /scoreboard players operation A var >< B var
``` ```
The above command would swap the values of A and B e.g. 执行上述命令后A和B的值将互换
Before: A = 10; B = 25; 执行前:A = 10B = 25
After: A = 25; B = 10; 执行后:A = 25B = 10
This can be seen as three operations: `temp = A; A = B; B = temp;`, and as such `A var = 10` and `B var = 25`. 该操作等效于三步操作:`temp = A; A = B; B = temp;`,最终`A var = 10``B var = 25`
## Useful Creations ## 实用案例
#### Check If Values are Equal #### 检查数值是否相等
If you want to check in scoreboard, whether one value equals another value, you can copy first value to temporary value, subtract the other and compare temporary value to zero. Given values A and B: 若要通过记分板检查两个值是否相等可将第一个值复制到临时变量再减去第二个值后比较临时变量是否为0。假设有值A和B
<CodeHeader></CodeHeader> ::: code-group
```json [实体标签]
```
scoreboard objectives add temp dummy scoreboard objectives add temp dummy
scoreboard players operation @e temp = @s A scoreboard players operation @e temp = @s A
scoreboard players operation @e temp -= @s B scoreboard players operation @e temp -= @s B
execute @e[scores={temp=0}] ~~~ say A equals B execute @e[scores={temp=0}] ~~~ say A等于B
scoreboard objectives remove temp scoreboard objectives remove temp
``` ```
#### Scoreboard Initialization #### 记分板初始化
If you want to initialize a scoreboard value to 0, but only if it doesn't exists, you can use `scoreboard players add <selector> <name> 0`. It will set the value to 0, if it doesn't exist on the entity and do nothing, if it already exist. 若要将记分板值初始化为0仅当该值不存在时可使用`scoreboard players add <选择器> <名称> 0`。此命令会在实体不存在该分数时设为0若已存在则不做任何操作。

View File

@@ -1,200 +1,176 @@
--- ---
title: Scoreboard Timers title: 记分板计时器
category: Scoreboard Systems category: 计分板系统
mentions: mentions:
- BedrockCommands - BedrockCommands
- zheaEvyline - zheaEvyline
nav_order: 5 nav_order: 5
tags: tags:
- system - 系统
--- ---
## Introduction # 记分板计时器
[Sourced By Bedrock Commands Community Discord](https://discord.gg/SYstTYx5G5) <!--@include: @/wiki/bedrock-wiki-mirror.md-->
This system allows you to run your desired commands at specific intervals with any amount of delay that you wish to add. ## 简介
- **Some Examples:** [源自 Bedrock Commands 社区 Discord](https://discord.gg/SYstTYx5G5)
- Sending a message in chat every 2 hours.
- Running a 'lag clear' function every 10 minutes.
- Effecting players with 'speed' every 30 seconds.
This system is especially useful when you need to set up multiple timers on your world. When working with command blocks, you may use the [Tick Delay](/commands/intro-to-command-blocks#command-block-tick-delay) option to delay the time taken for your commands to run. However, when working with functions you will need to use a system like this.
It is recommended to use this system while working with command blocks, as well if you wish to run all your timers in sync with one another, ie. with the same start time. 本系统允许你在指定时间间隔内运行自定义指令,延迟时长可根据需求自由设定。
## Setup
*To be typed in chat:* - **应用场景示例:**
<CodeHeader></CodeHeader> - 每2小时在聊天栏发送消息
- 每10分钟执行一次"清除延迟"函数
- 每30秒给玩家施加速度效果
```yaml 当需要在世界中设置多个计时器时,本系统尤为实用。使用命令方块时可通过[Tick 延迟](/wiki/commands/intro-to-command-blocks#command-block-tick-delay)选项来延迟指令执行,但在函数中则需要依赖此类系统。
推荐在命令方块中也使用本系统,以便让所有计时器保持同步启动。
## 初始设置
*在聊天栏输入以下指令:*
::: code-group
```yaml [初始化]
scoreboard objectives add ticks dummy scoreboard objectives add ticks dummy
scoreboard objectives add events dummy scoreboard objectives add events dummy
``` ```
Once you have created these two objectives, you will need to define the interval for each repeating event you need on your world in the `ticks` objective. 创建这两个记分项后,需要在`ticks`记分项中为每个重复事件定义间隔时间。
To do that, first you must know that **1 second is approximately 20 game ticks in Minecraft**. Based on this knowledge, you will need to do some basic calculations to obtain the ticks equivalent for each interval you want to define. 需注意**Minecraft中1秒约等于20游戏刻**,可通过基础运算换算所需时间对应的刻数。
<CodeHeader></CodeHeader> ::: code-group
```yaml [时间换算]
```yaml # 2小时 = 20(t) × 60(秒) × 60(分) × 2(小时) = 144000刻
# 2h = 20(t) × 60(s) × 60(m) × 2(h) = 144000t
scoreboard players set 2h ticks 144000 scoreboard players set 2h ticks 144000
#10m = 20(t) × 60(s) × 10(m) = 12000t #10分钟 = 20(t) × 60() × 10() = 12000
scoreboard players set 10m ticks 12000 scoreboard players set 10m ticks 12000
#30s = 20(t) × 30(s) = 600t #30 = 20(t) × 30() = 600
scoreboard players set 30s ticks 600 scoreboard players set 30s ticks 600
``` ```
We will now use this scoreboard data to make our timers function. :::
## System ## 系统实现
<CodeHeader>mcfunction</CodeHeader> ::: code-group
```yaml [计时系统.mcfunction]
```yaml
scoreboard players add timer ticks 1 scoreboard players add timer ticks 1
scoreboard players operation * events = timer ticks scoreboard players operation * events = timer ticks
#Chat Message (every 2h) # 聊天消息每2小时
scoreboard players operation chatMessage events %= 2h ticks scoreboard players operation chatMessage events %= 2h ticks
execute if score chatMessage events matches 0 run say Technoblade never dies! execute if score chatMessage events matches 0 run say 技术之刃永世长存!
#Lag Clear (every 10m) # 延迟清理每10分钟
scoreboard players operation lagClear events %= 10m ticks scoreboard players operation lagClear events %= 10m ticks
execute if score lagClear events matches 0 run function clear_lag execute if score lagClear events matches 0 run function clear_lag
#Speed Effect (every 30s) # 速度效果每30秒
scoreboard players operation speedEffect events %= 30s ticks scoreboard players operation speedEffect events %= 30s ticks
execute if score speedEffect events matches 0 run effect @a speed 10 2 true execute if score speedEffect events matches 0 run effect @a speed 10 2 true
``` ```
![commandBlockChain8](/assets/images/commands/commandBlockChain/8.png)
Here we have taken 3 examples to give you an idea on how to do it, but you can add any timer you need and as many as you require.
Just make sure to follow the given order and properly use the `/execute if score` command as shown to run the commands you need.
## Explanation
- **` events `** on this objective we label all the repeating events we want on our world.
- `chatMessage`
- `lagClear`
- `speedEffect`
- **` ticks `** on this objective we define all the intervals for our events and also run our scoreboard timer.
- ` 2h` interval (static score 144000)
- `10m` interval (static score 12000)
- `30s` interval (static score 600)
- `timer` clock (variable score n+1)
- **Command 1:** this command adds +1 score every tick to FakePlayer name `timer` indicating a tick has passed in the game. This is basically our scoreboard timer/clock which we will use for all the repeating events on our world.
- **Command 2:** here we copy `timer` score to all our events using the ` * ` wildcard selector. This will allow us to perform operations to determine if the interval has been reached to run the commands for that particular event. Example:
- If `timer` score is 1200 that means 1200 game ticks have passed.
- And this command makes it so all our events FakePlayer names: `chatMessage`, `lagClear`, `speedEffect` scores are also 1200.
- **Command 3:** we will use the ` %= ` modulo operation to check if our event score is divisible by it's corresponding interval. A number is said to be divisible when the remainder is 0.
- Chat Message: `1200/144000` Q=0, R=1200, *hence interval not reached.*
- Lag Clear: `1200/12000` Q=0, R=1200, *hence interval not reached.*
- Speed Effect: `1200/600` Q=2, R=0, *hence interval has reached and event commands can be executed.*
Here we can note that the first 2 events are yet to happen but the 3rd event is happening for the second time.
:::tip
In Minecraft; scoreboard division is only calculated up to whole numbers and decimal values are ignored.
![longDivision](/assets/images/commands/longDivision.png)
::: :::
![命令方块链示意图](/assets/images/commands/commandBlockChain/8.png)
- **Command 4:** the remainder value obtained from the calculation is applied to the corresponding event FakePlayer name. Based on this knowledge we can run our command if it's score is equal to 0. 本示例展示了三种计时器的实现方法,您可根据需求扩展更多计时器。请严格按照顺序编写指令,并正确使用`/execute if score`条件判断。
The rest of the commands are identical in structure and only the event labels and interval values are changed. ## 系统解析
## Defining Events With Limited Intervals - **`events`记分项:** 用于标记所有需要重复执行的事件
- `chatMessage` - 聊天消息
- `lagClear` - 延迟清理
- `speedEffect` - 速度效果
- **`ticks`记分项:** 存储事件间隔参数与计时器数值
- `2h`间隔固定值144000
- `10m`间隔固定值12000
- `30s`间隔固定值600
- `timer`计时器(动态累加值)
To limit how many times an event occurs, you will need to create a new objective called `intervals` and define how many times the event should occur like so: **指令详解:**
<CodeHeader></CodeHeader> 1. **计时累加:** 每游戏刻为`timer`虚拟玩家分数+1作为全局时间基准
2. **数值同步:** 将`timer`数值复制到所有事件虚拟玩家,建立时间参照
3. **模运算检测:** 使用` %= `运算符计算余数当余数为0时触发事件
4. **事件触发:** 根据模运算结果执行对应指令
```yaml :::tip 模运算原理
scoreboard objectives set chatMessage intervals 5 Minecraft中的分数除法仅保留整数部分余数通过模运算获取。当余数为0时表示达到设定间隔。
scoreboard objectives set speedEffect intervals 10 ![长除法示意图](/assets/images/commands/longDivision.png)
:::
## 有限次数事件
如需限制事件触发次数,可创建`intervals`记分项来设置剩余触发次数:
::: code-group
```yaml [次数限制]
scoreboard players set chatMessage intervals 5
scoreboard players set speedEffect intervals 10
``` ```
Once you have done that, modify your system from above like so: 修改系统函数如下:
::: code-group
<CodeHeader>mcfunction</CodeHeader> ```yaml [有限次数版.mcfunction]
```yaml
scoreboard players add timer ticks 1 scoreboard players add timer ticks 1
scoreboard players operation * events = timer ticks scoreboard players operation * events = timer ticks
#Chat Message (every 10m) # 聊天消息每2小时
scoreboard players operation chatMessage events %= 2h ticks scoreboard players operation chatMessage events %= 2h ticks
execute if score chatMessage events matches 0 if score chatMessage intervals matches 1.. run say Technoblade never dies! execute if score chatMessage events matches 0 if score chatMessage intervals matches 1.. run say 技术之刃永世长存!
execute if score chatMessage events matches 0 if score chatMessage intervals matches 1.. run scoreboard players remove chatMessage intervals 1 execute if score chatMessage events matches 0 if score chatMessage intervals matches 1.. run scoreboard players remove chatMessage intervals 1
#Speed Effect (every 30s) # 速度效果每30秒
scoreboard players operation speedEffect events %= 30s ticks scoreboard players operation speedEffect events %= 30s ticks
execute if score speedEffect events matches 0 if score speedEffect intervals matches 1.. run effect @a speed 10 2 true execute if score speedEffect events matches 0 if score speedEffect intervals matches 1.. run effect @a speed 10 2 true
execute if score speedEffect events matches 0 if score speedEffect intervals matches 1.. run scoreboard players remove speedEffect intervals 1 execute if score speedEffect events matches 0 if score speedEffect intervals matches 1.. run scoreboard players remove speedEffect intervals 1
``` ```
![commandBlockChain8](/assets/images/commands/commandBlockChain/8.png) :::
## Executing Commands During Timeframe ## 时段内持续执行
To run commands during the timeframe between intervals for a particular system you may do something like this: 若需要在计时过程中持续执行指令(而不仅是在触发时刻):
<CodeHeader>mcfunction</CodeHeader> ::: code-group
```yaml [持续效果.mcfunction]
```yaml # 速度效果每30秒 + 持续粒子效果
#Speed Effect (every 30s) + Particle (every tick)
scoreboard players operation speedEffect events %= 30s ticks scoreboard players operation speedEffect events %= 30s ticks
execute if score speedEffect intervals matches 1.. as @a at @s run particle minecraft:shulker_bullet ~~~ execute if score speedEffect intervals matches 1.. as @a at @s run particle minecraft:shulker_bullet ~~~
execute if score speedEffect events matches 0 if score speedEffect intervals matches 1.. run effect @a speed 10 2 true execute if score speedEffect events matches 0 if score speedEffect intervals matches 1.. run effect @a speed 10 2 true
execute if score speedEffect events matches 0 if score speedEffect intervals matches 1.. run scoreboard players remove speedEffect intervals 1 execute if score speedEffect events matches 0 if score speedEffect intervals matches 1.. run scoreboard players remove speedEffect intervals 1
``` ```
As shown in line 3; to run commands while the timer is running, all you need to do is remove the "if score" testing if the interval has been reached. And instead, only test if *any* interval is left, to run our commands. :::
Let's say we had set the intervals for this event to 10, then that means players would also have particle trails for 300 seconds since `10*30s=300s` 如设置触发次数为10次粒子效果将持续300秒10 × 30秒
## Entity Timers ## 实体独立计时器
In some cases such as an entity despawn event you will need to run timers for each entity individually rather than a synchronised timer which could cause the event to trigger too soon. In such cases an Async Timer can be helpful. 对于需要单独计时的实体(如定时消失),可使用异步计时系统:
::: code-group
Let's say we want to: ```yaml [实体计时器.mcfunction]
- kill all entities named "station" 5 minutes after they've been summoned. # 计时核心
- play a shulker particle around them during that timeframe.
- play a flame particle around them in the first 10 seconds.
- play a pling sound to nearby players when the timer reaches half way.
- stop the timer if a passive mob is nearby.
- loop the timer if a hostile mob is nearby.
<CodeHeader>mcfunction</CodeHeader>
```yaml
#Clock
scoreboard players add @e [name=station, scores={ticks=0..}] ticks 1 scoreboard players add @e [name=station, scores={ticks=0..}] ticks 1
#Executing Commands while timer is running # 持续粒子效果
execute as @e [name=station, scores={ticks=0..}] at @s run particle minecraft:shulker_bullet ~~~ execute as @e [name=station, scores={ticks=0..}] at @s run particle minecraft:shulker_bullet ~~~
#Executing commands within a timeframe # 前10秒火焰粒子
execute as @e [name=station, scores={ticks=0..200}] at @s run particle minecraft:basic_flame_particle ~~~ execute as @e [name=station, scores={ticks=0..200}] at @s run particle minecraft:basic_flame_particle ~~~
#Executing commands at specific intervals # 中途提示音效
execute as @e [name=station, scores={ticks=3600}] at @s run playsound note.pling @a [r=10] execute as @e [name=station, scores={ticks=3600}] at @s run playsound note.pling @a [r=10]
#Stopping the timer # 暂停计时条件
execute as @e [name=station] at @s if entity @e [family=pacified, r=10, c=1] run scoreboard players set @s ticks -1 execute as @e [name=station] at @s if entity @e [family=pacified, r=10, c=1] run scoreboard players set @s ticks -1
#Looping the timer # 循环计时条件
execute as @e [name=station, scores={ticks=6000}] at @s if entity @e [family=monster, r=10, c=1] run scoreboard players set @s ticks 0 execute as @e [name=station, scores={ticks=6000}] at @s if entity @e [family=monster, r=10, c=1] run scoreboard players set @s ticks 0
#End # 最终执行
kill @e [name=station, scores={ticks=6000}] kill @e [name=station, scores={ticks=6000}]
``` ```
![commandBlockChain7](/assets/images/commands/commandBlockChain/7.png) :::
As shown; setting the score to 0 when it completes the timeframe will loop the timer and setting the score to -1 will stop/disable it. You can still set the score to 0 to start the timer again. ![实体计时器示意图](/assets/images/commands/commandBlockChain/7.png)
通过将分数设为0可实现循环计时设为-1可停止计时。实体将在6000刻5分钟后被清除。

View File

@@ -1,6 +1,6 @@
--- ---
title: Understanding Selectors title: 选择器详解
category: General category: 基础
mentions: mentions:
- Science-geek42 - Science-geek42
- Brougud - Brougud
@@ -10,208 +10,286 @@ mentions:
- Hatchibombotar - Hatchibombotar
--- ---
Target selectors are used in commands to target who you want to execute a command on without explicitly setting a target, such as a player's name. A target selector is comprised of a selector variable, and optionally a list of selector arguments. # 选择器详解
## Selector Variables <!--@include: @/wiki/bedrock-wiki-mirror.md-->
The selector variable defines the broad list of entities to select. There are six selector variables to choose from: 目标选择器用于在命令中动态指定执行对象,无需明确设置目标(例如玩家名称)。选择器由选择器变量和可选的选择器参数组成。
- `@a` - Target all players
- `@p` - Target the nearest player
- `@r` - Target a random player
- `@e` - Target all entities
- `@s` - Target the executor
- `@initiator` - Target the player interacting with an NPC
## Selector Arguments ## 选择器变量
Selector arguments can narrow down a list of target candidates to those who meet certain conditions. In order to use selector arguments, you must first have a selector variable. To start with selector arguments you must add square brackets `[]` to the end of the chosen target selector like this: `kill @e[]`. Multiple selector arguments can be used by separating them with commas. 选择器变量定义了基本的实体筛选范围。共有六种选择器变量可选:
- `@a` - 选择所有玩家
- `@p` - 选择最近的玩家
- `@r` - 随机选择玩家
- `@e` - 选择所有实体
- `@s` - 选择命令执行者自身
- `@initiator` - 选择与NPC交互的玩家
### Type ## 选择器参数
Limits the selection of targets by their identifier. Negating the argument selects entities without that identifier. This argument cannot be repeated unless negated, since a given entity can only have one identifier. This argument can be used with the selector `@r` to select entities randomly.
- `type=<identifier>`—Include only entities with the given identifier. 选择器参数可进一步缩小候选目标范围。使用参数时需先指定选择器变量,并在其后添加方括号`[]`,例如:`kill @e[]`。多个参数之间用逗号分隔。
- `type=!<identifier>`—Exclude any entities with the given identifier.
Examples: ### Type类型
根据实体标识符筛选目标。否定参数将排除指定类型的实体。由于每个实体只能有一个标识符,除非使用否定参数,否则该参数不可重复。可与`@r`选择器配合进行随机筛选。
Affect all pigs with levitation: - `type=<标识符>`——仅包含指定类型的实体
- `/effect @e[type=pig] levitation` - `type=!<标识符>`——排除指定类型的实体
Kill all entities that are not arrows and snowballs: 示例:
- `/kill @e[type=!arrow,type=!snowball]`
### Count 对所有猪施加漂浮效果:
Limits the number of selected entities, following selector sorting rules. ::: code-group
```json [pig]
/effect @e[type=pig] levitation
```
The selectors `@a`, `@p`, and `@e` sort by increasing distance, while `@r` sorts randomly. For the variables `@p` and `@r`, this argument defaults to 1. Negating this argument reverses the sorting order; random sorting cannot be negated. 清除所有非箭矢和非雪球的实体:
```json [non-arrow/snowball]
/kill @e[type=!arrow,type=!snowball]
```
:::
- `c=<count>`—Select up to `<count>` entities. ### Count数量
根据排序规则限制选中实体数量。
Examples: `@a`、`@p`和`@e`按距离升序排列,`@r`随机排列。`@p`和`@r`默认值为1。否定参数将反转排序方向随机排序不可否定
Clear stone from the closest five players: - `c=<数量>`——选择最多`<数量>`个实体
- `/clear @a[c=5] stone`
Damage the furthest two skeletons: 示例:
- `/damage @e[type=skeleton,c=-2] 2`
### Position 清除最近五名玩家背包中的石头:
Changes the position a selector starts its search at. It also modifies where the distance and volume arguments are positioned. Leaving any undefined defaults to the command's current position. ::: code-group
```json [5 players]
/clear @a[c=5] stone
```
[Relative coordinates](/commands/relative-coordinates#relative-coordinates) can be used to define a relative offset from the command's position. 对最远的两只骷髅造成伤害:
```json [skeletons]
/damage @e[type=skeleton,c=-2] 2
```
:::
- `x=<value>`, `y=<value>`, and `z=<value>`—Defines a position for the target selector. ### Position位置
设定选择器的搜索起点,同时影响距离和体积参数的判定基准。未定义时默认使用命令执行位置。
Examples: 可使用[相对坐标](/wiki/commands/relative-coordinates#相对坐标)来设置偏移量。
Teleport the closest player to (140, 64, -200) ten blocks up: - `x=<值>`, `y=<值>`, `z=<值>`——定义选择器的基准坐标
- `/teleport @p[x=140, y=64, z=-200] ~ ~10 ~`
### Distance 示例:
Limits the selection of targets by their spherical distance from the selector. This selects entities by their feet.
- `rm=<value>` and `r=<value>`—Selects entities between the minimum and maximum number of blocks away, inclusive and respectively. 将(140,64,-200)处最近的玩家向上传送10格
::: code-group
```json [teleport]
/teleport @p[x=140, y=64, z=-200] ~ ~10 ~
```
:::
Examples: ### Distance距离
根据实体脚部的球面距离筛选目标。
Kill all chickens between two and six blocks away: - `rm=<值>`和`r=<值>`——分别设置最小和最大距离(包含边界值)
- `/kill @e[type=chicken, rm=2, r=6]`
Enchant the held item with Sharpness for all players within one block of (0, 100, 0): 示例:
- `/enchant @a[x=0, y=100, z=0, r=1] sharpness`
### Volume 清除2到6格范围内的所有鸡
Limits the selection of targets to those inside of a cuboid volume aligned to the block grid. There are three arguments, each determining the size of the box along their respective axes. If at least one argument is defined, any remaining arguments left undefined are assumed to be 0. This selects entities by their feet. ::: code-group
```json [chicken]
/kill @e[type=chicken, rm=2, r=6]
```
The general formula for calculating the volume between two positions can be viewed as: `dx = x2 - x1; dy = y2 - y1; dz = z2 - z1`. 在(0,100,0)1格范围内所有玩家的手持物品附魔锋利
```json [enchant]
/enchant @a[x=0, y=100, z=0, r=1] sharpness
```
:::
- `dx=<value>`, `dy=<value>`, and `dz=<value>`—Selects entities inside the given bounding box. ### Volume体积
筛选位于方块坐标系对齐的立方体内的实体。三个参数分别定义各轴长度未定义参数默认为0。以实体脚部为判定点。
Examples: 体积计算公式:`dx = x2 - x1; dy = y2 - y1; dz = z2 - z1`
List all entities within a 12x30x2 box: - `dx=<值>`, `dy=<值>`, `dz=<值>`——定义立方体区域
- `/say @e[dx=12, dz=30, dy=2]`
Add the "lobby" tag to all players between (-400, 0, -350) and (-150, 256, 50): 示例:
- `/tag @a[x=-400, y=0, z=-350, dx=250, dy=256, dz=400] add lobby`
### Scores 列出12x30x2区域内的所有实体
Limits the selection of targets by their score value. This argument is represented as an object, with key-value pairs for a scoreboard objective and a value. The value can represent a range of numbers, using the range syntax. The value of a score can be negated to test if the entity does not have a score value within that range. ::: code-group
```json [say]
/say @e[dx=12, dz=30, dy=2]
```
- `scores={<objective>=<value>}`—Selects entities whose score under the given objective matches the given value. 为(-400,0,-350)到(-150,256,50)区域内的玩家添加"lobby"标签:
```json [tag]
/tag @a[x=-400, y=0, z=-350, dx=250, dy=256, dz=400] add lobby
```
:::
The range syntax works as follows: ### Scores计分板
- `N..` is any number greater than or equal to N. 根据计分板分数筛选目标。参数格式为对象,包含计分项与数值的键值对。数值可使用范围语法。否定参数将排除分数范围内的实体。
- `..N` is any number less than or equal to N.
- `N..M` is any number between N and M, inclusive.
Examples: - `scores={<计分项>=<数值>}`——筛选符合分数条件的实体
Set the "points" score for all players with a "points" score of ten to 0: 范围语法说明:
- `/scoreboard players set @p[scores={points=10}] points 0` - `N..`大于等于N的数值
- `..N`小于等于N的数值
- `N..M`介于N到M之间的数值包含边界
Add the "start" tag to armor stands with both a "started" score of one, and a "timer" score of 20 or less: 示例:
- `/tag @e[type=armor_stand, scores={started=1, timer=..20}] add start`
### Name 将"points"分数为10的玩家分数重置为0
Limits the selection of targets by name. Negating the argument selects entities whose name does not match. ::: code-group
```json [points]
/scoreboard players set @p[scores={points=10}] points 0
```
- `name=<name>`—Include only entities with the given name. 为同时满足"started=1"且"timer≤20"的盔甲架添加"start"标签:
- `name=!<name>`—Exclude any entities with the given name. ```json [armor_stand]
/tag @e[type=armor_stand, scores={started=1, timer=..20}] add start
```
:::
Examples: ### Name名称
根据实体名称筛选目标。否定参数将排除指定名称的实体。
List all zombies named Shadow: - `name=<名称>`——仅包含指定名称的实体
- `/say @e[type=zombie, name=Shadow]` - `name=!<名称>`——排除指定名称的实体
Give one level to players both not named Steve and not named Alex: 示例:
- `/xp 1L @a[name=!Steve, name=!Alex]`
### Tag 列出所有名为Shadow的僵尸
Limits the selection of targets by their tags. This argument can be repeated to test for multiple tags, and all filters must pass for an entity to be selected. Negating this argument selects entities without that tag. ::: code-group
```json [zombie]
/say @e[type=zombie, name=Shadow]
```
- `tag=<tag>`—Include only entities with the given tag. 给非Steve和非Alex的玩家提升1级
- `tag=!<tag>`—Exclude any entities with the given tag. ```json [xp]
/xp 1L @a[name=!Steve, name=!Alex]
```
:::
Examples: ### Tag标签
根据实体标签筛选目标。可重复使用多个标签参数,所有条件需同时满足。否定参数将排除具有指定标签的实体。
Kill all mobs with the tag "marked", and without the tag "exempt": - `tag=<标签>`——仅包含具有指定标签的实体
- `/kill @e[tag=marked, tag=!exempt]` - `tag=!<标签>`——排除具有指定标签的实体
### Family 示例:
Limits the selection of targets by type family. This argument can be repeated to test for multiple families, and all filters must pass for an entity to be selected. Negating this argument selects entities whose type family does not match.
- `family=<family>`—Include only entities with the given type family. 清除所有带"marked"标签且无"exempt"标签的生物:
- `family=!<family>`—Exclude any entities with the given type family. ::: code-group
```json [marked]
/kill @e[tag=marked, tag=!exempt]
```
:::
Examples: ### Family族群
根据实体族群类型筛选目标。可重复使用多个族群参数,所有条件需同时满足。否定参数将排除指定族群的实体。
Affect all entities in the "monster" family with Regeneration: - `family=<族群>`——仅包含指定族群的实体
- `/effect @e[family=monster] regeneration` - `family=!<族群>`——排除指定族群的实体
### Rotation 示例:
Limits the selection of targets by their rotation. There are two types of rotation: x-rotation, which is vertical rotation around the x-axis; and y-rotation, which is horizontal rotation around the y-axis. X-rotation ranges between -90 and 90 (180° total), going from looking up to down; and y-rotation ranges between -180 and 180 (360° total), starting and ending at North, wrapping around clockwise.
对"monster"族群的所有实体施加再生效果:
::: code-group
```json [monster]
/effect @e[family=monster] regeneration
```
:::
### Rotation旋转角度
根据实体视角筛选目标。分为垂直视角x轴旋转范围-90~90和水平视角y轴旋转范围-180~180
- `rxm=<value>` and `rx=<value>`—Selects entities whose x-rotation is between the minimum and maximum values, inclusive and respectively. - `rxm=<值>`和`rx=<值>`——垂直视角范围
- `rym=<value>` and `ry=<value>`—Selects entities whose y-rotation is between the minimum and maximum values, inclusive and respectively. - `rym=<值>`和`ry=<值>`——水平视角范围
Examples: 示例:
Affect all players looking at or above the horizon with Blindness for one second: 对仰角≥0度平视或俯视的玩家施加1秒失明
- `/effect @a[rx=0] blindness 1` (0 or less) ::: code-group
```json [blindness]
Damage all players facing generally south: /effect @a[rx=0] blindness 1
- `/damage @a[rym=-45, ry=45] 1` ```
### Level 对朝南方向(-45°~45°的玩家造成伤害
Limits the selection of targets by experience levels. Only players can have EXP, so this filters out non-player targets. ```json [damage]
/damage @a[rym=-45, ry=45] 1
- `lm=<amount>` and `l=<amount>`—Selects players whose EXP levels are between the minimum and maximum values specified, inclusive and respectively. ```
:::
Examples:
### Level经验等级
Give all players who have between three and eight levels a diamond: 根据玩家经验等级筛选目标(仅限玩家)。
- `/give @a[lm=3, l=8] diamond`
- `lm=<数值>`和`l=<数值>`——分别设置最低和最高等级(包含边界)
### Game mode
Limits the selection of targets by game mode. Only players can use game mode, so this filters out non-player targets. Negating the argument selects targets whose game mode does not match. 示例:
- `m=<gamemode>`—Selects players by their game mode. 给3-8级的玩家发放钻石
::: code-group
Possible values include: ```json [diamond]
* `0`, `s`, or `survival` for Survival mode /give @a[lm=3, l=8] diamond
* `1`, `c`, or `creative` for Creative mode ```
* `2`, `a`, or `adventure` for Adventure mode :::
* `spectator` for Spectator mode
* `d` or `default` for the default game mode ### Game mode游戏模式
根据游戏模式筛选玩家目标。否定参数将排除指定模式的玩家。
Examples:
- `m=<模式>`——筛选指定游戏模式
List all players in Creative mode:
- `/say @a[m=creative]` 可用模式值:
* `0`、`s`或`survival`:生存模式
Set the game mode to Creative mode for players both not in Survival mode, and not in Adventure mode: * `1`、`c`或`creative`:创造模式
- `/gamemode creative @a[m=!survival, m=!adventure]` * `2`、`a`或`adventure`:冒险模式
* `spectator`:旁观模式
### Items * `d`或`default`:默认模式
Limits the selection of targets by what items they have in their inventory. This argument is represented as an object, or an array of objects, with up to one each of the following parameters:
示例:
- `item=<string>`—The identifier of the item to test for, and the only required argument. This can accept custom identifiers too.
- `quantity=<int>`—The amount of the item to test for. Accepts a [range](/commands/selectors#scores) for a value. This argument can also be negated. 列出所有创造模式玩家:
- `data=<int>`—The data value of the item to test for. Defaults to -1. **Currently not functional:** [MCPE-151920](https://bugs.mojang.com/browse/MCPE-151920) ::: code-group
- `location=<string>`—The slot the item should be located in. Accepts the same arguments as the slotType argument in the `/replaceitem` command. ```json [creative]
- `slot=<int>`—The index of the slot used in the "location" argument, and can only be used with "location". Accepts a range for a value. This argument can be negated. /say @a[m=creative]
```
Examples:
将非生存和非冒险模式的玩家设为创造模式:
Checks for players who have a netherite sword in their inventory: ```json [gamemode]
- `/testfor @a[hasitem={item=netherite_sword}]` /gamemode creative @a[m=!survival, m=!adventure]
```
Clears 2 apples for players that have four or more apples: :::
- `/clear @a[hasitem={item=apple,quantity=4..}] apple 2`
### Items物品
Checks for players who have two sticks and two diamonds: 根据物品栏内容筛选目标。参数格式为对象或对象数组,支持以下参数:
- `/testfor @a[hasitem=[{item=diamond,quantity=2},{item=stick,quantity=2}]]`
- `item=<字符串>`——物品标识符(必填)
Checks for players who doesn't have a stick: - `quantity=<整数>`——物品数量(支持范围语法,可否定)
- `/testfor @a[hasitem=[{item=stick,quantity=0}]` - `data=<整数>`——物品数据值(默认-1**当前不可用**[MCPE-151920](https://bugs.mojang.com/browse/MCPE-151920))
- `location=<字符串>`——物品所在栏位(与`/replaceitem`的slotType参数一致
- `slot=<整数>`——栏位索引需配合location使用支持范围语法可否定
示例:
检测携带下界合金剑的玩家:
::: code-group
```json [netherite_sword]
/testfor @a[hasitem={item=netherite_sword}]
```
清除拥有≥4个苹果的玩家2个苹果
```json [apple]
/clear @a[hasitem={item=apple,quantity=4..}] apple 2
```
检测携带2钻石+2木棍的玩家
```json [multiple]
/testfor @a[hasitem=[{item=diamond,quantity=2},{item=stick,quantity=2}]]
```
检测未携带木棍的玩家:
```json [negation]
/testfor @a[hasitem=[{item=stick,quantity=0}]
```
:::

View File

@@ -1,6 +1,6 @@
--- ---
title: Tellraw title: tellraw命令
category: Commands category: 命令
mentions: mentions:
- SirLich - SirLich
- Dreamedc2015 - Dreamedc2015
@@ -13,120 +13,110 @@ mentions:
- SmokeyStack - SmokeyStack
--- ---
tellraw sends a JSON message to selected or all players being useful for sending plain messages to players ingame # tellraw命令
**The titleraw command follows the same theme** <!--@include: @/wiki/bedrock-wiki-mirror.md-->
`tellraw` 用于向指定或所有玩家发送JSON格式消息适用于在游戏中向玩家发送纯文本信息
**titleraw命令遵循相同的设计理念**
![](/assets/images/documentation/tellrawshow.png) ![](/assets/images/documentation/tellrawshow.png)
## 格式规范
## Format `tellraw`命令的基础语法结构如下:
this is how the tell raw command is formatted
``` ```
tellraw <target: target> <raw json message: json> tellraw <目标: 目标> <原始JSON消息: json>
``` ```
- ` <target: target>`: The target is expressed as a playername or player groups such as `@a` `@r` `@s` `@p` - ` <目标: 目标>`: 目标可以表示为玩家名称或玩家组,例如`@a` `@r` `@s` `@p`
- `<raw json message: json>`: This is a json schema that tells how the message is structured or constructed. expressed with for example: - `<原始JSON消息: json>`: 用于定义消息结构的JSON格式例如
`{"rawtext":[{"text":""}]}` `{"rawtext":[{"text":""}]}`
## 基础示例
## Examples 发送引号内的文字内容
This sends the words in the last set of quotes ::: code-group
```json [命令]
<CodeHeader></CodeHeader>
```json
/tellraw @a {"rawtext":[{"text":"Hello"}]} /tellraw @a {"rawtext":[{"text":"Hello"}]}
``` ```
:::
## 转义字符处理
## Escaping Characters 在消息中使用引号时,需在引号左侧添加反斜杠进行转义
To use quotations in a tellraw message place a backslash to the left side of the quotation mark. ::: code-group
```json [命令]
<CodeHeader></CodeHeader>
```json
/tellraw @a {"rawtext":[{"text":"Quote me: \"I am here\"."}]} /tellraw @a {"rawtext":[{"text":"Quote me: \"I am here\"."}]}
``` ```
:::
## 换行处理
## Line breaks 使用`\n`实现文本换行
To insert a line break use `\n` ::: code-group
```json [命令]
<CodeHeader></CodeHeader>
```json
/tellraw @a { "rawtext": [ { "text":"I am line one\nI am line two" } ] } /tellraw @a { "rawtext": [ { "text":"I am line one\nI am line two" } ] }
``` ```
:::
## 显示实体/玩家信息
## Displaying entities / player 通过选择器显示实体名称的用法示例
You can use the following to use selector to display names. ::: code-group
```json [命令]
<CodeHeader></CodeHeader>
```json
/tellraw @a {"rawtext": [{"text": "§6The winner is: §a"}, {"selector": "@a[r=5,c=1]"}]} /tellraw @a {"rawtext": [{"text": "§6The winner is: §a"}, {"selector": "@a[r=5,c=1]"}]}
``` ```
:::
## 显示计分板数值
## Displaying scores 显示玩家计分板数值的复合用法
You can use the following to use selector to display names. ::: code-group
```json [命令]
<CodeHeader></CodeHeader>
```json
/tellraw @a {"rawtext": [{"text": "§6The winner is: §a"}, {"selector": "@a[r=5,c=1]"}, {"text": "§6With a score of: "}, {"score":{"name": "@s","objective": "value"}}]} /tellraw @a {"rawtext": [{"text": "§6The winner is: §a"}, {"selector": "@a[r=5,c=1]"}, {"text": "§6With a score of: "}, {"score":{"name": "@s","objective": "value"}}]}
``` ```
:::
## 多语言文本翻译
## Translate text 使用translate组件配合[翻译键](/wiki/concepts/text-and-translations)实现多语言支持。注意需在对应语言的.lang文件中配置翻译内容
To have a language dependant text you can use the translate component and [translation keys](/concepts/text-and-translations). please note you will need relevant information in each of the desired .lang files for this to work. ::: code-group
```json [RP/texts/en_US.lang]
<CodeHeader>RP/texts/en_US.lang</CodeHeader>
```
example.langcode.1=I am line one example.langcode.1=I am line one
``` ```
<CodeHeader>RP/texts/de_DE.lang</CodeHeader> ```json [RP/texts/de_DE.lang]
```
example.langcode.1=Ich bin Zeile eins example.langcode.1=Ich bin Zeile eins
``` ```
:::
对应命令:
The command: ::: code-group
```json [命令]
<CodeHeader></CodeHeader>
```json
/tellraw @a { "rawtext": [ { "translate": "example.langcode.1" } ] } /tellraw @a { "rawtext": [ { "translate": "example.langcode.1" } ] }
``` ```
:::
## 复合型翻译模板
## Translate text with selectors/scores 多语言文件配置:
language files: ::: code-group
```json [示例]
<CodeHeader></CodeHeader>
```
example.langcode.2=The winner is: %s. With a score of %s example.langcode.2=The winner is: %s. With a score of %s
``` ```
<CodeHeader></CodeHeader> ```json [命令]
```json
/tellraw @a {"rawtext":[{"translate":"example.langcode.2","with":{"rawtext":[{"selector":"@a[r=5,c=1]"},{"text":"§6With a score of: "},{"score":{"name":"@s","objective":"value"}}]}}]} /tellraw @a {"rawtext":[{"translate":"example.langcode.2","with":{"rawtext":[{"selector":"@a[r=5,c=1]"},{"text":"§6With a score of: "},{"score":{"name":"@s","objective":"value"}}]}}]}
``` ```
:::

View File

@@ -10,18 +10,20 @@ mentions:
- TheItsNameless - TheItsNameless
--- ---
`contents.json` is a file that is _probably_ used for the game to process the pack files more easily. It is _probably_ intended for marketplace content creators and Mojang, it is not required to have this file in the pack for the pack to work properly. # contents.json
You will find there some instructions about the usage of this file. <!--@include: @/wiki/bedrock-wiki-mirror.md-->
## Structure of the file `contents.json` 是游戏用于更高效处理资源包文件的配置文件。该文件 _可能_ 主要为市场内容创作者和 Mojang 设计,资源包即使不包含此文件仍可正常运行。
`contents.json` is located at the root of the add-on directory. It contains a list of the files that are included in the pack. 以下是关于该文件使用方式的说明。
Example:
<CodeHeader>RP/contents.json</CodeHeader> ## 文件结构
```json `contents.json` 位于附加包目录的根路径,包含资源包内所有文件的路径列表。示例:
::: code-group
```json [RP/contents.json]
{ {
"content": [ "content": [
{ {
@@ -51,6 +53,7 @@ Example:
] ]
} }
``` ```
:::
<FolderView <FolderView
:paths="[ :paths="[
@@ -65,20 +68,24 @@ Example:
]" ]"
> </FolderView> > </FolderView>
## Automatizing the process ## 自动化生成
The `contents.json` file can be generated automatically by the game itself, it is very recommended to decrease the risks of making mistakes. However, the file must be prepared first. Create a new empty file called `contents.json` in the root directory of your add-on, and add empty brackets. `contents.json` 可通过游戏自动生成,这种方式能有效减少手动配置错误。首先需要在附加包根目录创建空文件并添加空对象:
<CodeHeader>BP|RP/contents.json</CodeHeader> ::: code-group
```json [BP|RP/contents.json]
```json
{} {}
``` ```
:::
The file content will be automatically written next time the game is launched. 游戏会在下次启动时自动填充该文件内容。
## Additional information ## 补充说明
- The automatic process can be achieved no matter what is the location of the pack (Development folders or normal folders). - 自动生成功能适用于任意位置的资源包(开发文件夹或普通文件夹均可)
- Do not make multiple `contents.json` for subpacks, the file at the root of the pack is sufficient. - 不需要为子包单独创建多个 `contents.json`,根目录文件已足够
- This file is not required for the addon to work properly. - 该文件并非附加包运行的必要条件
<!-- 保留原始专有名词Tick、Component、Entity、Block、Item 等未翻译 -->
<!-- FolderView 组件保持原样以兼容 Vitepress 功能 -->
<!-- code-group 语法已正确替换原始 CodeHeader 组件 -->

View File

@@ -1,5 +1,5 @@
--- ---
title: Emojis & Symbols title: 表情符号与特殊字符
mentions: mentions:
- SirLich - SirLich
- Joelant05 - Joelant05
@@ -15,231 +15,232 @@ mentions:
- ThomasOrs - ThomasOrs
--- ---
# 表情符号与特殊字符
<!--@include: @/wiki/bedrock-wiki-mirror.md-->
:::warning :::warning
Modifying texture of vanilla emojis and symbols on this page are incompatible with Nintendo Switch platform! 修改本页所述原版表情符号的材质与任天堂Switch平台不兼容
::: :::
Minecraft has a bunch of hard-coded [Private Use Unicode symbols](https://en.wikipedia.org/wiki/Private_Use_Areas) that it automatically converts to Emoji-like symbols. Minecraft 内置了一系列硬编码的[Unicode私有区符号](https://zh.wikipedia.org/wiki/Unicode%E7%A7%81%E6%9C%89%E5%8C%BA),这些符号会被自动转换为表情符号样式。它们可以在任何支持普通文字的地方使用——告示牌、书与笔、物品名称、聊天框等。
These can be used anywhere where normal letters can - signs, books, item names, chat, etc.
Below you can find platform specific Emoji's, as well as general symbols. Copy/paste the "box" character under the Letter colum directly into Minecraft. 下方表格列出了平台专属表情符号和通用符号。直接将"字符"列下的方框字符复制/粘贴到Minecraft中使用。
There will be instructions for creating custom emoji at the bottom. 文档底部还提供了创建自定义表情符号的指南。
### HUD ### HUD界面
| Name | Letter (Copy/Paste This) | Unicode | Image | | 名称 | 字符(复制/粘贴此处) | Unicode | 图片 |
| ----------------- | ------------------------ | ------- | ------------------------------------------------- | | ----------------- | --------------------- | ------- | ------------------------------------------------ |
| Food |  | U+E100 | ![](/assets/images/concepts/emojis/hud/food.png) | | 饥饿值 |  | U+E100 | ![](/assets/images/concepts/emojis/hud/food.png) |
| Armor |  | U+E101 | ![](/assets/images/concepts/emojis/hud/armor.png) | | 护甲值 |  | U+E101 | ![](/assets/images/concepts/emojis/hud/armor.png) |
| Heart |  | U+E10C | ![](/assets/images/concepts/emojis/hud/heart.png) | | 生命值 |  | U+E10C | ![](/assets/images/concepts/emojis/hud/heart.png) |
### Items & Blocks ### 物品与方块
| Name | Letter (Copy/Paste This) | Unicode | Image | | 名称 | 字符(复制/粘贴此处) | Unicode | 图片 |
| -------------- | ------------------------ | ------- | ------------------------------------------------------------ | | -------------- | --------------------- | ------- | ----------------------------------------------------------- |
| Wooden Pickaxe |  | U+E108 | ![](/assets/images/concepts/emojis/items/wooden_pickaxe.png) | | 木镐 |  | U+E108 | ![](/assets/images/concepts/emojis/items/wooden_pickaxe.png) |
| Wooden Sword |  | U+E109 | ![](/assets/images/concepts/emojis/items/wooden_sword.png) | | 木剑 |  | U+E109 | ![](/assets/images/concepts/emojis/items/wooden_sword.png) |
| Crafting Table |  | U+E10A | ![](/assets/images/concepts/emojis/items/crafting_table.png) | | 工作台 |  | U+E10A | ![](/assets/images/concepts/emojis/items/crafting_table.png) |
| Furnace |  | U+E10B | ![](/assets/images/concepts/emojis/items/furnace.png) | | 熔炉 |  | U+E10B | ![](/assets/images/concepts/emojis/items/furnace.png) |
### Marketplace ### 市场
| Name | Letter (Copy/Paste This) | Unicode | Image | | 名称 | 字符(复制/粘贴此处) | Unicode | 图片 |
| ---------------- | ------------------------ | ------- | ------------------------------------------------------------ | | ---------------- | --------------------- | ------- | ----------------------------------------------------------- |
| Minecoin |  | U+E102 | ![](/assets/images/concepts/emojis/marketplace/minecoin.png) | | Minecoin |  | U+E102 | ![](/assets/images/concepts/emojis/marketplace/minecoin.png) |
| Token |  | U+E105 | ![](/assets/images/concepts/emojis/marketplace/token.png) | | 代币 |  | U+E105 | ![](/assets/images/concepts/emojis/marketplace/token.png) |
### Inventory ### 物品栏
| Name | Letter (Copy/Paste This) | Unicode | Image | | 名称 | 字符(复制/粘贴此处) | Unicode | 图片 |
| ---------------- | ------------------------ | ------- | ------------------------------------------------------------------ | | ---------------- | --------------------- | ------- | ----------------------------------------------------------------- |
| Craft Toggle On |  | U+E0A0 | ![](/assets/images/concepts/emojis/inventory/craft_toggle_on.png) | | 合成开关开启 |  | U+E0A0 | ![](/assets/images/concepts/emojis/inventory/craft_toggle_on.png) |
| Craft Toggle Off |  | U+E0A1 | ![](/assets/images/concepts/emojis/inventory/craft_toggle_off.png) | | 合成开关关闭 |  | U+E0A1 | ![](/assets/images/concepts/emojis/inventory/craft_toggle_off.png) |
### New Touch ### 新触控界面
| Name | Letter (Copy/Paste This) | Unicode | Image | | 名称 | 字符(复制/粘贴此处) | Unicode | 图片 |
| ----------------- | ------------------------ | ------- | ---------------------------------------------------------- | | ----------------- | --------------------- | ------- | --------------------------------------------------------- |
| Jump |  | U+E014 | ![](/assets/images/concepts/emojis/new_touch/jump.png) | | 跳跃 |  | U+E014 | ![](/assets/images/concepts/emojis/new_touch/jump.png) |
| Attack |  | U+E015 | ![](/assets/images/concepts/emojis/new_touch/attack.png) | | 攻击 |  | U+E015 | ![](/assets/images/concepts/emojis/new_touch/attack.png) |
| Joy Stick |  | U+E016 | ![](/assets/images/concepts/emojis/new_touch/joystick.png) | | 摇杆 |  | U+E016 | ![](/assets/images/concepts/emojis/new_touch/joystick.png) |
| Place |  | U+E018 | ![](/assets/images/concepts/emojis/new_touch/place.png) | | 放置 |  | U+E018 | ![](/assets/images/concepts/emojis/new_touch/place.png) |
| Sneak |  | U+E019 | ![](/assets/images/concepts/emojis/new_touch/sneak.png) | | 潜行 |  | U+E019 | ![](/assets/images/concepts/emojis/new_touch/sneak.png) |
| Sprint |  | U+E01A | ![](/assets/images/concepts/emojis/new_touch/sprint.png) | | 疾跑 |  | U+E01A | ![](/assets/images/concepts/emojis/new_touch/sprint.png) |
| Fly Up |  | U+E01B | ![](/assets/images/concepts/emojis/new_touch/fly_up.png) | | 上升 |  | U+E01B | ![](/assets/images/concepts/emojis/new_touch/fly_up.png) |
| Fly Down |  | U+E01C | ![](/assets/images/concepts/emojis/new_touch/fly_down.png) | | 下降 |  | U+E01C | ![](/assets/images/concepts/emojis/new_touch/fly_down.png) |
| Dismount |  | U+E01D | ![](/assets/images/concepts/emojis/new_touch/dismount.png) | | 下马 |  | U+E01D | ![](/assets/images/concepts/emojis/new_touch/dismount.png) |
### Touch ### 触控界面
| Name | Letter (Copy/Paste This) | Unicode | Image | | 名称 | 字符(复制/粘贴此处) | Unicode | 图片 |
| ----------------- | ------------------------ | ------- | ------------------------------------------------------------- | | ----------------- | --------------------- | ------- | ----------------------------------------------------------- |
| Jump |  | U+E084 | ![](/assets/images/concepts/emojis/touch/jump.png) | | 跳跃 |  | U+E084 | ![](/assets/images/concepts/emojis/touch/jump.png) |
| Crouch |  | U+E085 | ![](/assets/images/concepts/emojis/touch/crouch.png) | | 蹲下 |  | U+E085 | ![](/assets/images/concepts/emojis/touch/crouch.png) |
| Fly Up |  | U+E086 | ![](/assets/images/concepts/emojis/touch/fly_up.png) | | 上升 |  | U+E086 | ![](/assets/images/concepts/emojis/touch/fly_up.png) |
| Fly Down |  | U+E087 | ![](/assets/images/concepts/emojis/touch/fly_down.png) | | 下降 |  | U+E087 | ![](/assets/images/concepts/emojis/touch/fly_down.png) |
| Stop Flying |  | U+E088 | ![](/assets/images/concepts/emojis/touch/stop_flying.png) | | 停止飞行 |  | U+E088 | ![](/assets/images/concepts/emojis/touch/stop_flying.png) |
| Left Arrow |  | U+E081 | ![](/assets/images/concepts/emojis/touch/left_arrow.png) | | 左箭头 |  | U+E081 | ![](/assets/images/concepts/emojis/touch/left_arrow.png) |
| Right Arrow |  | U+E083 | ![](/assets/images/concepts/emojis/touch/right_arrow.png) | | 右箭头 |  | U+E083 | ![](/assets/images/concepts/emojis/touch/right_arrow.png) |
| Up Arrow |  | U+E080 | ![](/assets/images/concepts/emojis/touch/up_arrow.png) | | 上箭头 |  | U+E080 | ![](/assets/images/concepts/emojis/touch/up_arrow.png) |
| Down Arrow |  | U+E082 | ![](/assets/images/concepts/emojis/touch/down_arrow.png) | | 下箭头 |  | U+E082 | ![](/assets/images/concepts/emojis/touch/down_arrow.png) |
| Small Jump |  | U+E059 | ![](/assets/images/concepts/emojis/touch/smalljump.png) | | 小跳跃 |  | U+E059 | ![](/assets/images/concepts/emojis/touch/smalljump.png) |
| Small Crouch |  | U+E05A | ![](/assets/images/concepts/emojis/touch/smallcrouch.png) | | 小蹲下 |  | U+E05A | ![](/assets/images/concepts/emojis/touch/smallcrouch.png) |
| Small Fly Up |  | U+E05C | ![](/assets/images/concepts/emojis/touch/smallflyup.png) | | 小上升 |  | U+E05C | ![](/assets/images/concepts/emojis/touch/smallflyup.png) |
| Small Fly Down |  | U+E05D | ![](/assets/images/concepts/emojis/touch/smallflydown.png) | | 小下降 |  | U+E05D | ![](/assets/images/concepts/emojis/touch/smallflydown.png) |
| Small Left Arrow |  | U+E056 | ![](/assets/images/concepts/emojis/touch/smallleftarrow.png) | | 小左箭头 |  | U+E056 | ![](/assets/images/concepts/emojis/touch/smallleftarrow.png) |
| Small Right Arrow |  | U+E058 | ![](/assets/images/concepts/emojis/touch/smallrightarrow.png) | | 小右箭头 |  | U+E058 | ![](/assets/images/concepts/emojis/touch/smallrightarrow.png) |
| Small Up Arrow |  | U+E055 | ![](/assets/images/concepts/emojis/touch/smalluparrow.png) | | 小上箭头 |  | U+E055 | ![](/assets/images/concepts/emojis/touch/smalluparrow.png) |
| Small Down Arrow |  | U+E057 | ![](/assets/images/concepts/emojis/touch/smalldownarrow.png) | | 小下箭头 |  | U+E057 | ![](/assets/images/concepts/emojis/touch/smalldownarrow.png) |
| Small Inventory |  | U+E05B | ![](/assets/images/concepts/emojis/touch/smallinventory.png) | | 小物品栏 |  | U+E05B | ![](/assets/images/concepts/emojis/touch/smallinventory.png) |
### Keyboard & Mouse ### 键鼠操作
| Name | Letter (Copy/Paste This) | Unicode | Image | | 名称 | 字符(复制/粘贴此处) | Unicode | 图片 |
| ------------------ | ------------------------ | ------- | ------------------------------------------------------------------- | | ------------------ | --------------------- | ------- | ----------------------------------------------------------------- |
| Left Click |  | U+E060 | ![](/assets/images/concepts/emojis/keyboard/left_click.png) | | 左键点击 |  | U+E060 | ![](/assets/images/concepts/emojis/keyboard/left_click.png) |
| Right Click |  | U+E061 | ![](/assets/images/concepts/emojis/keyboard/right_click.png) | | 右键点击 |  | U+E061 | ![](/assets/images/concepts/emojis/keyboard/right_click.png) |
| Middle Click |  | U+E062 | ![](/assets/images/concepts/emojis/keyboard/middle_click.png) | | 中键点击 |  | U+E062 | ![](/assets/images/concepts/emojis/keyboard/middle_click.png) |
| Small Left Click |  | U+E070 | ![](/assets/images/concepts/emojis/keyboard/small_left_click.png) | | 小左键点击 |  | U+E070 | ![](/assets/images/concepts/emojis/keyboard/small_left_click.png) |
| Small Right Click |  | U+E071 | ![](/assets/images/concepts/emojis/keyboard/small_right_click.png) | | 小右键点击 |  | U+E071 | ![](/assets/images/concepts/emojis/keyboard/small_right_click.png) |
| Small Middle Click |  | U+E072 | ![](/assets/images/concepts/emojis/keyboard/small_middle_click.png) | | 小中键点击 |  | U+E072 | ![](/assets/images/concepts/emojis/keyboard/small_middle_click.png) |
| Small Mouse |  | U+E073 | ![](/assets/images/concepts/emojis/keyboard/small_mouse.png) | | 小鼠标图标 |  | U+E073 | ![](/assets/images/concepts/emojis/keyboard/small_mouse.png) |
### Xbox ### Xbox手柄
| Name | Letter (Copy/Paste This) | Unicode | Image | | 名称 | 字符(复制/粘贴此处) | Unicode | 图片 |
| ------------------ | ------------------------ | ------- | ---------------------------------------------------------- | | ------------------ | --------------------- | ------- | -------------------------------------------------------- |
| Y |  | U+E003 | ![](/assets/images/concepts/emojis/xbox/y_button.png) | | Y |  | U+E003 | ![](/assets/images/concepts/emojis/xbox/y_button.png) |
| B |  | U+E001 | ![](/assets/images/concepts/emojis/xbox/b_button.png) | | B |  | U+E001 | ![](/assets/images/concepts/emojis/xbox/b_button.png) |
| A |  | U+E000 | ![](/assets/images/concepts/emojis/xbox/a_button.png) | | A |  | U+E000 | ![](/assets/images/concepts/emojis/xbox/a_button.png) |
| X |  | U+E002 | ![](/assets/images/concepts/emojis/xbox/x_button.png) | | X |  | U+E002 | ![](/assets/images/concepts/emojis/xbox/x_button.png) |
| Back |  | U+E008 | ![](/assets/images/concepts/emojis/xbox/back.png) | | 返回键 |  | U+E008 | ![](/assets/images/concepts/emojis/xbox/back.png) |
| Start |  | U+E009 | ![](/assets/images/concepts/emojis/xbox/start.png) | | 开始键 |  | U+E009 | ![](/assets/images/concepts/emojis/xbox/start.png) |
| LB (Left Bumper) |  | U+E004 | ![](/assets/images/concepts/emojis/xbox/left_bumper.png) | | LB(左肩键) |  | U+E004 | ![](/assets/images/concepts/emojis/xbox/left_bumper.png) |
| RB (Right Bumper) |  | U+E005 | ![](/assets/images/concepts/emojis/xbox/right_bumper.png) | | RB(右肩键) |  | U+E005 | ![](/assets/images/concepts/emojis/xbox/right_bumper.png) |
| LT (Left Trigger) |  | U+E006 | ![](/assets/images/concepts/emojis/xbox/left_trigger.png) | | LT(左扳机键) |  | U+E006 | ![](/assets/images/concepts/emojis/xbox/left_trigger.png) |
| RT (Right Trigger) |  | U+E007 | ![](/assets/images/concepts/emojis/xbox/right_trigger.png) | | RT(右扳机键) |  | U+E007 | ![](/assets/images/concepts/emojis/xbox/right_trigger.png) |
| LS (Left Stick) |  | U+E00A | ![](/assets/images/concepts/emojis/xbox/left_stick.png) | | LS(左摇杆) |  | U+E00A | ![](/assets/images/concepts/emojis/xbox/left_stick.png) |
| RS (Right Stick) |  | U+E00B | ![](/assets/images/concepts/emojis/xbox/right_stick.png) | | RS(右摇杆) |  | U+E00B | ![](/assets/images/concepts/emojis/xbox/right_stick.png) |
| D-pad Up |  | U+E00C | ![](/assets/images/concepts/emojis/xbox/dpad_up.png) | | 方向键上 |  | U+E00C | ![](/assets/images/concepts/emojis/xbox/dpad_up.png) |
| D-pad Right |  | U+E00F | ![](/assets/images/concepts/emojis/xbox/dpad_right.png) | | 方向键右 |  | U+E00F | ![](/assets/images/concepts/emojis/xbox/dpad_right.png) |
| D-pad Down |  | U+E00E | ![](/assets/images/concepts/emojis/xbox/dpad_down.png) | | 方向键下 |  | U+E00E | ![](/assets/images/concepts/emojis/xbox/dpad_down.png) |
| D-pad Left |  | U+E00D | ![](/assets/images/concepts/emojis/xbox/dpad_left.png) | | 方向键左 |  | U+E00D | ![](/assets/images/concepts/emojis/xbox/dpad_left.png) |
### Nintendo Switch ### 任天堂Switch
| Name | Letter (Copy/Paste This) | Unicode | Image | | 名称 | 字符(复制/粘贴此处) | Unicode | 图片 |
| ------------------ | ------------------------ | ------- | ------------------------------------------------------------ | | ------------------ | --------------------- | ------- | ---------------------------------------------------------- |
| X |  | U+E042 | ![](/assets/images/concepts/emojis/switch/x_button.png) | | X |  | U+E042 | ![](/assets/images/concepts/emojis/switch/x_button.png) |
| A |  | U+E040 | ![](/assets/images/concepts/emojis/switch/a_button.png) | | A |  | U+E040 | ![](/assets/images/concepts/emojis/switch/a_button.png) |
| B |  | U+E041 | ![](/assets/images/concepts/emojis/switch/b_button.png) | | B |  | U+E041 | ![](/assets/images/concepts/emojis/switch/b_button.png) |
| Y |  | U+E043 | ![](/assets/images/concepts/emojis/switch/y_button.png) | | Y |  | U+E043 | ![](/assets/images/concepts/emojis/switch/y_button.png) |
| + |  | U+E049 | ![](/assets/images/concepts/emojis/switch/plus.png) | | + |  | U+E049 | ![](/assets/images/concepts/emojis/switch/plus.png) |
| - |  | U+E048 | ![](/assets/images/concepts/emojis/switch/minus.png) | | - |  | U+E048 | ![](/assets/images/concepts/emojis/switch/minus.png) |
| L (Left Bumper) |  | U+E044 | ![](/assets/images/concepts/emojis/switch/left_bumper.png) | | L(左肩键) |  | U+E044 | ![](/assets/images/concepts/emojis/switch/left_bumper.png) |
| R (Right Bumper) |  | U+E045 | ![](/assets/images/concepts/emojis/switch/right_bumper.png) | | R(右肩键) |  | U+E045 | ![](/assets/images/concepts/emojis/switch/right_bumper.png) |
| ZL (Left Trigger) |  | U+E046 | ![](/assets/images/concepts/emojis/switch/left_trigger.png) | | ZL(左扳机键) |  | U+E046 | ![](/assets/images/concepts/emojis/switch/left_trigger.png) |
| RL (Right Trigger) |  | U+E047 | ![](/assets/images/concepts/emojis/switch/right_trigger.png) | | RL(右扳机键) |  | U+E047 | ![](/assets/images/concepts/emojis/switch/right_trigger.png) |
| L (Left Stick) |  | U+E04A | ![](/assets/images/concepts/emojis/switch/left_stick.png) | | L(左摇杆) |  | U+E04A | ![](/assets/images/concepts/emojis/switch/left_stick.png) |
| R (Right Stick) |  | U+E04B | ![](/assets/images/concepts/emojis/switch/right_stick.png) | | R(右摇杆) |  | U+E04B | ![](/assets/images/concepts/emojis/switch/right_stick.png) |
| D-pad Up |  | U+E04C | ![](/assets/images/concepts/emojis/switch/dpad_up.png) | | 方向键上 |  | U+E04C | ![](/assets/images/concepts/emojis/switch/dpad_up.png) |
| D-pad Right |  | U+E04F | ![](/assets/images/concepts/emojis/switch/dpad_right.png) | | 方向键右 |  | U+E04F | ![](/assets/images/concepts/emojis/switch/dpad_right.png) |
| D-pad Down |  | U+E04E | ![](/assets/images/concepts/emojis/switch/dpad_down.png) | | 方向键下 |  | U+E04E | ![](/assets/images/concepts/emojis/switch/dpad_down.png) |
| D-pad Left |  | U+E04D | ![](/assets/images/concepts/emojis/switch/dpad_left.png) | | 方向键左 |  | U+E04D | ![](/assets/images/concepts/emojis/switch/dpad_left.png) |
### PlayStation (4/5) ### PlayStation (4/5)
| Name | Letter (Copy/Paste This) | Unicode | Image | | 名称 | 字符(复制/粘贴此处) | Unicode | 图片 |
| ------------------ | ------------------------ | ------- | ----------------------------------------------------------------- | | ------------------ | --------------------- | ------- | --------------------------------------------------------------- |
| Triangle |  | U+E023 | ![](/assets/images/concepts/emojis/playstation/triangle.png) | | 三角键 |  | U+E023 | ![](/assets/images/concepts/emojis/playstation/triangle.png) |
| Circle |  | U+E021 | ![](/assets/images/concepts/emojis/playstation/circle.png) | | 圆圈键 |  | U+E021 | ![](/assets/images/concepts/emojis/playstation/circle.png) |
| Cross |  | U+E020 | ![](/assets/images/concepts/emojis/playstation/cross.png) | | 叉键 |  | U+E020 | ![](/assets/images/concepts/emojis/playstation/cross.png) |
| Square |  | U+E022 | ![](/assets/images/concepts/emojis/playstation/square.png) | | 方框键 |  | U+E022 | ![](/assets/images/concepts/emojis/playstation/square.png) |
| Options/Share |  | U+E029 | ![](/assets/images/concepts/emojis/playstation/options_share.png) | | 选项/分享键 |  | U+E029 | ![](/assets/images/concepts/emojis/playstation/options_share.png) |
| Touch Pad |  | U+E028 | ![](/assets/images/concepts/emojis/playstation/touch_pad.png) | | 触摸板 |  | U+E028 | ![](/assets/images/concepts/emojis/playstation/touch_pad.png) |
| L1 (Left Bumper) |  | U+E024 | ![](/assets/images/concepts/emojis/playstation/left_bumper.png) | | L1(左肩键) |  | U+E024 | ![](/assets/images/concepts/emojis/playstation/left_bumper.png) |
| R1 (Right Bumper) |  | U+E025 | ![](/assets/images/concepts/emojis/playstation/right_bumper.png) | | R1(右肩键) |  | U+E025 | ![](/assets/images/concepts/emojis/playstation/right_bumper.png) |
| L2 (Left Trigger) |  | U+E026 | ![](/assets/images/concepts/emojis/playstation/left_trigger.png) | | L2(左扳机键) |  | U+E026 | ![](/assets/images/concepts/emojis/playstation/left_trigger.png) |
| R2 (Right Trigger) |  | U+E027 | ![](/assets/images/concepts/emojis/playstation/right_trigger.png) | | R2(右扳机键) |  | U+E027 | ![](/assets/images/concepts/emojis/playstation/right_trigger.png) |
| L3 (Left Stick) |  | U+E02A | ![](/assets/images/concepts/emojis/playstation/left_stick.png) | | L3(左摇杆) |  | U+E02A | ![](/assets/images/concepts/emojis/playstation/left_stick.png) |
| R3 (Right Stick) |  | U+E02B | ![](/assets/images/concepts/emojis/playstation/right_stick.png) | | R3(右摇杆) |  | U+E02B | ![](/assets/images/concepts/emojis/playstation/right_stick.png) |
| D-pad Up |  | U+E02C | ![](/assets/images/concepts/emojis/playstation/dpad_up.png) | | 方向键上 |  | U+E02C | ![](/assets/images/concepts/emojis/playstation/dpad_up.png) |
| D-pad Right |  | U+E02F | ![](/assets/images/concepts/emojis/playstation/dpad_right.png) | | 方向键右 |  | U+E02F | ![](/assets/images/concepts/emojis/playstation/dpad_right.png) |
| D-pad Down |  | U+E02E | ![](/assets/images/concepts/emojis/playstation/dpad_down.png) | | 方向键下 |  | U+E02E | ![](/assets/images/concepts/emojis/playstation/dpad_down.png) |
| D-pad Left |  | U+E02D | ![](/assets/images/concepts/emojis/playstation/dpad_left.png) | | 方向键左 |  | U+E02D | ![](/assets/images/concepts/emojis/playstation/dpad_left.png) |
### Oculus (Rift/Rift S) ### Oculus (Rift/Rift S)
| Name | Letter (Copy/Paste This) | Unicode | Image | | 名称 | 字符(复制/粘贴此处) | Unicode | 图片 |
| ------------------ | ------------------------ | ------- | ------------------------------------------------------------ | | ------------------ | --------------------- | ------- | ---------------------------------------------------------- |
| 0 |  | U+E0E0 | ![](/assets/images/concepts/emojis/oculus/0_button.png) | | 0 |  | U+E0E0 | ![](/assets/images/concepts/emojis/oculus/0_button.png) |
| B |  | U+E0E2 | ![](/assets/images/concepts/emojis/oculus/b_button.png) | | B |  | U+E0E2 | ![](/assets/images/concepts/emojis/oculus/b_button.png) |
| A |  | U+E0E1 | ![](/assets/images/concepts/emojis/oculus/a_button.png) | | A |  | U+E0E1 | ![](/assets/images/concepts/emojis/oculus/a_button.png) |
| Y |  | U+E0EA | ![](/assets/images/concepts/emojis/oculus/y_button.png) | | Y |  | U+E0EA | ![](/assets/images/concepts/emojis/oculus/y_button.png) |
| X |  | U+E0E9 | ![](/assets/images/concepts/emojis/oculus/x_button.png) | | X |  | U+E0E9 | ![](/assets/images/concepts/emojis/oculus/x_button.png) |
| LG (Left Grip) |  | U+E0E3 | ![](/assets/images/concepts/emojis/oculus/left_grip.png) | | LG(左握柄) |  | U+E0E3 | ![](/assets/images/concepts/emojis/oculus/left_grip.png) |
| RG (Right Grip) |  | U+E0E4 | ![](/assets/images/concepts/emojis/oculus/right_grip.png) | | RG(右握柄) |  | U+E0E4 | ![](/assets/images/concepts/emojis/oculus/right_grip.png) |
| LT (Left Trigger) |  | U+E0E7 | ![](/assets/images/concepts/emojis/oculus/left_trigger.png) | | LT(左扳机键) |  | U+E0E7 | ![](/assets/images/concepts/emojis/oculus/left_trigger.png) |
| RT (Right Trigger) |  | U+E0E8 | ![](/assets/images/concepts/emojis/oculus/right_trigger.png) | | RT(右扳机键) |  | U+E0E8 | ![](/assets/images/concepts/emojis/oculus/right_trigger.png) |
| LS (Left Stick) |  | U+E0E5 | ![](/assets/images/concepts/emojis/oculus/left_stick.png) | | LS(左摇杆) |  | U+E0E5 | ![](/assets/images/concepts/emojis/oculus/left_stick.png) |
| RS (Right Stick) |  | U+E0E6 | ![](/assets/images/concepts/emojis/oculus/right_stick.png) | | RS(右摇杆) |  | U+E0E6 | ![](/assets/images/concepts/emojis/oculus/right_stick.png) |
### Windows MR (Mixed Reality) ### Windows MR(混合现实)
| Name | Letter (Copy/Paste This) | Unicode | Image | | 名称 | 字符(复制/粘贴此处) | Unicode | 图片 |
| ------------------------- | ------------------------ | ------- | --------------------------------------------------------------------------- | | ------------------------- | --------------------- | ------- | ------------------------------------------------------------------------- |
| Menu |  | U+E0C2 | ![](/assets/images/concepts/emojis/windowsMR/menu.png) | | 菜单键 |  | U+E0C2 | ![](/assets/images/concepts/emojis/windowsMR/menu.png) |
| Windows |  | U+E0CD | ![](/assets/images/concepts/emojis/windowsMR/windows.png) | | Windows |  | U+E0CD | ![](/assets/images/concepts/emojis/windowsMR/windows.png) |
| Left Touchpad |  | U+E0C5 | ![](/assets/images/concepts/emojis/windowsMR/left_touchpad.png) | | 左触摸板 |  | U+E0C5 | ![](/assets/images/concepts/emojis/windowsMR/left_touchpad.png) |
| Left Horizontal Touchpad |  | U+E0C6 | ![](/assets/images/concepts/emojis/windowsMR/left_touchpad_horizontal.png) | | 左水平触摸板 |  | U+E0C6 | ![](/assets/images/concepts/emojis/windowsMR/left_touchpad_horizontal.png) |
| Left Vertical Touchpad |  | U+E0C7 | ![](/assets/images/concepts/emojis/windowsMR/left_touchpad_vertical.png) | | 左垂直触摸板 |  | U+E0C7 | ![](/assets/images/concepts/emojis/windowsMR/left_touchpad_vertical.png) |
| Right Touchpad |  | U+E0C8 | ![](/assets/images/concepts/emojis/windowsMR/right_touchpad.png) | | 右触摸板 |  | U+E0C8 | ![](/assets/images/concepts/emojis/windowsMR/right_touchpad.png) |
| Right Horizontal Touchpad |  | U+E0C9 | ![](/assets/images/concepts/emojis/windowsMR/right_touchpad_horizontal.png) | | 右水平触摸板 |  | U+E0C9 | ![](/assets/images/concepts/emojis/windowsMR/right_touchpad_horizontal.png) |
| Right Vertical Touchpad |  | U+E0CA | ![](/assets/images/concepts/emojis/windowsMR/right_touchpad_vertical.png) | | 右垂直触摸板 |  | U+E0CA | ![](/assets/images/concepts/emojis/windowsMR/right_touchpad_vertical.png) |
| LT (Left Trigger) |  | U+E0CB | ![](/assets/images/concepts/emojis/windowsMR/left_trigger.png) | | LT(左扳机键) |  | U+E0CB | ![](/assets/images/concepts/emojis/windowsMR/left_trigger.png) |
| RT (Right Trigger) |  | U+E0CC | ![](/assets/images/concepts/emojis/windowsMR/right_trigger.png) | | RT(右扳机键) |  | U+E0CC | ![](/assets/images/concepts/emojis/windowsMR/right_trigger.png) |
| LG (Left Grab) |  | U+E0C0 | ![](/assets/images/concepts/emojis/windowsMR/left_grab.png) | | LG(左抓握键) |  | U+E0C0 | ![](/assets/images/concepts/emojis/windowsMR/left_grab.png) |
| RG (Right Grab) |  | U+E0C1 | ![](/assets/images/concepts/emojis/windowsMR/right_grab.png) | | RG(右抓握键) |  | U+E0C1 | ![](/assets/images/concepts/emojis/windowsMR/right_grab.png) |
| LS (Left Stick) |  | U+E0C3 | ![](/assets/images/concepts/emojis/windowsMR/left_stick.png) | | LS(左摇杆) |  | U+E0C3 | ![](/assets/images/concepts/emojis/windowsMR/left_stick.png) |
| RS (Right Stick) |  | U+E0C4 | ![](/assets/images/concepts/emojis/windowsMR/right_stick.png) | | RS(右摇杆) |  | U+E0C4 | ![](/assets/images/concepts/emojis/windowsMR/right_stick.png) |
### Other ### 其他
| Name | Letter (Copy/Paste This) | Unicode | Image | | 名称 | 字符(复制/粘贴此处) | Unicode | 图片 |
| ---------------- | ------------------------ | ------- | -------------------------------------------------------------- | | ---------------- | --------------------- | ------- | ------------------------------------------------------------- |
| Crosshair |  | U+E017 | ![](/assets/images/concepts/emojis/other/crosshair.png) | | 准星 |  | U+E017 | ![](/assets/images/concepts/emojis/other/crosshair.png) |
| Agent |  | U+E103 | ![](/assets/images/concepts/emojis/other/agent.png) | | 助手 |  | U+E103 | ![](/assets/images/concepts/emojis/other/agent.png) |
| Immersive Reader |  | U+E104 | ![](/assets/images/concepts/emojis/other/immersive_reader.png) | | 沉浸式阅读器 |  | U+E104 | ![](/assets/images/concepts/emojis/other/immersive_reader.png) |
| Hollow Star |  | U+E106 | ![](/assets/images/concepts/emojis/other/hollow_star.png) | | 空心星 |  | U+E106 | ![](/assets/images/concepts/emojis/other/hollow_star.png) |
| Solid Star |  | U+E107 | ![](/assets/images/concepts/emojis/other/solid_star.png) | | 实心星 |  | U+E107 | ![](/assets/images/concepts/emojis/other/solid_star.png) |
## Custom Emoji ## 自定义表情符号
::: warning :::warning
This method is not officially supported. Use with caution on the Marketplace! 此方法并非官方支持功能。在市场中请谨慎使用!
::: :::
To make a custom emoji, we use a very similar method to the pre-built emoji, except instead of using the Microsoft sprite-sheets, we overwrite them with our own! Some _character-slots_ are already used up with the emoji above, but there are blank slots we can use. 要创建自定义表情符号,我们使用与原版表情符号类似的方法,不过需要用自己的材质覆盖微软的精灵图!虽然上文中部分字符位已被占用,但仍存在可用空白位。
Please note that the following files have been annotated with slot information: If you use them directly, existing Emoji will have numbers added on top of them. If you need the original sprite-sheets, you can get them from the Vanilla Resources on your system (not included in the Vanilla Resource Pack downloads). 请注意以下文件已添加槽位注释:如果直接使用这些文件,现有表情符号上会出现数字叠加。如需原始精灵图,请从系统内的原版资源中提取(原版资源包下载中不包含)。
To get started, you should download the sprite-sheets, and move them into the fonts folder. 首先需要下载精灵图文件,并将其移动到字体目录中:
Two sprite-sheets are provided for each glyph-target: One that accurately reflects vanilla, and a second version which has been annotated with hex information, for easily finding the correct character.
### RP/font/glyph_E0.png ### RP/font/glyph_E0.png
@@ -251,7 +252,7 @@ Two sprite-sheets are provided for each glyph-target: One that accurately reflec
![](/assets/images/concepts/emojis/custom/annotated/glyph_E1.png) ![](/assets/images/concepts/emojis/custom/annotated/glyph_E1.png)
![](/assets/images/concepts/emojis/custom/glyph_E1.png) ![](/assets/images/concepts/emojis/custom/glyph_E1.png)
Your filepath should look like this: 文件结构应如下所示:
<FolderView <FolderView
:paths="[ :paths="[
@@ -262,28 +263,28 @@ Your filepath should look like this:
]" ]"
></FolderView> ></FolderView>
### Finding the correct hex. ### 获取正确十六进制编码
Once you have emojis inside the `glyph_E0.png` or `glyph_E1.png` you need to find your character "code" so it can be converted. `glyph_E0.png``glyph_E1.png`中添加表情符号后,需要找到对应的字符"编码"以进行转换。
The first two characters are always `0x`. 前两位固定为`0x`
The next two characters are either `E0` or `E1`, depending on which file you added emojis to. 第三、四位根据文件选择`E0``E1`
The next two characters are the position inside the image like `<row><column>`, where each character is a number in hexadecimal numeral system. You can find this number by referencing the images above. For example, the top-right square in `E0` is `0F`, and the bottom right is `FF`. 最后两位表示图像中的行列位置(十六进制)。例如,`E0`的右上角方格为`0F`,右下角为`FF`
So after you are done, it might look like `0xE102` (`0x` + `E1` + `02`). 最终编码可能形如`0xE102``0x` + `E1` + `02`)。
Copy this code into the following field, and press <kbd>Convert</kbd>. The symbol on the right-hand side can be copy/pasted into MC. 将编码输入下方字段并点击<kbd>转换</kbd>按钮右侧生成的符号即可复制到MC中使用。
<div markdown="0"> <div markdown="0">
<form> <form>
<input id="hexValue" placeholder="Hex value" style="padding: 1em;margin: 0.5em;border-radius: 0.4rem; border: solid 1px rgb(38, 38, 38); outline: none;color: blue;"/> <input id="hexValue" placeholder="输入十六进制值" style="padding: 1em;margin: 0.5em;border-radius: 0.4rem; border: solid 1px rgb(38, 38, 38); outline: none;color: blue;"/>
<input id="result" placeholder="Result" readonly style="padding: 1em;margin: 0.5em;border-radius: 0.4rem; border: solid 1px rgb(38, 38, 38); outline: none;color: blue;"/> <input id="result" placeholder="转换结果" readonly style="padding: 1em;margin: 0.5em;border-radius: 0.4rem; border: solid 1px rgb(38, 38, 38); outline: none;color: blue;"/>
<a onclick="document.getElementById('result').value = String.fromCodePoint(parseInt(document.getElementById('hexValue').value, 16))" style="text-decoration: none; color: white; background: rgb(91, 33, 182); padding: 0.5em; border-radius: 0.4em; cursor: pointer;">Convert</a> <a onclick="document.getElementById('result').value = String.fromCodePoint(parseInt(document.getElementById('hexValue').value, 16))" style="text-decoration: none; color: white; background: rgb(91, 33, 182); padding: 0.5em; border-radius: 0.4em; cursor: pointer;">转换</a>
</form> </form>
</div> </div>
### Glyph Separation Space ### 字形间隔问题
Sometimes, it appears that if you put 2 glyphs near to each other, there will be a couple of empty pixels between them. The only fix for it is to scale the glyph itself. 当两个相邻符号间出现多余空白时,可通过缩放字形本身来解决。

View File

@@ -1,3 +1,3 @@
--- ---
title: Concepts title: 概念 Concepts
--- ---

View File

@@ -1,7 +1,7 @@
--- ---
title: Molang title: Molang
tags: tags:
- intermediate - 中级
mentions: mentions:
- yanasakana - yanasakana
- TheDoctor15 - TheDoctor15
@@ -11,37 +11,56 @@ mentions:
- TheItsNameless - TheItsNameless
--- ---
## Introduction # Molang
Pretty much everything evaluates to a number; if something doesn't evaluate to a number, you can use an `operator` to make it into one. You can basically just think of Molang as one big math equation.
An equation evaluates to `true` when any number except `0` is returned. When I reference `returning`, I'm talking about the output of an equation. There is also a `return` statement, but I don't usually use it, and will therefore not be talking about it. <!--@include: @/wiki/bedrock-wiki-mirror.md-->
## Accessing Values ## 简介
There are three main ways to access and use values in Molang (queries, variables and temp variables) 几乎所有的表达式都会求值为一个数字。如果某个表达式的结果不是数字,可以使用`operator`运算符将其转换为数字。你可以将Molang简单理解为一个大型数学方程式。
- **Queries** are read only values returned by the game. You cannot set these values, only read them. (`query.example_query` | `q.example_query`) 当方程式返回除`0`以外的任何数字时,都会被判定为`true`(真)。本文中提到的"返回"指的是方程式的输出结果。虽然存在`return`语句,但通常不推荐使用,因此不做详细讨论。
- **Variables** are read and write values that you can manipulate, these can be set and read through Molang. (`variable.example_variable` | `v.example_variable`) ## 值访问方式
- There are also hard-coded variables which act practically the same way as queries, but can only be used in certain situations. 在Molang中主要有三种访问值的方式查询语句、变量和临时变量
- **Temp. Variables** are practically the same as variables, except they only exist in the current scope. (`temp.example_temp` | `t.example_temp`) - **查询语句** 是从游戏获取的只读值,不可修改只能读取(语法:`query.example_query` 或简写为 `q.example_query`
- A "scope" can refer to the current `for_each` or `loop` *or* just the current expression, if it's not used within either
## Handling values - **变量** 是可读写的值可以通过Molang进行修改语法`variable.example_variable` 或简写为 `v.example_variable`
- 部分硬编码变量的行为与查询语句类似,但仅在特定情境下可用
- **Logical Operators** can be used to convert non-numbers into 1s or 0s. These include: `==`, `!=`, `<`, `>`, `<=`, `>=`. - **临时变量** 的功能与普通变量相同,但仅在当前作用域内有效(语法:`temp.example_temp` 或简写为 `t.example_temp`
- Example.) "`q.get_equipped_item_name == 'stick'`" Will evaluate to `1`/`true` when holding a stick - "作用域"指当前的`for_each`循环、`loop`循环,若未在循环中使用则指当前表达式
- There is also a *second* set of *Logical Operators* which can be used to 'group' values into `and/or` statements, often used in cases where you need *multiple* things to evaluate to `true` or just *one out of many*. `&&` represents an `and` statement, and `||` represents an `or` statement. ## 值处理
- Example.) "`q.is_sneaking && q.is_using_item`" Will evaluate to `1`/`true` when sneaking *and* using an item
- Example.) "`q.is_sneaking || q.is_jumping`" // Evaluates to `1`/`true` when either jumping *or* sneaking
- **Parentheses**, `( )`, are also a major help when grouping values or performing math operations. - **逻辑运算符** 可以将非数字值转换为1或0包括`==`, `!=`, `<`, `>`, `<=`, `>=`
- Example.) "`q.is_sneaking && (q.get_equipped_item_name == "stick" || q.get_equipped_item_name == "diamond")`" Will evaluate to `1`/`true` when sneaking *and* holding either a stick *or* a diamond - 示例:`q.get_equipped_item_name == 'stick'` 当手持木棍时求值为`1`/`true`
- **Conditional Operators** can be used as `if/else` statements. - **复合逻辑运算符** 用于构建"与/或"逻辑关系:
- A *binary* conditional operator refers to just using `?`. When this is used, it'll output your value or `0` depending on whether the given input value is `true`. - `&&` 表示"与"`||` 表示"或"
- Example.) "`q.is_sneaking ? 5`" Will output a `5` when sneaking, otherwise returning a `0` - 示例:`q.is_sneaking && q.is_using_item` 潜行且使用物品时返回`1`/`true`
- A *trinary* conditional operator refers to using `?` and `:`. When this is used, it'll output one of the two given values depending on whether your given input value is `true`. - 示例:`q.is_sneaking || q.is_jumping` 潜行或跳跃时返回`1`/`true`
- Example.) "`q.is_sneaking ? 10 : 3`" Will output a `10` when sneaking, otherwise returning a `3`
- **圆括号** `( )` 在组合值或进行数学运算时非常实用
- 示例:`q.is_sneaking && (q.get_equipped_item_name == "stick" || q.get_equipped_item_name == "diamond")` 潜行时手持木棍或钻石返回`1`/`true`
- **条件运算符** 可实现类似`if/else`的逻辑:
- **二元条件运算符** `?` 根据输入值返回指定值或0
- 示例:`q.is_sneaking ? 5` 潜行时返回`5`,否则返回`0`
- **三元条件运算符** `? :` 根据条件返回两个指定值之一
- 示例:`q.is_sneaking ? 10 : 3` 潜行时返回`10`,否则返回`3`
::: code-group
```json [示例]
{
"format_version": "1.16.100",
"minecraft:entity": {
"components": {
"minecraft:movement": {
"value": "q.is_jumping ? 0.1 : 0.05" // 跳跃时移动速度变为0.1否则0.05
}
}
}
}
```
:::

View File

@@ -1,51 +1,48 @@
--- ---
title: Namespaces title: 命名空间
mentions: mentions:
- SirLich - SirLich
- MedicalJewel105 - MedicalJewel105
--- ---
Namespaces are identifiers that mark content ownership. You can think of them as folders. Namespaces are helpful because they keep naming conflicts from happening. # 命名空间
Namespaces in addon creation can essentially be thought of as "the part to the left of the colon". For example, `minecraft` is the namespace of `minecraft:zombie`. The general form is `namespace:name`. <!--@include: @/wiki/bedrock-wiki-mirror.md-->
As a concrete example of why namespaces are helpful, let's imagine you create a new Mob. You name it `minecraft:shark`, not aware that you should create your own namespace for custom content. Next year, Mojang decides to add sharks into the game! Now there is a naming conflict since there are two definitions of `minecraft:shark`. Your addon will break. 命名空间是用于标识内容归属的标识符。你可以将它们理解为文件夹。命名空间有助于避免命名冲突的产生。
If you had instead used `your_namespace:shark`, the naming conflict wouldn't have happened. 在附加包创作中,命名空间本质上可以看作是"冒号左侧的部分"。例如在`minecraft:zombie`中,`minecraft`就是命名空间。其通用格式为`命名空间:名称`
## Picking a namespace 举个具体例子说明命名空间的重要性:假设你创建了一个新生物并命名为`minecraft:shark`却不知道应该为自定义内容使用自己的命名空间。一年后Mojang决定在游戏中加入鲨鱼此时就会出现两个`minecraft:shark`的定义,导致命名冲突,你的附加包将无法正常运行。
A suitable namespace is unique to you. Something like `mob` or `cars` or `content` or `custom` would be a **bad** namespace since another developer might come up with the same namespace as you. 如果你当初使用`你的命名空间:shark`,就不会发生这种冲突。
A suitable namespace is short. You will be writing your namespace a **LOT**, so the shorter, the better. `george_carlin_the_comedian` would be a lousy namespace for this reason. ## 如何选择命名空间
For personal projects, I recommend a convenient version of your player name, and for commercial projects, I recommend a suitable version of the company name. 合适的命名空间应当具有个人独特性。类似`mob``cars``content``custom`这样的通用词是**糟糕的**命名空间选择,因为其他开发者可能会使用相同的名称。
Some good examples: 合适的命名空间应当简短。你将会**频繁使用**你的命名空间,因此越简短越好。类似`george_carlin_the_comedian`这样的长命名空间就不太合适。
- `gcarlin` 对于个人项目建议使用玩家ID的简化版本商业项目则建议使用公司名称的合适变体。
- `sirlich`
- `cubeworld`
- `bworks`
**DO NOT USE** `minecraft` or `minecon` as a namespace unless editing a vanilla file. Not only is it a terrible idea, but Minecraft reserves these, and it won't even work. 优秀示例:
- `gcarlin`
- `sirlich`
- `cubeworld`
- `bworks`
## Where to use namespaces? **切勿使用**`minecraft``minecon`作为命名空间除非修改原版文件。这不仅是个糟糕的主意而且Minecraft保留了这些命名空间的使用权实际也无法生效。
In short, you should use namespaces as often as you can. ## 命名空间的使用场景
For starters, you should use a namespace when adding custom entities to the game. 简而言之,应当尽可能多地使用命名空间。
`sirlich:shark` is much better than `shark`. 基础原则:为游戏添加自定义实体时必须使用命名空间。`sirlich:shark`的命名方式远优于`shark`
It would be best if you also used namespaces for components and events. Just like Mojang uses `minecraft:pig_saddled` you should use `namespace:my_mob_event`, and `namespace:my_component_group`. 在组件和事件的命名中也应使用命名空间。就像Mojang使用`minecraft:pig_saddled`那样,你应该使用`命名空间:我的生物事件``命名空间:我的组件组`的格式。
It would be best if you also used namespaces in animation controllers, render controllers, and animations. 在动画控制器、渲染控制器和动画的命名中也推荐使用命名空间。例如:`controller.animation.命名空间.实体名称.动作`的格式优于`controller.animation.我的动作`
For example: `controller.animation.namespace.entity_name.action` is better than `controller.animation.my_action`. ## 无需使用命名空间的场景
## Where NOT to use namespaces. 实际文件结构不需要包含命名空间。`animations/命名空间/我的实体/animation`的路径结构反而会比`animations/我的实体/animation`更易造成混淆。
The actual file structure does not need namespaces.
`animations/namespace/my_entity/animation` is more confusing than `animations/my_entity/animation`.

View File

@@ -1,7 +1,7 @@
--- ---
title: Overwriting Assets title: 资源覆盖机制
tags: tags:
- intermediate - 中级
mentions: mentions:
- SirLich - SirLich
- MedicalJewel105 - MedicalJewel105
@@ -9,76 +9,80 @@ mentions:
- SmokeyStack - SmokeyStack
--- ---
## Addon Layering # 资源覆盖机制
The addon system is built layer by layer, where each pack is added _on top_ of the ones before it. Even if you only have a single pack added, there is an implicit _vanilla_ pack which is always added. When you add custom content, this content will have full access to all vanilla files. <!--@include: @/wiki/bedrock-wiki-mirror.md-->
### Accessing Vanilla Files ## 附加包层级系统
This layered structure is very useful, because it allows us to access the files inside of vanilla, without copy/pasting them into our addon. For example you can access `blocks/stone.png` without moving it into your addon! Just set it as the texture for your custom entity - it will work out of the box. This is particularly useful for things like models, or render controllers, or sounds. 附加包系统采用分层架构,每个资源包/行为包都会叠加在先前加载的包之上。即使你只添加了一个自定义包,系统也会默认加载隐式的原版包。当创建自定义内容时,这些内容将完全继承原版文件的所有权限。
If the vanilla assets change, for example if [JAPPA](https://twitter.com/JasperBoerstra?ref_src=twsrc%5Egoogle%7Ctwcamp%5Eserp%7Ctwgr%5Eauthor) updates the stone texture, your addon will also receive the update, since you are relying on the actual dynamic, vanilla resources. ### 访问原版文件
You should try to use this system of layering as often as you can. If you don't *need* to copy/paste something into your addon, don't. 这种分层结构非常实用,它允许我们无需将原版文件复制到附加包中即可直接调用。例如你可以直接调用`blocks/stone.png`作为自定义实体的纹理,无需复制文件即可直接生效。这种特性在模型、渲染控制器、音效等资源的调用中尤为便利。
若原版资源发生更新(例如[JAPPA](https://twitter.com/JasperBoerstra?ref_src=twsrc%5Egoogle%7Ctwcamp%5Eserp%7Ctwgr%5Eauthor)更新了石头纹理),你的附加包也会同步获得更新,因为你的资源始终动态关联着原版资源。
请尽可能使用这种分层调用机制。如果不需要复制粘贴原版资源,就不要进行冗余操作。
:::warning :::warning
It is never OK to make an addon inside of a copy of the vanilla resource/behavior pack. This will make the download for your addon incredibly huge, and will reduce performance. Always begin with a blank addon, then copy/paste the files you want to overwrite. 绝对禁止直接复制原版资源包/行为包进行修改。这会导致附加包体积异常臃肿,并严重影响运行性能。正确做法是新建空白附加包,仅复制需要覆盖的特定文件。
::: :::
## Overwriting Assets ## 资源覆盖方式
Pack Layering also allows us to overwrite vanilla assets, by _overwriting_ them with a file that shares the same path, or the same identifier. Our new file will replace the one being used in vanilla, allowing us to change textures, sounds, entity behavior, etc. 通过包层级系统,我们可以通过创建相同路径或相同标识符的文件来覆盖原版资源。新的文件将完全替代原版文件,从而实现纹理替换、音效修改、实体行为调整等功能。
:::warning :::warning
Different resources have different methods of overwriting, so be careful to use the right method for each type! 不同类型的资源需要采用不同的覆盖方式,请仔细确认每种资源的覆盖机制!
::: :::
### Overwriting by Path ### 路径覆盖法
Assets that are referenced by _path_, and do _not have an identifier_ can be overwritten by simply placing a new asset into the same path. The following can be overwritten in this way: 对于通过路径引用且没有标识符的资源,只需在相同路径下创建新文件即可覆盖。以下资源类型适用此方式:
- Functions - 游戏指令
- Loot tables - 战利品表
- Textures - 纹理贴图
- Sounds - 音效文件
- Trade Tables - 交易表
When you overwrite these files, the overwriting is absolute: The new asset will fully replace the old asset. 此方式会完全替换原文件内容。
:::tip :::tip
**Example**: If you would like to replace the redstone ore texture, simply place a new file at `textures/blocks/redstone_ore.png`. **示例**:要替换红石矿石纹理,只需在`textures/blocks/redstone_ore.png`路径放置新纹理文件即可。
::: :::
### Overwriting by Identifier ### 标识符覆盖法
Many assets are defined not by their name, but by their identifier! To overwrite these assets, simply create a new file that shares the same identifier, regardless of file-path. The following can be overwritten in this way: 对于通过标识符定义的资源,只需创建具有相同标识符的文件(无论路径如何)即可覆盖。以下资源类型适用此方式:
- BP Entities - 行为包实体
- RP Entities - 资源包实体
- Animations - 动画
- Models - 模型
- Animation Controllers - 动画控制器
- Spawn Rules - 生成规则
- Recipes - 合成配方
- Particles - 粒子效果
- Render Controllers - 渲染控制器
When you overwrite these files, the overwriting is absolute: The new asset will fully replace the old asset. 此方式会完全替换原文件内容。
:::tip :::tip
**Example**: If you would like to make Ghasts have higher health, simply create a new BP entity with the `minecraft:ghast` identifier, and all the behaviors required to make the ghast function. **示例**:要提升恶魂生命值,需要创建包含`minecraft:ghast`标识符的新实体行为文件,并完整定义恶魂的所有行为组件。
Remember, entity files do not merge together, so you will first need to copy/paste the entire BP Ghast file, and _then_ edit the health. Simply creating a `minecraft:ghast` with a high health component inside will not work. 注意:实体文件不会自动合并,必须首先完整复制原版恶魂行为文件,再进行生命值修改。仅创建包含高生命值组件的`minecraft:ghast`文件会导致功能异常。
::: :::
### Overwriting via Reference File ### 注册表覆盖法
Many assets can also be registered into some kind of "registration system" file. These files are interesting, because unlike the other asset types, they are _merged together_ instead of _overwritten_. This means that when you define these files, you do not need to copy from the vanilla resources. You can simply start with a blank file, and then overwrite the specific definitions you want. 部分资源通过注册表文件进行管理,这类文件具有合并特性而非完全覆盖。这意味着你无需复制原版内容,只需创建新的定义即可覆盖特定条目。
The following files work in this way: 以下注册表文件支持此方式:
- All UI files - 所有UI文件
- [All language files](/concepts/text-and-translations) - [所有语言文件](/wiki/concepts/text-and-translations)
- `item_textures.json` - `item_textures.json`
- `flipbook_textures.json` - `flipbook_textures.json`
- `terrain_textures.json` - `terrain_textures.json`
@@ -87,11 +91,10 @@ The following files work in this way:
- `sound_definitions.json` - `sound_definitions.json`
:::tip :::tip
**Example:** Lets say you want to override the `sugar` texture, using the reference files. You can do so by creating a new `item_textures.json`, with the following contents: **示例**:通过注册表覆盖法修改糖的纹理,只需新建`item_textures.json`并添加以下内容:
<CodeHeader></CodeHeader> ::: code-group
```json [item_textures.json]
```json
{ {
"resource_pack_name": "vanilla", "resource_pack_name": "vanilla",
"texture_data": { "texture_data": {
@@ -101,20 +104,23 @@ The following files work in this way:
} }
} }
``` ```
This _definition_ will be merged with the vanilla `item_textures.json`, and will override the short-name `sugar`. When the vanilla item accesses this short-name, it will get a reference to your custom texture path, instead of the actual texture path to sugar.
::: :::
## Overwriting Dangers 该定义会与原版`item_textures.json`合并,覆盖`sugar`的纹理路径指向。当原版物品调用此简称时,将自动引用你的自定义纹理。
:::
Since addons mostly _overwrite_ each other rather than _merge_, it can be very difficult to get two incompatible addons to work together. For example, if you try to combine two addons that overwrite the creeper behavior (for example, one makes them very fast, and one makes them very large) the addon you have applied _second_ will overwrite the first. ## 覆盖风险提示
This is mostly a problem with `player.json` (in either the RP or the BP), since this file is often used for gameplay purposes. 由于附加包采用覆盖机制而非合并机制,不同附加包之间可能存在兼容性问题。例如同时安装两个修改爬行者行为的附加包(一个提升速度,一个增大体型),后加载的包会完全覆盖前者的修改。
## Things that Cannot be Overwritten 这个问题在`player.json`(资源包或行为包中的)中尤为突出,因为该文件常被用于核心玩法修改。
Not everything can be overwritten, the following is a list of things that cannot be overwritten using any of the described methods: ## 不可覆盖内容列表
- Vanilla items (Not all) 以下内容无法通过上述任何方式覆盖:
- Vanilla blocks
- Vanilla fogs (create a fog with another namespace and change it everywhere it is used) - 原版物品(部分不可覆盖)
- 原版方块
- 原版雾效(需新建命名空间的雾效并全局替换引用)
(注:保留英文术语以保持开发概念准确性)

View File

@@ -1,5 +1,5 @@
--- ---
title: Shaders title: 着色器(光影)
mentions: mentions:
- SirLich - SirLich
- Dreamedc2015 - Dreamedc2015
@@ -8,46 +8,42 @@ mentions:
- SIsilicon - SIsilicon
--- ---
# 着色器光影Shader
<!--@include: @/wiki/bedrock-wiki-mirror.md-->
:::warning :::warning
The shaders on this page are incompatible with [Render Dragon](https://help.minecraft.net/hc/en-us/articles/360052771272-About-the-1-16-200-Update-for-Windows-10-). That means that they will not work on Windows and Console devices past 1.16.200, nor other devices past 1.18.30! 本页所述的着色器与[Render Dragon](https://help.minecraft.net/hc/en-us/articles/360052771272-About-the-1-16-200-Update-for-Windows-10-)渲染引擎不兼容。这意味着在1.16.200版本后的Windows和主机设备以及1.18.30版本后的其他设备上无法使用!
::: :::
## Overview ## 概述
Shaders are divided into 2 folders: `glsl` and `hlsl`. For shaders to work on every device, 着色器分为`glsl``hlsl`两个文件夹。要使着色器在所有设备上生效需要同时用两种语言编写代码。在Windows平台测试时使用`hlsl`即可。在两种语言间转换时需要注意语法差异例如HLSL中的`float3`对应GLSL中的`vec3`。[此处](https://anteru.net/blog/2016/mapping-between-HLSL-and-GLSL/)可查看两种语言的对照表。
you need to code shaders in both languages. For testing on Windows, `hlsl` is enough.
When rewriting shaders from one language to another, there are few things to change,
like HLSL `float3` is `vec3` in GLSL. Mapping between those languages can be found [here](https://anteru.net/blog/2016/mapping-between-HLSL-and-GLSL/)
## Materials ## 材质
Vertex, fragments, and sometimes geometry shaders are combined with some options 顶点着色器、片段着色器和几何着色器(可选)通过材质配置文件组合使用。创建新材质时,需要参照原版资源包中的`.material`文件命名。例如:`materials/particles.material`。材质支持继承机制,使用冒号语法:`entity_alpha:entity_base`
as materials and are required for custom shaders. To create new material,
you need to create a file, which matches the name of the .material file in the vanilla resource pack.
For example: `materials/particles.material`. Materials support inheritance by adding parent
material after a colon. For example: `entity_alpha:entity_base`
### Common material definition fields ### 通用材质定义字段
| **Field name** | **Description** | **Example value** | **Notes** | | **字段名称** | **描述** | **示例值** | **注意事项** |
| ---------------- | --------------------------------------------------------------------- | -------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | | ------------------ | ----------------------------------------------------------------------- | ------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------ |
| `vertexShader` | Path to the shader relative to hlsl/glsl folder | | For HLSL shader, `.hlsl` suffix is added. | | `vertexShader` | 顶点着色器路径相对于hlsl/glsl文件夹 | | HLSL着色器会自动添加`.hlsl`后缀 |
| `fragmentShader` | Path to the shader relative to hlsl/glsl folder | | For HLSL shader, `.hlsl` suffix is added. | | `fragmentShader` | 片段着色器路径相对于hlsl/glsl文件夹 | | HLSL着色器会自动添加`.hlsl`后缀 |
| `vertexFields` | An array of fields passed to vertex shader | | It's better to copy this field from vanilla material. | | `vertexFields` | 传递给顶点着色器的字段数组 | | 建议从原版材质中复制此字段 |
| `variants` | An array of objects, which define variants of the material | | It's better to copy this field from vanilla material. | | `variants` | 定义材质变体的对象数组 | | 建议从原版材质中复制此字段 |
| `+defines` | An array of `#define` directives to add to the shader source | | Useful for reusing shader, but changing some minor setting. | | `+defines` | 添加到着色器源码的`#define`指令数组 | | 适用于复用着色器时调整细节参数 |
| `+states` | An array of states to enable | `["Blending", "DisableAlphaWrite", "DisableDepthWrite"]` | For OpenGL implementation, this is equivalent to [glEnable](https://www.khronos.org/registry/OpenGL-Refpages/gl2.1/xhtml/glEnable.xml) call. | | `+states` | 启用的渲染状态数组 | `["Blending", "DisableAlphaWrite", "DisableDepthWrite"]` | OpenGL实现中对应[glEnable](https://www.khronos.org/registry/OpenGL-Refpages/gl2.1/xhtml/glEnable.xml)调用 |
| `-defines` | An array of `#defines` directives to remove from inherited `+defines` | | | | `-defines` | 从继承的`+defines`中移除的指令数组 | | |
| `+samplerStates` | An array of objects, defining how texture at certain index is treated | `{ "samplerIndex": 0, "textureFilter": "Point" }` | `textureFilter` specifies how to sample the texture and `textureWrap` specifies the behavior, when accessing outside of the texture dimensions. | | `+samplerStates` | 定义纹理采样方式的对象数组 | `{ "samplerIndex": 0, "textureFilter": "Point" }` | `textureFilter`指定采样方式,`textureWrap`定义纹理边界外访问行为 |
| `msaaSupport` | Multisample anti-aliasing support | `Both` | | | `msaaSupport` | 多重采样抗锯齿支持 | `Both` | |
| `blendSrc` | Specifies how the color source blending factors are computed | `One` | For OpenGL implementation, this is equivalent to [glBlendFunc](https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/glBlendFunc.xhtml) call. | | `blendSrc` | 颜色源混合因子计算方式 | `One` | OpenGL实现中对应[glBlendFunc](https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/glBlendFunc.xhtml)调用 |
| `blendDst` | Specifies how the color destination blending factors are computed | `One` | For OpenGL implementation, this is equivalent to [glBlendFunc](https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/glBlendFunc.xhtml) call. | | `blendDst` | 颜色目标混合因子计算方式 | `One` | OpenGL实现中对应[glBlendFunc](https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/glBlendFunc.xhtml)调用 |
Example: 示例:
<CodeHeader></CodeHeader> ::: code-group
```json [材质示例]
```json
{ {
"materials": { "materials": {
"version": "1.0.0", "version": "1.0.0",
@@ -73,89 +69,80 @@ Example:
} }
} }
``` ```
:::
For all the details about material files and possible field values, check [material file JSON schema](https://github.com/stirante/bedrock-shader-schema/blob/master/materials.schema.json). 完整材质文件规范请参考[材质文件JSON模式](https://github.com/stirante/bedrock-shader-schema/blob/master/materials.schema.json)。
## Troubleshooting ## 疑难解答
### Shader doesnt change ### 着色器未生效
Every time there is a change in the shader, you need to restart Minecraft to recompile the shader completely. 每次修改着色器后必须重启Minecraft才能完全重新编译着色器。
### Compilation error ### 编译错误
When there is a shader compilation error, a line number is usually specified where the error occurred. You need to check a few lines above the one set in error because Minecraft adds `#define` directives before compilation. 出现编译错误时错误信息中的行号可能需要检查前几行的代码因为Minecraft会在编译前自动添加`#define`指令。
### Couldnt find constant buffer named: $Globals ### 找不到名为$Globals的常量缓冲区
I couldnt accurately find the actual cause of this error, but it seems to be somehow connected to global variables. Removing them (initializing them in the `main` function or changing them to `#define` directives) seems to fix the problem. 此错误可能与全局变量相关。尝试通过以下方式解决:
- 在`main`函数中初始化变量
- 改用`#define`指令定义常量
## Tips and tricks ## 实用技巧
### Passing variables to the shader ### 向着色器传递变量
You can pass variables to the shader from a particle or an entity by changing entity color. 通过修改实体颜色可将数据传入着色器。输入值会被限制在`<0.0, 1.0>`范围内。传递较大数值时建议先进行归一化处理。
Input color is clamped to `<0.0, 1.0>`. To pass more significant values, you need to divide by max value (or at least some considerable number).
### Using time in shader ### 使用时间变量
`TIME` variable is a number of seconds as `float` and is global for all shaders. For time-based on particle lifetime, you need to pass this: 全局`TIME`变量存储以秒为单位的浮点时间值。要获取基于粒子生命周期的计时器:
<CodeHeader></CodeHeader> ::: code-group
```json [粒子计时器配置]
```json
"minecraft:particle_appearance_tinting": { "minecraft:particle_appearance_tinting": {
"color": ["variable.particle_age/variable.particle_lifetime", 0, 0, 1] "color": ["variable.particle_age/variable.particle_lifetime", 0, 0, 1]
} }
``` ```
:::
Then in the shader, use `PSInput.color.r` as time, where `0.0` is particle birth and `1.0` is particle death. 在着色器中使用`PSInput.color.r`获取时间值,其中`0.0`表示粒子生成,`1.0`表示粒子消亡。
### Camera direction towards the entity ### 相机朝向控制
For entity shaders, you can make the shader dependent on the camera direction towards the entity. 在实体着色器中实现相机方向相关效果:
- Add to `PS_Input` in vertex and fragment shader new field
<CodeHeader></CodeHeader>
1. 在顶点/片段着色器的`PS_Input`结构体添加:
``` ```
float3 viewDir: POSITION; float3 viewDir: POSITION;
``` ```
- After that, add to vertex shader this line 2. 在顶点着色器中添加:
<CodeHeader></CodeHeader>
``` ```
PSInput.viewDir = normalize((mul(WORLD, mul(BONES[VSInput.boneId], float4(VSInput.position, 1)))).xyz); PSInput.viewDir = normalize((mul(WORLD, mul(BONES[VSInput.boneId], float4(VSInput.position, 1)))).xyz);
``` ```
- In the fragment shader, use `PSInput.viewDir` to make changes depending on camera rotation 3. 在片段着色器中使用`PSInput.viewDir`控制渲染逻辑
### Debugging values ### 调试技巧
The easiest way to debug a value is to turn it into color and render it like this. 将调试值转换为颜色输出是最直观的方式:
<CodeHeader></CodeHeader> ::: code-group
```hlsl [颜色调试]
```
PSOutput.color = float4(PSInput.uv, 0., 1.); PSOutput.color = float4(PSInput.uv, 0., 1.);
``` ```
:::
This should create a red-green gradient, showing that the values of `uv` are between `<0, 0>` and `<1, 1>`. 这会生成红绿渐变显示UV坐标范围。推荐使用[调试着色器](http://files.stirante.com/debugShader.zip)修改HLSL第70行代码可显示不同变量
You can use the debug shader I wrote [based on this shader](http://mew.cx/drawtext/drawtext).
Right now, this shader will display values of the color passed to the shader. To display another value, change line 70 in hlsl shader to
<CodeHeader></CodeHeader>
::: code-group
```hlsl [调试代码]
int ascii = getFloatCharacter( cellIndex, <需要显示的向量> );
``` ```
int ascii = getFloatCharacter( cellIndex, <float4 vector here> ); :::
```
GLSL version of debugging shader may crash Minecraft, use only for debugging. 注意:GLSL版调试着色器可能导致崩溃,建议仅用于调试。
[Download debug shader](http://files.stirante.com/debugShader.zip) ![调试着色器演示](/assets/images/knowledge/shaders/debugShader.gif)
![](/assets/images/knowledge/shaders/debugShader.gif)

View File

@@ -1,7 +1,7 @@
--- ---
title: Sounds title: 声音系统
tags: tags:
- intermediate - 中级
mentions: mentions:
- SirLich - SirLich
- solvedDev - solvedDev
@@ -14,17 +14,21 @@ mentions:
- ThomasOrs - ThomasOrs
--- ---
In bedrock, we can add custom sounds without overwriting any vanilla sounds. This is done by adding files to the resource pack. # 声音系统
<!--@include: @/wiki/bedrock-wiki-mirror.md-->
在基岩版中,我们可以通过资源包添加自定义声音而无需覆盖原版音效。以下是实现方法:
:::tip :::tip
The best way to learn about sounds is by downloading and playing around with the default resource pack. 学习声音系统的最佳方式是下载并研究默认资源包的结构。
::: :::
### Folder Structure ### 文件夹结构
There are two main files that we edit when we want to add sounds. Note how `sound_definition` is nested inside `sounds`. 添加声音时主要需要修改两个文件。注意`sound_definition`文件需要放置在`sounds`文件夹内。
Sound files themselves are added inside of the `sounds` folder, and can be any of the following formats. 声音文件本身存放在`sounds`文件夹中,支持以下格式:
<FolderView :paths="[ <FolderView :paths="[
'RP/sounds.json', 'RP/sounds.json',
@@ -36,11 +40,10 @@ Sound files themselves are added inside of the `sounds` folder, and can be any o
## sound_definitions.json ## sound_definitions.json
`sound_definitions.json` is where we define new sound short-names. This should be thought of as typing a `short-name` or `id` to a physical sound path. Here is an example, `sound_definitions.json`, that adds a new trumpet sound called `example.toot`: 此文件用于定义声音的短名称short-name相当于为物理声音文件创建ID标识。以下示例添加了名为`example.toot`的小号音效:
<CodeHeader>RP/sounds/sound_definitions.json</CodeHeader> ::: code-group
```json [RP/sounds/sound_definitions.json]
```json
{ {
"format_version": "1.14.0", "format_version": "1.14.0",
"sound_definitions": { "sound_definitions": {
@@ -51,69 +54,68 @@ Sound files themselves are added inside of the `sounds` folder, and can be any o
} }
} }
``` ```
Sounds added in this way can be triggered using `/playsound`. Please note that `playsound` does not auto-correct, so you will need to be careful in your typing.
:::warning
New files referenced by file path, such as sounds, DO need a complete client restart to load. This means that if sounds don't work, you should restart your entire MC client rather than just reloading the world.
::: :::
### /playsound volume notes 通过此方式添加的声音可通过`/playsound`命令触发。注意命令输入需严格匹配名称。
The game will clamp the sound volume to at most 1.0 before multiplying it with the sound definition's volume. :::warning
新增声音文件需要完全重启客户端才能生效。若音效未正常加载,请重启整个游戏而非仅重载世界。
:::
For `/playsound`, the maximum hearable range of a sound is given by `min(max_distance, max(volume * 16, 16))`. ### /playsound 音量说明
If `"max_distance"`is not given in the sound's definition, it is equivalent to `playsound_volume * 16`.
Approximate sound attenuation by distance. The actual graph might not be linear. 游戏会将音量参数限制在1.0以内,再与声音定义中的音量相乘。
声音的最大可听距离计算公式为:`min(max_distance, max(volume * 16, 16))`
若未在定义中设置`max_distance`,则等效于`playsound_volume * 16`
以下是声音随距离衰减的近似曲线(实际衰减可能非线性):
![](/assets/images/concepts/sounds/sound_graph.png) ![](/assets/images/concepts/sounds/sound_graph.png)
Shown above is the approximate sound attenuation factor by distance **for playing sounds with a volume parameter greater than or equal to 1**. Notice how the playsound `<volume>` limits the sound's audible range. 上图展示了**当playsound音量参数≥1时**的衰减曲线。注意`<volume>`参数会影响声音的可听范围。
The axis `distance` is the distance of the sound listener (player) to the sound source. The corresponding `volume` axis' value is the factor for the playsound volume capped to 1, multiplied by the sound definition's volume to get the final volume of the sound you hear. As an expression this could be written as: `final_volume = min(playsound_volume, 1) * graph_volume * sound_definition_volume`.
**Note:** Attenuation by distance of the hearable sound's volume is not affected by the volume parameter given in the command. 公式表达为:`final_volume = min(playsound_volume, 1) * graph_volume * sound_definition_volume`
For example, `mob.ghast.affectionate_scream` sets `"min_distance": 100.0`, but can only be heard from at most 16 blocks away when using `/playsound` with volume 1 to play it. Specifying a greater volume value increases the audible range. When using a large enough volume to hear the sound farther away, the sound will get quieter only after a distance of more than 100.0. **注意:** 距离衰减曲线不受命令中音量参数影响。
To make a sound which can be heard far away but also drops in volume continuously over distance, one can add e.g. `"volume": 0.01`and use large `<volume>` values in the playsound command. The high value for the `/playsound` volume will produce a large audible range (e.g. a volume of 4 is 64 blocks as calculated above), while the low volume will prevent the played sound from capping at 1.0 too soon. 例如:`mob.ghast.affectionate_scream`设置了`"min_distance": 100.0`,但使用`/playsound`音量1时最大可听距离仍为16格。若需增大范围可通过设置更高的音量参数。
### Top Level Keys 要实现远距离可听且线性衰减的效果,可在定义中设置`"volume": 0.01`并在命令中使用大音量值如4对应64格范围
In the example above, I showed two `top-level` fields: `category` and `sounds`. Sounds will be discussed in further detail below, but the other `top-level` keys will be discussed here: ### 顶级参数
#### Categories #### 类别(Categories
Categories are used internally by the engine to decide how each sound is played. We can utilize different channels to get other effects. 控制声音播放方式的核心参数:
| Category | Note | | 类别 | 说明 |
| -------- | ----------------------------------------------- | |----------|--------------------------|
| weather | | | weather | 天气音效 |
| block | | | block | 方块交互音效 |
| bucket | | | bucket | 桶类音效 |
| bottle | | | bottle | 玻璃瓶音效 |
| ui | Sounds in this category will ignore range limit | | ui | 界面音效(无视距离限制)|
| player | | | player | 玩家相关音效 |
| hostile | | | hostile | 敌对生物音效 |
| music | | | music | 背景音乐 |
| record | | | record | 唱片机音效 |
| neutral | | | neutral | 中立生物音效 |
#### min_distance #### min_distance
The distance from the sound source after which sound volume is attenuated. Default value: 0.0. It must be a float (eg. 1.0), or the property will be ignored. 声音开始衰减的最小距离浮点数默认0.0
#### max_distance #### max_distance
The distance from the sound source after which the sound volume is the quietest (if in range). It must be a float (eg. 1.0), or the property will be ignored. 声音衰减至最弱的最大距离(浮点数)
### Sound definitions ### 声音定义进阶
In the example above, I showed `sounds` as simply a list with a single path. This is good for simple sounds but does not have much power. For starts, I can add multiple sounds to the list. These sounds will be randomized when played: 可通过数组定义多个随机音效:
<CodeHeader>RP/sounds/sound_definitions.json</CodeHeader> ::: code-group
```json [RP/sounds/sound_definitions.json]
```json
{ {
"format_version": "1.14.0", "format_version": "1.14.0",
"sound_definitions": { "sound_definitions": {
@@ -128,49 +130,25 @@ In the example above, I showed `sounds` as simply a list with a single path. Thi
} }
} }
``` ```
:::
Additionally, we can define each sound as an object instead of a string. This allows us finer control and unlocks some new settings. The string/object style can be mixed and matched. #### 对象式定义参数
#### name | 参数 | 说明 |
|-------------------|----------------------------------------------------------------------|
| name | 文件路径(例:"sounds/music/game/creative/creative1" |
| stream | 启用流式加载(降低内存占用) |
| volume | 音量0.0-1.0可超过1.0 |
| load_on_low_memory| 已弃用1.16.0+ |
| pitch | 音高倍数2.3=2.3倍速播放) |
| is3D | 是否启用3D音效音乐/UI类自动禁用 |
| interruptible | 是否可被中断默认true |
| weight | 随机权重权重10的选中概率是权重2的5倍 |
The path to the file, such as: `"sounds/music/game/creative/creative1"` ### 完整示例
#### stream ::: code-group
```json [RP/sounds/sound_definitions.json#sound_definitions]
Limits the sound only to be played a limited number of instances at a time. Will cause the game to not load the entire sound data into memory while playing, but rather in smaller parts while playing, thus using less memory. Good for improving performance on sound heavy worlds.
#### volume
How loud the sound should play, from `0.0` to `1.0`. Sounds cannot be made more audible than initially encoded. Set to `1.0` by default.
Sounds in custom resource packs can have working values greater than 1.0.
#### load_on_low_memory
Forces the loading of the sound even when nearing low memory. "load_on_low_memory" is now deprecated as of 1.16.0
#### pitch
The pitch of the sound (how low/high it sounds). Should be a positive value. For example, `2.3` will let the sound play 2.3 times as quickly and thus at higher pitch. Set to `1.0` by default.
#### is3D
`true` makes the sound directional. Set to `true` for all sounds by default. Ignored for `music` and `ui` sounds. Only sounds with `false` will play stereo sound.
#### interruptible
Set to `true` by default.
### weight
If there is more than one sound in the list, the sound to be played is chosen randomly. `"weight"` (integer value like 5) will give the relative chance that this sound is chosen from the list. For example, if there are two sounds in the list, one with `"weight": 10` and the other with `"weight": 2`, the first will be played approximately 5 times more likely than the second (accurately: `10 / (10 + 2) = 83.3%` chance vs. `2 / (10 + 2) = 16.7%` chance) . Set to `1` by default.
### Example
Here is a more realistic example containing these options:
<CodeHeader>RP/sounds/sound_definitions.json#sound_definitions</CodeHeader>
```json
"block.beehive.drip": { "block.beehive.drip": {
"category": "block", "category": "block",
"max_distance": 8, "max_distance": 8,
@@ -185,63 +163,39 @@ Here is a more realistic example containing these options:
] ]
} }
``` ```
:::
## sounds.json ## sounds.json
If we want our sounds to run automatically, we can add them into the `sounds.json` file. This will tie the sound definitions directly to game events and cause them to play without needing to trigger with `/playsound`. 此文件用于绑定自动播放的音效:
Sounds can be added into various categories: | 分类 | 说明 |
|------------------------|----------------------|
| individual_event_sounds| 独立事件音效(如信标激活)|
| block_sounds | 方块交互音效 |
| entity_sounds | 实体音效(含自定义实体)|
| interactive_sounds | 交互音效(开发中) |
| Category | Note | ### 实体音效事件
| ----------------------- | -------------------------------------------------------------------------------- |
| individual_event_sounds | Contains sounds like beacon activation, chest-close, or explode |
| block_sounds | Contains hit, step, and break sounds for blocks |
| entity_sounds | Contains death, ambient, hurt, etc. sounds for entities (Including custom ones!) |
| interactive_sounds | WIP |
### Adding Entity Sounds 常见生命周期事件:
I assume that sounds can be added in other categories, but I personally only have experience adding sounds into the `entities` category. Entity sounds are automatically played at various points in the entities life-cycle. | 事件 | 触发时机 |
|---------------|------------------------|
| ambient | 随机播放(如生物低鸣)|
| hurt | 受伤时 |
| death | 死亡时 |
| step | 移动时 |
| fall.big | 高空坠落 |
| fall.small | 低处跌落 |
| splash | 溅水 |
| attack | 近战攻击 |
| shoot | 远程射击 |
Common events: ### 实体音效示例
| Events | Note | ::: code-group
| ---------- | -------------------------------------------------------- | ```json [RP/sounds.json]
| ambient | Played randomly, such as grunts, clucks, or ghast noises |
| hurt | Played when damaged |
| death | Played when it dies |
| step | Played when the entity moves along the ground |
| fall.big | For hitting the ground from a high height |
| fall.small | For hitting the ground from a low height |
| splash | For splashing in the water |
| attack | For melee attacking |
| shoot | For shooting projectiles |
There are also many sound events, which _most likely_ trigger automatically, but which I don't have details for, such as:
| Unknown Categories |
| ------------------ |
| breathe |
| splash |
| swim |
| ambient.in.water |
| death.in.water |
| jump |
| eat |
| hurt.in.water |
| mad |
| stare |
| sniff |
| sleep |
| spit |
| warn |
| scream |
### Example
<CodeHeader>RP/sounds.json</CodeHeader>
```json
{ {
"entity_sounds": { "entity_sounds": {
"entities": { "entities": {
@@ -265,48 +219,44 @@ There are also many sound events, which _most likely_ trigger automatically, but
} }
} }
``` ```
:::
## Adding sounds to Animations ## 动画音效绑定
Sounds played in animations function based off of `short-name` definitions in the RP entity file. 通过RP实体文件中的`sound_effects`实现动画同步:
This example shows playing a wing-flap sound, synced with an animation. ::: code-group
```json [RP/entities/dragon.json#minecraft:client_entity/description]
<CodeHeader>RP/entities/dragon.json#minecraft:client_entity/description</CodeHeader>
```json
"sound_effects": { "sound_effects": {
"wing_flap": "wiki.dragon.wing_flap" //where wiki.dragon.roar is a sound defined in sound_definitions "wing_flap": "wiki.dragon.wing_flap" // wiki.dragon.wing_flap需在sound_definitions中定义
} }
``` ```
:::
<CodeHeader>RP/animations/dragon.json#animations/animation.dragon.flying</CodeHeader> ::: code-group
```json [RP/animations/dragon.json#animations/animation.dragon.flying]
```json
"sound_effects": { "sound_effects": {
"3.16": { "3.16": {
"effect": "wing_flap" "effect": "wing_flap"
} }
} }
``` ```
:::
## Adding sounds to Animation Controllers ## 动画控制器音效
You can play sounds within animation controllers in a similar way that animations can be. 动画控制器中的音效触发方式类似:
This example shows playing an explosion sound, synced using an animation controller. ::: code-group
```json [RP/entities/custom_tnt.json#minecraft:client_entity/description]
<CodeHeader>RP/entities/custom_tnt.json#minecraft:client_entity/description</CodeHeader>
```json
"sound_effects": { "sound_effects": {
"explosion": "wiki.custom_tnt.explosion" //where wiki.custom_tnt.explosion is a sound defined in sound_definitions just like animation sounds. "explosion": "wiki.custom_tnt.explosion" // 需在sound_definitions中定义
} }
``` ```
:::
<CodeHeader>RP/animation_controllers/custom_tnt.animation_controllers.json#controller.animation.custom_tnt</CodeHeader> ::: code-group
```json [RP/animation_controllers/custom_tnt.animation_controllers.json#controller.animation.custom_tnt]
```json
"states":{ "states":{
"default":{ "default":{
"transitions":[ "transitions":[
@@ -329,3 +279,4 @@ This example shows playing an explosion sound, synced using an animation control
} }
} }
``` ```
:::

View File

@@ -1,5 +1,5 @@
--- ---
title: Subpacks title: 子Packs
mentions: mentions:
- SirLich - SirLich
- solvedDev - solvedDev
@@ -10,32 +10,36 @@ mentions:
- TheItsNameless - TheItsNameless
--- ---
## What are Subpacks? # 子Packs
Subpacks allow you to select between different addon 'configurations'. <!--@include: @/wiki/bedrock-wiki-mirror.md-->
They are intended for texture resolutions to load on different memory capacities, but can also be used to create file variations in behavior and resource packs. These variations can be selected by clicking the gear icon and adjusting the slider. ## 什么是子包?
## How do Subpacks work? 子包功能允许玩家在不同的附加包"配置"之间进行选择。
Files placed in you subpack folder will override files placed in your main addon folder, if the subpack is selected. For example, if your addon contains both `RP/textures/entities/ghost.png` and `RP/subpacks/pack_1/textures/ghost.png`, the second image file will replace the first, if subpack `pack_1` is selected. 该功能最初设计用于根据设备内存容量加载不同分辨率的材质包,但也可用于创建行为包和资源包的多种文件变体。玩家可以通过点击齿轮图标并调整滑块来选择不同的子包配置。
For more information about how files override each other, please see our page on [overriding vanilla assets](/concepts/overwriting-assets). ## 子包工作原理
## Creating Subpacks 当子包被选中时,放置在子包文件夹中的文件将覆盖主附加包文件夹中的同名文件。例如,若附加包同时包含 `RP/textures/entities/ghost.png``RP/subpacks/pack_1/textures/ghost.png`,当选择 `pack_1` 子包时,第二个图片文件将取代第一个文件。
- To start adding a subpack you need to create a `subpacks` folder inside the root of your `BP`/`RP`. 关于文件覆盖机制的更多信息,请参阅我们的[覆盖原版资源](/wiki/concepts/overwriting-assets)说明文档。
- Then inside the `subpacks` folder add a folder for each subpack you want to have
e.g. ## 创建子包
- 首先需要在行为包或资源包的根目录下创建 `subpacks` 文件夹
-`subpacks` 文件夹内为每个子包创建独立文件夹
例如:
<FolderView :paths="[ <FolderView :paths="[
'RP/subpacks/subpack_1', 'RP/subpacks/subpack_1',
'RP/subpacks/subpack_2' 'RP/subpacks/subpack_2'
]"></FolderView> ]"></FolderView>
- Inside each of these folders you can add the content of each subpack. - 在每个子包文件夹中添加该子包的特定内容
This can be anything that normally goes in your behavior or resource pack. 这些内容可以是常规附加包中的任意资源
e.g. 例如:
<FolderView :paths="[ <FolderView :paths="[
'RP/subpacks/subpack_1/textures/blocks/dirt.png', 'RP/subpacks/subpack_1/textures/blocks/dirt.png',
@@ -44,20 +48,19 @@ For more information about how files override each other, please see our page on
'RP/subpacks/subpack_2/textures/items/example_item.png' 'RP/subpacks/subpack_2/textures/items/example_item.png'
]"></FolderView> ]"></FolderView>
## Manifest Part ## 清单文件配置
To register the subpacks in the manifest you need to add `subpacks` and this contains an array of subpacks. 需要在清单文件(manifest.json)中注册子包信息,在 `subpacks` 字段下以数组形式声明各个子包。
Example: 示例配置:
<CodeHeader>RP/manifest.json</CodeHeader> ::: code-group
```json [RP/manifest.json]
```json
{ {
"format_version": 2, "format_version": 2,
"header": { "header": {
"name": "Pack Name", "name": "资源包名称",
"description": "Pack Description", "description": "资源包描述",
"uuid": "2fc2dd6f-86cb-4370-af70-21490a1ae471", "uuid": "2fc2dd6f-86cb-4370-af70-21490a1ae471",
"version": [1, 0, 0], "version": [1, 0, 0],
"min_engine_version": [1, 13, 0] "min_engine_version": [1, 13, 0]
@@ -72,24 +75,23 @@ Example:
"subpacks": [ "subpacks": [
{ {
"folder_name": "subpack_1", "folder_name": "subpack_1",
"name": "First Subpack", "name": "初级材质",
"memory_tier": 0 "memory_tier": 0
}, },
{ {
"folder_name": "subpack_2", "folder_name": "subpack_2",
"name": "Second Subpack", "name": "高清材质",
"memory_tier": 1 "memory_tier": 1
} }
] ]
} }
``` ```
:::
- `name` - name that will show when selecting subpacks. - `name` - 在子包选择界面显示的名称
- `memory_tier`- 设备运行所需内存配置1个内存等级 = 0.25 GB
- `folder_name` - 对应子包文件夹名称,例如示例中的 `subpack_1` 或 `subpack_2`
- `memory_tier`- amount of RAM that device must have to enable this subpack. 1 memory tier = 0.25 GB. ## 注意事项
- `folder_name` - name of the folder to be used for this subpack, for example in the examples above this would be `subpack_1` or `subpack_2`. 当仅添加一个子包时,选择界面会显示两个选项,但第二个"无子包"选项实际上**不会**用根目录内容覆盖子包内容。
## Known Things
If you add only one subpack, there will be 2 options at the subpacks selection section, however second resolution (no subpack actually) does **not** make content in the root folder override subpacks.

View File

@@ -1,5 +1,5 @@
--- ---
title: Text and Localization title: 文本与本地化
mentions: mentions:
- ThijsHankelMC - ThijsHankelMC
- SirLich - SirLich
@@ -14,13 +14,17 @@ mentions:
- Sprunkles - Sprunkles
--- ---
Minecraft is a game with fully localized text in languages all over the world. To achieve this, Minecraft employs a system where internal **translation keys** are assigned values on a per-language basis. Minecraft will generate translation keys for custom entities, items, and blocks, and it is up to us to assign them a localized name in our resource pack. # 文本与本地化
## Language Files <!--@include: @/wiki/bedrock-wiki-mirror.md-->
### File Location Minecraft 是一款支持全球多语言本地化的游戏。为实现这一特性,游戏采用了基于语言代码的**翻译键值系统**。对于自定义实体Entity、物品Item和方块BlockMinecraft 会自动生成翻译键值,而我们需要通过资源包为其提供本地化文本。
Language files typically go within the resource pack in the "texts" folder as files with the `.lang` file extension. These files can be placed in the behavior pack, but the only translatable text it can change is the pack manifest's name and description. ## 语言文件
### 文件位置
语言文件通常位于资源包的 `texts` 文件夹中,使用 `.lang` 扩展名。虽然也可以放置在行为包中但行为包仅能修改资源包清单manifest的名称和描述。
<FolderView :paths="[ <FolderView :paths="[
'RP/texts/en_US.lang', 'RP/texts/en_US.lang',
@@ -29,128 +33,128 @@ Language files typically go within the resource pack in the "texts" folder as fi
]" ]"
></FolderView> ></FolderView>
Minecraft supports 29 languages currently, as described in [§ Vanilla Languages](/concepts/text-and-translations#vanilla-languages). Minecraft 目前支持 29 种语言,详见 [§ 原版支持语言](/wiki/concepts/text-and-translations#vanilla-languages)
### Format ### 格式规范
The format for a language file is rather straightforward. Translations are supplied as key-value pairs separated by an equals sign (`=`), the key being a translation key and the value being a string. Values cannot contain newline characters. 语言文件采用键值对格式,使用等号(`=`)分隔。键为翻译键值,值为字符串(不支持换行符)。
```toml ```toml
wiki.example_translation.line_1=The first line! wiki.example_translation.line_1=
wiki.example_translation.line_2=Some more information following the first line. wiki.example_translation.line_2=
``` ```
Comments may be added with two pound signs (`##`), either as line comments or in-line comments. All text after the pound signs are a comment until the next line. 可通过双井号(`##`)添加注释,支持行尾注释和整行注释(注释内容持续到行尾)。
:::warning :::warning
Trailing spaces are not trimmed for in-line comments. If you want to indent a comment, use the Tab character. 行尾注释前的空格不会被自动删除。如需缩进注释请使用制表符Tab
::: :::
```toml ```toml
## Translator note: I thought this would be funny to put here. ## 译者注:这个翻译可能有点幽默成分
item.flint_and_steel.name=Flint and Steve ##[sic] item.flint_and_steel.name= ##[原文如此]
``` ```
A translation can contain substitutions in place of text. Substitutions can either be ordered (`%1`, `%2`, etc.) or not ordered (`%s`). Vanilla translations have their values filled in by the game, while players can manually set the substitutions' values with commands that use the raw JSON text format, like with [`/tellraw`](/commands/tellraw). 翻译文本支持占位符替换,可使用有序占位符(`%1``%2`)或无序占位符(`%s`。原版占位符由游戏自动填充而通过原始JSON文本命令 [`/tellraw`](/wiki/commands/tellraw))可手动指定替换值。
```toml ```toml
commands.op.success=Opped: %s commands.op.success=%s
immersive_reader.book_page_header=Page %1 of %2 immersive_reader.book_page_header= %1 / %2
``` ```
### Usage ### 应用场景
Localization can be done just about anywhere text can be used, including (but not limited to): 本地化文本可用于以下场景(包括但不限于):
- Pack name and description - 资源包/行为包名称与描述
- Entity, item, or block names - 实体、物品或方块的名称
- Pages in a book - 书页内容
- Lines on a sign - 告示牌文字
- `/tellraw` and `/titleraw` commands - `/tellraw` `/titleraw` 命令
- Text in dialogue - 对话系统中的文本
Some text cannot be translated however, such as for an item renamed in an anvil. 但某些文本(如铁砧重命名的物品)不支持本地化。
## Localization ## 本地化实践
:::tip :::tip
It is good practice create a copy of your language file for each major language your pack supports. For example, to support full English one should create both an `en_US.lang` and an `en_GB.lang` file, to cover English in both the United States and Great Britain countries, respectively. 最佳实践是为每个主要支持语言创建独立语言文件。例如要完整支持英语,应同时创建 `en_US.lang`(美式英语)和 `en_GB.lang`(英式英语)文件。
::: :::
When editing language files one must also add a `languages.json` file in the `texts` folder containing an array with each of the languages you plan to change. This lets Minecraft know that it should apply localization for these languages. 编辑语言文件时,需在 `texts` 文件夹中添加 `languages.json` 文件,声明需要修改的语言列表。这会告知 Minecraft 应用对应的本地化配置。
<CodeHeader>RP/texts/languages.json</CodeHeader> ::: code-group
```json [原始CodeHeader的值]
```json
[ [
"en_US", "en_US",
"en_GB", "en_GB",
"fr_FR" "fr_FR"
] ]
``` ```
:::
### Custom Languages ### 自定义语言
With a global resource pack, custom languages may be introduced through the `languages.json` and `language_names.json` files. Once the pack is applied globally the language can be changed in the "Language" tab of the in-game settings. 通过全局资源包,可使用 `languages.json` 和 `language_names.json` 添加自定义语言。应用全局资源包后,即可在游戏设置的"语言"选项中选择新语言。
For the following examples, lets assume that we have 2 fully functional language files, one named `xx_XX.lang`, and another named `yy_YY.lang`. 假设我们有两个功能完善的语言文件:`xx_XX.lang` 和 `yy_YY.lang`。
<CodeHeader>RP/texts/languages.json</CodeHeader> ::: code-group
```json [原始CodeHeader的值]
```json
[ [
"xx_XX", "xx_XX",
"yy_YY" "yy_YY"
] ]
``` ```
`language_names.json` is an array as well, but this time to define the names to display for the languages.
<CodeHeader>RP/texts/language_names.json</CodeHeader>
```json
[
[ "xx_XX", "New Language (Custom Language #1)" ],
[ "yy_YY", "Wiki-Speak (Custom Language #2)" ]
]
```
:::warning
Whenever using a custom language, make sure to unequip the language before you disable the Resource Pack which it is stored in, or else Minecraft will crash.
::: :::
### Vanilla Languages `language_names.json` 用于定义语言在选项菜单中的显示名称:
The following is a table of the 29 languages Minecraft supports by default. ::: code-group
```json [原始CodeHeader的值]
[
[ "xx_XX", "新语言(自定义语言 #1" ],
[ "yy_YY", "维基语(自定义语言 #2" ]
]
```
:::
| File ID | Language | Country | :::warning
| ---------- | --------------------- | -------------- | 使用自定义语言时,在禁用其所属资源包前请先切换回其他语言,否则可能导致游戏崩溃。
| id_ID | Indonesian | Indonesia | :::
| da_DK | Danish | Denmark |
| de_DE | German | Germany | ### 原版支持语言
| en_GB | English | Great Britain |
| en_US | English | North America | 下表列出了 Minecraft 默认支持的 29 种语言:
| es_ES | Spanish | Spain |
| es_MX | Mexican Spanish | Mexico | | 文件ID | 语言 | 国家/地区 |
| fr_CA | Canadian French | Canada | | ---------- | ------------------- | --------------- |
| fr_FR | French | France | | id_ID | 印度尼西亚语 | 印度尼西亚 |
| it_IT | Italian | Italy | | da_DK | 丹麦语 | 丹麦 |
| hu_HU | Hungarian | Hungary | | de_DE | 德语 | 德国 |
| nl_NL | Dutch | Netherlands | | en_GB | 英语 | 英国 |
| nb_NO | Bokmål | Norway | | en_US | 英语 | 北美 |
| pl_PL | Polish | Poland | | es_ES | 西班牙语 | 西班牙 |
| pt_BR | Brazilian Portuguese | Brazil | | es_MX | 墨西哥西班牙语 | 墨西哥 |
| pt_PT | Portuguese | Portugal | | fr_CA | 加拿大法语 | 加拿大 |
| sk_SK | Slovak | Slovakia | | fr_FR | 法语 | 法国 |
| fi_FI | Finnish | Finland | | it_IT | 意大利语 | 意大利 |
| sv_SE | Swedish | Sweden | | hu_HU | 匈牙利语 | 匈牙利 |
| tr_TR | Turkish | Turkey | | nl_NL | 荷兰语 | 荷兰 |
| cs_CZ | Czech | Czech Republic | | nb_NO | 书面挪威语 | 挪威 |
| el_GR | Greek | Greece | | pl_PL | 波兰语 | 波兰 |
| bg_BG | Bulgarian | Bulgaria | | pt_BR | 巴西葡萄牙语 | 巴西 |
| ru_RU | Russian | Russia | | pt_PT | 葡萄牙语 | 葡萄牙 |
| uk_UA | Ukrainian | Ukraine | | sk_SK | 斯洛伐克语 | 斯洛伐克 |
| ja_JP | Japanese | Japan | | fi_FI | 芬兰语 | 芬兰 |
| zh_CN | Chinese (Simplified) | China | | sv_SE | 瑞典语 | 瑞典 |
| zh_TW | Chinese (Traditional) | Taiwan | | tr_TR | 土耳其语 | 土耳其 |
| ko_KR | Korean | Korea | | cs_CZ | 捷克语 | 捷克共和国 |
| el_GR | 希腊语 | 希腊 |
| bg_BG | 保加利亚语 | 保加利亚 |
| ru_RU | 俄语 | 俄罗斯 |
| uk_UA | 乌克兰语 | 乌克兰 |
| ja_JP | 日语 | 日本 |
| zh_CN | 简体中文 | 中国 |
| zh_TW | 繁体中文 | 台湾地区 |
| ko_KR | 韩语 | 韩国 |

View File

@@ -8,21 +8,24 @@ mentions:
- TheItsNameless - TheItsNameless
--- ---
## General Overview # textures_list.json
The `textures_list` file is Minecraft's way of *caching* each texture so that it can retrieve it faster than looking through each image in your textures folder. This is especially important when you have an abundance of textures, where Minecraft could potentially mess up and swap textures or even not load them at all. Minecraft tends to throw a content log _warning_ if you don't have the textures listed in the file. You can ignore it if you have a small amount, but it is recommended that you list the textures anyway. <!--@include: @/wiki/bedrock-wiki-mirror.md-->
## What textures can be used in the file? ## 概述
Any texture! Any textures can and _should_ be used in the textures_list.json file for best practice and performance. `textures_list` 文件是 Minecraft 用来*缓存*所有纹理的机制,相比从纹理文件夹中逐张查找,这种方式能更快地检索纹理。当您拥有大量纹理时这一点尤为重要,因为 Minecraft 可能会因纹理过多而出现错误交换纹理甚至无法加载的情况。如果您未在文件中列出纹理Minecraft 通常会在内容日志中抛出_警告_。纹理数量较少时可以忽略该警告但仍建议您将所有纹理列入清单。
## File Structure ## 可使用的纹理类型
The structure is simple. The file itself is in `RP/textures` and is named `textures_list.json`. The file includes the file path to every texture you want in the file: 所有纹理最佳实践表明任何纹理都可以且_应该_被列入 textures_list.json 文件中以优化性能。
<CodeHeader>RP/textures/textures_list.json</CodeHeader> ## 文件结构
```json 结构非常简单。该文件位于 `RP/textures` 目录下,命名为 `textures_list.json`。文件包含您需要缓存的所有纹理文件路径:
::: code-group
```json [RP/textures/textures_list.json]
[ [
"textures/blocks/foo", "textures/blocks/foo",
"textures/blocks/bar", "textures/blocks/bar",
@@ -37,7 +40,8 @@ The structure is simple. The file itself is in `RP/textures` and is named `textu
"textures/entity/bar" "textures/entity/bar"
] ]
``` ```
:::
## Automating ## 自动化处理
If you have a lot of textures, this could obviously be tedious to go and list all the texture paths. In this case you can start to use [Regolith](https://bedrock-oss.github.io/regolith/) with its wonderful filters. 当您需要处理大量纹理时,手动列出所有纹理路径显然非常繁琐。此时可以使用集成强大过滤器的 [Regolith](https://bedrock-oss.github.io/regolith/) 工具来实现自动化处理。

View File

@@ -1,70 +1,74 @@
--- ---
title: Advanced Molang title: 进阶Molang
toc_max_level: 2 toc_max_level: 2
mentions: mentions:
- Ciosciaa - Ciosciaa
- TheItsNameless - TheItsNameless
--- ---
## Values # 进阶Molang
- All expressions in Molang return a value for the sake of checks against equality. Most expressions return `0`. Notably, assignments return the value assigned and loops return the resolved value of the looping statements, if one would exist. <!--@include: @/wiki/bedrock-wiki-mirror.md-->
- All values in Molang are effectively single-precision floats.
- `this` is used to refer to the field's current value as it accumulated during evaluation. It is only observed to be usable in animations, but it may be usable elsewhere. As an example, if the accumulated transformations on the `x` `scale` of a bone would yield `62`, a final animation with a `x` `scale` of `-this` would resolve to `-62`, unsetting the prior transformations. This is used in vanilla animations in a number of places. Outside of animation contexts, `this` appears to always resolve to `0`.
### Booleans ## 值类型
- Booleans are usable in Molang. `true` resolves to `1`, and `false` resolves to `0`. - 所有Molang表达式都会返回一个值以便进行相等性检查。大多数表达式返回`0`。特别地,赋值表达式会返回被赋予的值,循环语句会返回循环体内最后一个解析的值(如果存在)。
- Molang中的所有值本质上都是单精度浮点数。
- `this`用于指代当前字段在运算过程中累积的当前值。目前仅在动画系统中被观察到可用,但可能在其他场景也有用途。例如,如果骨骼在`x`轴上的缩放变换累积结果为`62`,那么最终动画中`x`轴的`scale`设置为`-this`时,结果将为`-62`,这会抵消之前的变换效果。这一特性在大量原版动画中都有应用。在非动画上下文中,`this`似乎始终解析为`0`
### Numbers ### 布尔值
- You can use leading `0`s in front of numbers, for example, to line them up better in your code. - 布尔值可在Molang中使用。`true`解析为`1``false`解析为`0`
- Numbers can use exponential notation, such as `2.5e2`, which would be equal to 250. `e` can be suffixed with `+` or `-` to direct the power.
- Numbers may be suffixed with a single `f`, often used to denote a floating point value. This can be found across vanilla code, but it is not believed to have any functionality.
### Strings ### 数值
- Strings use `\` (`\\` in escaped JSON) as some sort of escape or perhaps something else. It is unknown what functionality this has. It is known that the subsequent 2 characters are handed off to their own sub-parser, which does not exit correctly on a closing `'`; this means the Molang string `"v.type = '\\x';"` is invalid. `'`, which is normally disallowed on its own as it would represent the end of the string, is allowed in the 2 characters following a `\`. - 可以在数值前添加前导零(例如`0012`),以便在代码中对齐。
- String values are (mostly) incremental as they are represented against floats. It is possible to compare 2 individual character strings using equality or comparison operators or even to effectively "adjust" the contents of a single-character string. Multi-character behavior of such is unknown. - 数值支持科学计数法(如`2.5e2`等价于250。指数部分可使用`+``-`符号。
- 数值可以后缀单个`f`(常见于原版代码中用于标记浮点数),但目前未发现该符号具有实际功能影响。
## Operators ### 字符串
The complete precedence list, from first to last evaluated: - 字符串使用`\`JSON转义后为`\\`)作为某种转义符或其他功能。其具体功能尚不明确。已知后续两个字符会被传递给独立子解析器,但该子解析器遇到结束单引号`'`时无法正确退出。例如Molang字符串`"v.type = '\\x';"`是无效的。而单独存在的`'`通常会被视为字符串结束符,但在`\`后的两个字符中出现时会被允许。
- 字符串值(多数情况下)以浮点数形式进行增量表示。可以通过等式或比较运算符对单字符字符串进行比较,甚至可对单字符字符串内容进行"调整"。多字符字符串在此类操作中的行为尚不明确。
1. `()` and `[]` ## 运算符
运算符优先级列表(从高到低):
1. `()``[]`
2. `->` 2. `->`
3. `!` and `-` (unary negation) 3. `!` `-`(一元取反)
4. `*` and `/` 4. `*` `/`
5. `+` and `-` (binary subtraction) 5. `+` `-`(二元减法)
6. `<`, `<=`, `>`, and `>=` 6. `<`, `<=`, `>` `>=`
7. `==` and `!=` 7. `==` `!=`
8. `&&` 8. `&&`
9. `||` 9. `||`
10. `?` and `? :` 10. `?` `? :`
11. `??` 11. `??`
12. `=` 12. `=`
13. `return` 13. `return`
- Operators are considered from left to right for all operators except the conditionals. - 除条件运算符外,所有运算符均按从左到右顺序执行。
- Multiple `->` cannot be used in the same statement. - 同一语句中不可重复使用`->`运算符。
- Logical operators short-circuit. - 逻辑运算符具有短路特性。
## Statements ## 语句
- Assignments return the value assigned. You can therefore chain assignments if you need separate variables to work with from a single value, such as with `v.iterator_x = (v.iterator_z = math.random_integer(16, 32));`. - 赋值语句会返回被赋予的值。因此可以进行链式赋值(例如`v.iterator_x = (v.iterator_z = math.random_integer(16, 32));`)。
- The last statement inside a brace scope does not need to end with a `;`. - 大括号作用域内的最后一条语句无需以`;`结尾。
- Brace scopes can be used anywhere an expression can be used. `v.spawn_point ?? {v.target = false;};`, for example, would set `v.target` to `false` if `v.spawn_point` were not defined. - 大括号作用域可以在任何表达式可用的位置使用。例如`v.spawn_point ?? {v.target = false;};`会在`v.spawn_point`未定义时将`v.target`设为`false`
## Collections ## 集合类型
- Entity iterables (such as the result of `q.get_nearby_entities`) are their own "type". They are not compatible with subscripts. - 实体可迭代对象(如`q.get_nearby_entities`的结果)属于独立"类型",不可与下标运算符兼容使用。
- Arrays, likewise, are not compatible with entity iterable operations, such as `q.count`. - 数组类型同样无法与实体可迭代操作(如`q.count`)兼容使用。
- The result of array subscripts cannot directly be an argument to `+`, `-`, `*`, or `/` but may still be used directly as function parameters (even math functions) or with other operators. - 数组下标结果不可直接作为`+`, `-`, `*`, `/`的操作数,但可作为函数参数(包括数学函数)或与其他运算符配合使用。
## Evaluation ## 表达式求值
- `initialize` and `pre_animation` are lazily concatenated. Molang strings in these arrays must be syntactically valid independently, but the basic concatenation of all independent strings must also be a valid Molang input. - `initialize``pre_animation`数组中的语句采用延迟连接方式。这些数组中的每个Molang字符串必须独立语法有效同时所有字符串连接后也需构成有效的Molang输入。
## Limits ## 限制条件
- Molang showed no reasonable limits to any language functionality, aside from numeric size. Loop counts, string lengths, Molang input length, collection size, etc., were observed to hold in very unreasonable situations. - 除数值大小外未发现Molang存在合理的功能限制。在极端场景下仍可观察到循环计数、字符串长度、输入长度、集合大小等参数的正常运行。

View File

@@ -1,5 +1,5 @@
--- ---
title: Menu Categories title: 菜单分类
mentions: mentions:
- Warhead51707 - Warhead51707
- yanasakana - yanasakana
@@ -13,37 +13,39 @@ mentions:
- QuazChick - QuazChick
--- ---
Menu categories determine where items and blocks appear inside of the creative inventory and recipe book. # 菜单分类
- A `category` can be defined to place the item under a tab (such as construction). Click [here](#list-of-categories) for a list of valid categories. <!--@include: @/wiki/bedrock-wiki-mirror.md-->
- A `group` specifies which expandable group the item is placed into. If you use a custom value, a new expandable group won't be created, however items with the group will be placed next to each other in the creative inventory. Click [here](#list-of-groups) for a list of expandable groups. 菜单分类决定了物品和方块在创造模式物品栏和配方书中的显示位置。
- You can also set `is_hidden_in_commands` to true to remove this block/item from commands, such as `/give` and `/setblock`. - 通过定义`category`可将物品放置于特定标签页下(如"construction"建筑类)。点击[此处](#分类列表)查看有效分类列表。
If `menu_category` is omitted, the item will only be accessible through commands and won't appear in the creative inventory or recipe book. - `group`参数用于指定物品所在的可展开分组。使用自定义值时不会创建新分组,但相同分组的物品会在创造模式物品栏中相邻排列。点击[此处](#分组列表)查看可展开分组列表。
**NOTE:** The menu category of custom spawn eggs cannot be modified. You must instead create a custom item with the `minecraft:entity_placer` component. - 设置`is_hidden_in_commands`为true可让该物品/方块无法通过`/give``/setblock`等命令获取。
<CodeHeader></CodeHeader> 若省略`menu_category`参数,物品将只能通过命令获取,且不会出现在创造模式物品栏或配方书中。
```json **注意:** 自定义刷怪蛋的菜单分类不可修改,需使用`minecraft:entity_placer`组件创建自定义物品实现类似功能。
::: code-group
```json [菜单分类配置]
"menu_category": { "menu_category": {
"category": "construction", // Tab the item is placed under "category": "construction", // 物品所在的标签页
"group": "itemGroup.name.door", // Optional - Group the item is placed into "group": "itemGroup.name.door", // 可选 - 物品所在的展开分组
"is_hidden_in_commands": false // Optional - default is false (item is usable in commands) "is_hidden_in_commands": false // 可选 - 默认为false可通过命令使用
} }
``` ```
:::danger HIDDEN ITEMS INACCESSIBLE IN COMMANDS ([MCPE-177866](https://bugs.mojang.com/browse/MCPE-177866)) :::danger 命令中隐藏物品不可访问的问题 ([MCPE-177866](https://bugs.mojang.com/browse/MCPE-177866))
Currently, setting the category to "none" in a custom item (not block) prevents the item from being used in commands, overriding the "is_hidden_in_commands" option. This issue doesn't affect blocks. 当前版本中,将自定义物品(非方块)的category设为"none"会覆盖"is_hidden_in_commands"设置,导致无法通过命令使用该物品。此问题不影响方块类物品。
::: :::
## Block Example ## 方块示例
<CodeHeader>BP/blocks/balsa_wood.json</CodeHeader> ::: code-group
```json [BP/blocks/balsa_wood.json]
```json
{ {
"format_version": "1.20.50", "format_version": "1.20.50",
"minecraft:block": { "minecraft:block": {
@@ -51,18 +53,18 @@ Currently, setting the category to "none" in a custom item (not block) prevents
"identifier": "wiki:balsa_wood", "identifier": "wiki:balsa_wood",
"menu_category": { "menu_category": {
"category": "nature", "category": "nature",
"group": "itemGroup.name.wood" // Placed into an expandable group "group": "itemGroup.name.wood" // 归入可展开分组
} }
} }
} }
} }
``` ```
:::
## Item Example ## 物品示例
<CodeHeader>BP/items/dagger.json</CodeHeader> ::: code-group
```json [BP/items/dagger.json]
```json
{ {
"format_version": "1.20.50", "format_version": "1.20.50",
"minecraft:item": { "minecraft:item": {
@@ -70,111 +72,112 @@ Currently, setting the category to "none" in a custom item (not block) prevents
"identifier": "wiki:dagger", "identifier": "wiki:dagger",
"menu_category": { "menu_category": {
"category": "equipment", "category": "equipment",
"is_hidden_in_commands": true // Item cannot be used in commands "is_hidden_in_commands": true // 无法通过命令使用
} }
} }
} }
} }
``` ```
:::
## List of Categories ## 分类列表
_For use with `menu_category` parameter, `category`._ _用于`menu_category`参数中的`category`属性_
| Category | Description | | 分类名称 | 描述 |
| ------------ | -------------------------------------------------------- | | ------------ | ----------------------------------------- |
| construction | Added to the "Contruction" tab. | | construction | 显示在"建筑"标签页 |
| equipment | Added to the "Equipment" tab. | | equipment | 显示在"装备"标签页 |
| items | Added to the "Items" tab. | | items | 显示在"物品"标签页 |
| nature | Added to the "Nature" tab. | | nature | 显示在"自然"标签页 |
| none | Not added to a tab and only accessible through commands. | | none | 不显示在任何标签页,只能通过命令获取 |
## List of Groups ## 分组列表
_For use with the `menu_category` parameter, `group`._ _用于`menu_category`参数中的`group`属性_
<!-- page_dumper_start --> <!-- page_dumper_start -->
| Creative Categories: | | 创造模式分组: |
| --------------------------------- | | ----------------------------- |
| itemGroup.name.anvil | | itemGroup.name.anvil |
| itemGroup.name.arrow | | itemGroup.name.arrow |
| itemGroup.name.axe | | itemGroup.name.axe |
| itemGroup.name.banner | | itemGroup.name.banner |
| itemGroup.name.banner_pattern | | itemGroup.name.banner_pattern |
| itemGroup.name.bed | | itemGroup.name.bed |
| itemGroup.name.boat | | itemGroup.name.boat |
| itemGroup.name.boots | | itemGroup.name.boots |
| itemGroup.name.buttons | | itemGroup.name.buttons |
| itemGroup.name.candles | | itemGroup.name.candles |
| itemGroup.name.chalkboard | | itemGroup.name.chalkboard |
| itemGroup.name.chest | | itemGroup.name.chest |
| itemGroup.name.chestboat | | itemGroup.name.chestboat |
| itemGroup.name.chestplate | | itemGroup.name.chestplate |
| itemGroup.name.concrete | | itemGroup.name.concrete |
| itemGroup.name.concretePowder | | itemGroup.name.concretePowder |
| itemGroup.name.cookedFood | | itemGroup.name.cookedFood |
| itemGroup.name.copper | | itemGroup.name.copper |
| itemGroup.name.coral | | itemGroup.name.coral |
| itemGroup.name.coral_decorations | | itemGroup.name.coral_decorations |
| itemGroup.name.crop | | itemGroup.name.crop |
| itemGroup.name.door | | itemGroup.name.door |
| itemGroup.name.dye | | itemGroup.name.dye |
| itemGroup.name.enchantedBook | | itemGroup.name.enchantedBook |
| itemGroup.name.fence | | itemGroup.name.fence |
| itemGroup.name.fenceGate | | itemGroup.name.fenceGate |
| itemGroup.name.firework | | itemGroup.name.firework |
| itemGroup.name.fireworkStars | | itemGroup.name.fireworkStars |
| itemGroup.name.flower | | itemGroup.name.flower |
| itemGroup.name.glass | | itemGroup.name.glass |
| itemGroup.name.glassPane | | itemGroup.name.glassPane |
| itemGroup.name.glazedTerracotta | | itemGroup.name.glazedTerracotta |
| itemGroup.name.goatHorn | | itemGroup.name.goatHorn |
| itemGroup.name.grass | | itemGroup.name.grass |
| itemGroup.name.hanging_sign | | itemGroup.name.hanging_sign |
| itemGroup.name.helmet | | itemGroup.name.helmet |
| itemGroup.name.hoe | | itemGroup.name.hoe |
| itemGroup.name.horseArmor | | itemGroup.name.horseArmor |
| itemGroup.name.leaves | | itemGroup.name.leaves |
| itemGroup.name.leggings | | itemGroup.name.leggings |
| itemGroup.name.lingeringPotion | | itemGroup.name.lingeringPotion|
| itemGroup.name.log | | itemGroup.name.log |
| itemGroup.name.minecart | | itemGroup.name.minecart |
| itemGroup.name.miscFood | | itemGroup.name.miscFood |
| itemGroup.name.mobEgg | | itemGroup.name.mobEgg |
| itemGroup.name.monsterStoneEgg | | itemGroup.name.monsterStoneEgg|
| itemGroup.name.mushroom | | itemGroup.name.mushroom |
| itemGroup.name.netherWartBlock | | itemGroup.name.netherWartBlock|
| itemGroup.name.ore | | itemGroup.name.ore |
| itemGroup.name.permission | | itemGroup.name.permission |
| itemGroup.name.pickaxe | | itemGroup.name.pickaxe |
| itemGroup.name.planks | | itemGroup.name.planks |
| itemGroup.name.potion | | itemGroup.name.potion |
| itemGroup.name.potterySherds | | itemGroup.name.potterySherds |
| itemGroup.name.pressurePlate | | itemGroup.name.pressurePlate |
| itemGroup.name.rail | | itemGroup.name.rail |
| itemGroup.name.rawFood | | itemGroup.name.rawFood |
| itemGroup.name.record | | itemGroup.name.record |
| itemGroup.name.sandstone | | itemGroup.name.sandstone |
| itemGroup.name.sapling | | itemGroup.name.sapling |
| itemGroup.name.sculk | | itemGroup.name.sculk |
| itemGroup.name.seed | | itemGroup.name.seed |
| itemGroup.name.shovel | | itemGroup.name.shovel |
| itemGroup.name.shulkerBox | | itemGroup.name.shulkerBox |
| itemGroup.name.sign | | itemGroup.name.sign |
| itemGroup.name.skull | | itemGroup.name.skull |
| itemGroup.name.slab | | itemGroup.name.slab |
| itemGroup.name.smithing_templates | | itemGroup.name.smithing_templates |
| itemGroup.name.splashPotion | | itemGroup.name.splashPotion |
| itemGroup.name.stainedClay | | itemGroup.name.stainedClay |
| itemGroup.name.stairs | | itemGroup.name.stairs |
| itemGroup.name.stone | | itemGroup.name.stone |
| itemGroup.name.stoneBrick | | itemGroup.name.stoneBrick |
| itemGroup.name.sword | | itemGroup.name.sword |
| itemGroup.name.trapdoor | | itemGroup.name.trapdoor |
| itemGroup.name.walls | | itemGroup.name.walls |
| itemGroup.name.wood | | itemGroup.name.wood |
| itemGroup.name.wool | | itemGroup.name.wool |
| itemGroup.name.woolCarpet | | itemGroup.name.woolCarpet |
*Last updated for 1.20.10* *最后更新版本:1.20.10*
<!-- page_dumper_end --> <!-- page_dumper_end -->

View File

@@ -1,106 +1,113 @@
--- ---
title: File Types title: 文件类型
max_toc_level : 3 max_toc_level : 3
mentions: mentions:
- Ciosciaa - Ciosciaa
- SirLich - SirLich
--- ---
A number of file types exist for *Minecraft*, all for importing content. All *Minecraft* files are ZIP archives renamed to use a `mc…` extension. These archives can currently be divided into three sets: # 文件类型
- **Levels (`mcworld` and `mcproject`)**: level data and associated resources for worlds and projects <!--@include: @/wiki/bedrock-wiki-mirror.md-->
- **Assets (`mcpack` and `mctemplate`)**: cosmetics or supporting assets for worlds
- **Composites (`mcaddon` and `mceditoraddon)`**: used to import up to one world or project and any number of asset types
All file types for Minecraft can be opened as any file, launching Minecraft and importing the content. When packages are imported, they are automatically unpacked into their constituent files and directories. If it was not already open, most file types will launch Minecraft in normal mode; `mcproject` and `mceditoraddon` will instead launch Minecraft into Editor mode. *Minecraft* 存在多种文件类型,均用于导入内容。所有 *Minecraft* 文件本质上都是 ZIP 压缩包,通过重命名使用 `mc...` 扩展名。这些压缩包目前可分为三大类:
# Levels - **世界文件(`mcworld``mcproject`**:包含世界或项目的关卡数据及相关资源
Levels represent save data and resources for regular worlds and Editor projects. All levels, regardless of mode, are imported to `minecraftWorlds` in the `com.mojang` directory. - **资源文件(`mcpack``mctemplate`**:包含世界的装饰性素材或支持性资源
- **复合文件(`mcaddon``mceditoraddon`**:可同时包含最多一个世界/项目文件及任意数量的资源文件
Importing an exact duplicate of an existing saved level will create a duplicate saved level. Composite archives will only import one level if multiple are included, including across nested composite archives. 所有 *Minecraft* 文件类型均可通过常规文件打开方式启动游戏并导入内容。当资源包被导入时,会自动解压到对应的文件目录结构中。若游戏未处于运行状态,多数文件类型会以普通模式启动游戏;而 `mcproject``mceditoraddon` 则会直接进入编辑器模式。
## Worlds # 世界文件
世界文件代表普通世界与编辑器项目的存档数据及资源。所有世界文件无论模式,都会被导入到 `com.mojang` 目录下的 `minecraftWorlds` 文件夹中。
若导入与已有存档完全相同的世界文件,会生成重复存档。复合文件包中若包含多个世界文件(包括嵌套的复合文件),只会导入其中一个世界。
## 普通世界
`mcworld` `mcworld`
Archive encapsulating an individual world 单个世界的压缩存档包
World archives can be created a few different ways: 创建世界存档的几种方式:
- Zipping the *contents* of a world directory and renaming the extension from `zip` to `mcworld` - 将世界目录的**全部内容**打包为 ZIP 文件后,将扩展名改为 `mcworld`
- Using the "Export World" button on the Game settings screen for a world - 在游戏设置界面点击"导出世界"按钮
- In Editor mode, exporting the world from the File → Export as → Playable world menu option. The world will be saved to the `projectbackups` directory in the `com.mojang` folder. - 在编辑器模式中,通过 文件 → 导出为 → 可游玩世界 菜单选项导出。存档将保存在 `com.mojang` 文件夹的 `projectbackups` 目录中
- In Editor mode, running the `/project export world` command. The world will be saved to the `projectbackups` directory in the `com.mojang` folder. - 在编辑器模式中运行 `/project export world` 命令。存档将保存在 `com.mojang` 文件夹的 `projectbackups` 目录中
Importing a world package while *Minecraft* is launched in Editor mode will import the world as a project. The imported world will then be inaccessible outside Editor mode and will need to be re-exported as a world for playing. Editor extension packs bundled in a world archive will be retained on import outside Editor mode. 在编辑器模式下导入世界文件会将其作为项目导入。此时该世界将无法在编辑器模式之外访问,需重新导出为普通世界才能游玩。世界文件中包含的编辑器扩展包在非编辑器模式导入时会被保留。
## Projects ## 项目文件
`mcproject` `mcproject`
Archive encapsulating an individual Editor project 单个编辑器项目的压缩存档包
Project archives can be created two different ways: 创建项目存档的两种方式:
- Zipping the *contents* of a project directory and renaming the extension from `zip` to `mcproject`. - 将项目目录的**全部内容**打包为 ZIP 文件后,将扩展名改为 `mcproject`
- Using the "Export Project" button on the Game settings screen for a world - 在编辑器模式中运行 `/project export project` 命令。存档将保存在 `com.mojang` 文件夹的 `projectbackups` 目录中
- In Editor mode, running the `/project export project` command. The world will be saved to the `projectbackups` directory in the `com.mojang` folder.
If *Minecraft* is not open, launching a `mcproject` file will open Editor mode. Importing a `mcproject` will fail if *Minecraft* is open but not in Editor mode. 若游戏未运行,打开 `mcproject` 文件会直接进入编辑器模式。若游戏已运行但未处于编辑器模式,导入 `mcproject` 文件会失败。
# Assets # 资源文件
Asset archives represent a singular instance of a number of non-level contents: 资源文件代表各种非世界类内容的独立实例:
- 行为包
- 资源包
- 皮肤包
- 世界模板
- Behavior packs 所有资源文件都包含描述其内容的清单文件manifest。若资源清单的 UUID 和版本号与同类型现有资源完全一致,导入将会失败。注意行为包和资源包共享相同的 UUID/版本号命名空间。内置于世界、项目或模板中的行为包/资源包不会被视为重复资源。
- Resource packs
- Skin packs
- World templates
All asset archives include a manifest describing their contents. An asset archive will fail to import if its manifest UUID and version exactly matches an existing asset archive of the same type. Note that behavior and resource packs share the same UUID/version space. Behavior and resource packs self-contained within a world, project, or template will not count as duplicates for the sake of importing. 虽然 `mcpack``mctemplate` 功能相同,但建议遵循以下规范:
- 使用 `mcpack` 作为行为包、资源包、皮肤包
- 使用 `mctemplate` 作为世界模板
以便用户更直观地识别内容类型。复合文件中可包含任意数量的资源文件。
Both asset extensions, `mcpack` and `mctemplate`, appear to functionally behave the same. It's best practice to use `mcpack` for behavior, resource, and skin packs and `mctemplate` for world templates to make it more clear what's being installed. Any number of asset archives may be included in a composite archive. ## 资源包
## Packs
`mcpack` `mcpack`
Package representing an individual behavior pack, resource pack, skin pack, or world template. It's recommended only to use `mctemplate` for behavior packs, resource packs, or skin packs. 代表单个行为包、资源包、皮肤包或世界模板的压缩包。建议仅将 `mctemplate` 用于世界模板。
Packs are only created manually, by zipping the contents of a behavior pack, resource pack, or skin pack directory and renaming the extension from `zip` to `mcpack`. Behavior and resource packs are installed globally and do not conflict with matching behavior or resource packs installed in worlds, projects, or templates. 手动创建方式:
- 将行为包、资源包或皮肤包目录的全部内容打包为 ZIP 文件后,将扩展名改为 `mcpack`
行为包与资源包会全局安装,不会与世界/项目/模板中安装的同名资源冲突。
### Behavior Packs ### 行为包
Behavior packs are attached to servers to change or extend gameplay. Behavior packs are installed to the `behavior_packs` directory in the `com.mojang` folder. 行为包用于修改或扩展游戏玩法,安装在 `com.mojang` 目录下的 `behavior_packs` 文件夹中。
Development behavior packs must be placed in the `development_behavior_packs` directory under `com.mojang` manually. 开发中的行为包需手动放置到 `com.mojang` 下的 `development_behavior_packs` 目录。
### Resource Packs ### 资源包
Resource packs are attached to clients to affect sounds, visuals, etc. Resource packs are installed to the `resource_packs` directory in the `com.mojang` folder. 资源包用于修改客户端音效、视觉效果等,安装在 `com.mojang` 目录下的 `resource_packs` 文件夹中。
Development resource packs must be placed in the `development_resource_packs` directory under `com.mojang` manually. 开发中的资源包需手动放置到 `com.mojang` 下的 `development_resource_packs` 目录。
### Skin Packs ### 皮肤包
Skin packs are client-only packs for custom skins. Skin packs are installed to the `skin_packs` directory in the `com.mojang` folder. 皮肤包是仅限客户端的自定义皮肤资源,安装在 `com.mojang` 目录下的 `skin_packs` 文件夹中。
Development skin packs must be placed in the `development_skin_packs` directory under `com.mojang` manually, but this feature appears non-functional. 开发中的皮肤包需手动放置到 `com.mojang` 下的 `development_skin_packs` 目录,但此功能目前似乎不可用。
## World Templates ## 世界模板
`mctemplate` `mctemplate`
Package representing an individual behavior pack, resource pack, skin pack, or world template. It's recommended only to use `mctemplate` for world templates. 代表单个行为包、资源包、皮肤包或世界模板的压缩包。建议仅将 `mctemplate` 用于世界模板。
World templates are installed to the `world_templates` directory under `com.mojang`. World templates can be constructed in a few different ways: 世界模板安装在 `com.mojang` 目录下的 `world_templates` 文件夹中。创建方式:
- Zipping the *contents* of a world directory, adding a world template manifest, and renaming the extension from `zip` to `mctemplate` - 将世界目录的**全部内容**打包为 ZIP 文件,添加模板清单文件后,将扩展名改为 `mctemplate`
- In Editor mode, using the "Export Template" button on the Game settings screen for a world - 在编辑器模式中点击游戏设置界面的"导出模板"按钮
- In Editor mode, running the `/project export template` command. The world will be saved to the `projectbackups` directory in the `com.mojang` folder. - 在编辑器模式中运行 `/project export template` 命令。存档将保存在 `com.mojang` 文件夹的 `projectbackups` 目录中
# Composites # 复合文件
Composite archives are used to import up to *one* level archive and any number or combination of asset archives in a single import action. In general, contents to a composite must be packaged. Directories can also be given *on the top level* of a composite archive for importing asset types (behavior packs, resource packs, skin packs, and world templates) without needing to pre-package them. Nested sub-directories for organization may not be used. 复合文件用于在一次导入操作中同时导入**最多一个**世界文件及任意数量的资源文件。通常复合文件中的内容需要预先打包,但资源类型(行为包/资源包/皮肤包/世界模板)的原始目录也可直接放在复合文件顶层(不可使用嵌套子目录)。
Composite contents are treated as usual. For example, importing a `mcaddon` contianing a `mcworld` while in Editor mode will import the world as a project. 复合文件的内容按常规方式处理。例如在编辑器模式导入包含 `mcworld``mcaddon` 时,世界文件会作为项目导入。
Composite archives may also contain any number or nesting of other composite archives, even across *Minecraft* modes. Nested composite archives cannot be used to get around the singular world import restriction. 复合文件可包含任意数量或层级的其他复合文件(跨模式也可)。但嵌套复合文件不能突破单世界导入限制。
Composites can only be constructed manually by zipping archives and asset types. 复合文件只能通过手动打包现有文件/目录创建。
## Add-Ons ## 附加包
`mcaddon` `mcaddon`
Generic composite content archive 通用复合内容存档
Importing a `mcaddon` package while *Minecraft* is launched in Editor mode will import any contained world as a project. The imported world will then be inaccessible outside Editor mode and will need to be re-exported as a world for playing. Asset types are imported as usual. 在编辑器模式导入 `mcaddon` 时,包含的世界文件会作为项目导入。此时该世界将无法在编辑器模式之外访问,需重新导出为普通世界才能游玩。其他资源类型会正常导入。
## Editor Add-Ons ## 编辑器附加包
`mceditoraddon` `mceditoraddon`
Composite content archive for Editor mode 专用于编辑器模式的复合内容存档
If *Minecraft* is not open, launching a `mcproject` file will open Editor mode. Importing a `mcproject` will fail if *Minecraft* is open but not in Editor mode. 若游戏未运行,打开 `mcproject` 文件会直接进入编辑器模式。若游戏已运行但未处于编辑器模式,导入 `mcproject` 文件会失败。

View File

@@ -1,92 +1,95 @@
--- ---
title: Fog IDs title: 雾效ID
mentions: mentions:
- SirLich - SirLich
- MedicalJewel105 - MedicalJewel105
- TheItsNameless - TheItsNameless
--- ---
## By Element X # 雾效ID
| ID | Note | <!--@include: @/wiki/bedrock-wiki-mirror.md-->
## 按元素X分类
| ID | 说明 |
| ---------------------------------------------- | -------------------------------------------------------------------------------- | | ---------------------------------------------- | -------------------------------------------------------------------------------- |
| minecraft:fog_bamboo_jungle | Fog used in the bamboo jungle. | | minecraft:fog_bamboo_jungle | 竹林生物群系使用的雾效 |
| minecraft:fog_bamboo_jungle_hills | Fog used in the bamboo jungle hills. | | minecraft:fog_bamboo_jungle_hills | 竹林丘陵生物群系使用的雾效 |
| minecraft:fog_basalt_deltas | Fog used in the basalt deltas. Adds a gray-red tint to the edge of the sky | | minecraft:fog_basalt_deltas | 玄武岩三角洲生物群系使用的雾效,为天空边缘添加灰红色调 |
| minecraft:fog_beach | Fog used in the beach biome. | | minecraft:fog_beach | 沙滩生物群系使用的雾效 |
| minecraft:fog_birch_forest | Fog used in the birch forest | | minecraft:fog_birch_forest | 桦木林生物群系使用的雾效 |
| minecraft:fog_birch_forest_hills | Fog used in the birch forest hills biome. | | minecraft:fog_birch_forest_hills | 桦木林丘陵生物群系使用的雾效 |
| minecraft:fog_cold_beach | Fog used in the cold beach biome. | | minecraft:fog_cold_beach | 寒冷沙滩生物群系使用的雾效 |
| minecraft:fog_cold_ocean | Fog used in the cold ocean biome. | | minecraft:fog_cold_ocean | 寒冷海洋生物群系使用的雾效 |
| minecraft:fog_cold_taiga | Fog used in the cold taiga biome. | | minecraft:fog_cold_taiga | 寒冷针叶林生物群系使用的雾效 |
| minecraft:fog_cold_taiga_hills | Fog used in the cold taiga hills biome. | | minecraft:fog_cold_taiga_hills | 寒冷针叶林丘陵生物群系使用的雾效 |
| minecraft:fog_cold_taiga_mutated | Fog used in the mutated cold taiga biome. | | minecraft:fog_cold_taiga_mutated | 突变寒冷针叶林生物群系使用的雾效 |
| minecraft:fog_crimson_forest | Fog used in the crimson forest biome. Adds a red tint to the edge of the sky | | minecraft:fog_crimson_forest | 绯红森林生物群系使用的雾效,为天空边缘添加红色调 |
| minecraft:fog_deep_cold_ocean | Fog used in the deep cold ocean biome. | | minecraft:fog_deep_cold_ocean | 深层寒冷海洋生物群系使用的雾效 |
| minecraft:fog_deep_frozen_ocean | Fog used in the deep frozen ocean biome. | | minecraft:fog_deep_frozen_ocean | 深层冰冻海洋生物群系使用的雾效 |
| minecraft:fog_deep_lukewarm_ocean | Fog used in the deep lukewarm ocean biome. | | minecraft:fog_deep_lukewarm_ocean | 深层温水海洋生物群系使用的雾效 |
| minecraft:fog_deep_ocean | Fog used in the deep ocean biome. | | minecraft:fog_deep_ocean | 深层海洋生物群系使用的雾效 |
| minecraft:fog_deep_warm_ocean | Fog used in the deep warm ocean biome. | | minecraft:fog_deep_warm_ocean | 深层温暖海洋生物群系使用的雾效 |
| minecraft:fog_default | Default fog used in the game. | | minecraft:fog_default | 游戏默认雾效 |
| minecraft:fog_desert | Fog used in the desert biome. | | minecraft:fog_desert | 沙漠生物群系使用的雾效 |
| minecraft:fog_desert_hills | Fog used in the desert hills biome. | | minecraft:fog_desert_hills | 沙漠丘陵生物群系使用的雾效 |
| minecraft:fog_extreme_hills | Fog used in the extreme hills biome. | | minecraft:fog_extreme_hills | 峭壁生物群系使用的雾效 |
| minecraft:fog_extreme_hills_edge | Fog used in the extreme hills edge biome. | | minecraft:fog_extreme_hills_edge | 峭壁边缘生物群系使用的雾效 |
| minecraft:fog_extreme_hills_mutated | Fog used in the mutated extreme hills biome. | | minecraft:fog_extreme_hills_mutated | 突变峭壁生物群系使用的雾效 |
| minecraft:fog_extreme_hills_plus_trees | Fog used in the extreme hills with trees biome. | | minecraft:fog_extreme_hills_plus_trees | 带树林的峭壁生物群系使用的雾效 |
| minecraft:fog_extreme_hills_plus_trees_mutated | Fog used in the mutated extreme hills with trees biome. | | minecraft:fog_extreme_hills_plus_trees_mutated | 突变带树林的峭壁生物群系使用的雾效 |
| minecraft:fog_flower_forest | Fog used in the flower forest biome. | | minecraft:fog_flower_forest | 繁花森林生物群系使用的雾效 |
| minecraft:fog_forest | Fog used in the forest biome. | | minecraft:fog_forest | 森林生物群系使用的雾效 |
| minecraft:fog_forest_hills | Fog used in the forest hills biome. | | minecraft:fog_forest_hills | 森林丘陵生物群系使用的雾效 |
| minecraft:fog_frozen_ocean | Fog used in the frozen ocean biome. | | minecraft:fog_frozen_ocean | 冰冻海洋生物群系使用的雾效 |
| minecraft:fog_frozen_river | Fog used in the frozen river biome. | | minecraft:fog_frozen_river | 冰冻河流生物群系使用的雾效 |
| minecraft:fog_hell | Fog used in the nether wastes biome. Adds a red tint to the edge of the sky | | minecraft:fog_hell | 下界荒地生物群系使用的雾效,为天空边缘添加红色调 |
| minecraft:fog_ice_mountains | Fog used in the ice mountains biome. | | minecraft:fog_ice_mountains | 冰封山脉生物群系使用的雾效 |
| minecraft:fog_ice_plains | Fog used in the ice plains biome. | | minecraft:fog_ice_plains | 冰原生物群系使用的雾效 |
| minecraft:fog_ice_plains_spikes | Fog used in the ice spikes biome. | | minecraft:fog_ice_plains_spikes | 冰刺平原生物群系使用的雾效 |
| minecraft:fog_jungle | Fog used in the jungle biome. | | minecraft:fog_jungle | 丛林生物群系使用的雾效 |
| minecraft:fog_jungle_edge | Fog used in the jungle edge biome. | | minecraft:fog_jungle_edge | 丛林边缘生物群系使用的雾效 |
| minecraft:fog_jungle_hills | Fog used in the jungle hills biome. | | minecraft:fog_jungle_hills | 丛林丘陵生物群系使用的雾效 |
| minecraft:fog_jungle_mutated | Fog used in the mutated jungle biome. | | minecraft:fog_jungle_mutated | 突变丛林生物群系使用的雾效 |
| minecraft:fog_lukewarm_ocean | Fog used in the lukewarm ocean biome. | | minecraft:fog_lukewarm_ocean | 温水海洋生物群系使用的雾效 |
| minecraft:fog_mega_spruce_taiga | Fog used in the mega spruce taiga biome. | | minecraft:fog_mega_spruce_taiga | 巨型云杉针叶林生物群系使用的雾效 |
| minecraft:fog_mega_spruce_taiga_mutated | Fog used in the mega spruce mutated taiga biome. | | minecraft:fog_mega_spruce_taiga_mutated | 突变巨型云杉针叶林生物群系使用的雾效 |
| minecraft:fog_mega_taiga | Fog used in the mega taiga biome. | | minecraft:fog_mega_taiga | 巨型针叶林生物群系使用的雾效 |
| minecraft:fog_mega_taiga_hills | Fog used in the mega taiga hills biome. | | minecraft:fog_mega_taiga_hills | 巨型针叶林丘陵生物群系使用的雾效 |
| minecraft:fog_mega_taiga_mutated | Fog used in the mega mutated taiga biome. | | minecraft:fog_mega_taiga_mutated | 突变巨型针叶林生物群系使用的雾效 |
| minecraft:fog_mesa | Fog used in the mesa biome. | | minecraft:fog_mesa | 平顶山生物群系使用的雾效 |
| minecraft:fog_mesa_bryce | Fog used in the mesa bryce biome. | | minecraft:fog_mesa_bryce | 布莱斯平顶山生物群系使用的雾效 |
| minecraft:fog_mesa_mutated | Fog used in the mutated mesa biome. | | minecraft:fog_mesa_mutated | 突变平顶山生物群系使用的雾效 |
| minecraft:fog_mesa_plateau | Fog used in the mesa plateau biome. | | minecraft:fog_mesa_plateau | 平顶山高原生物群系使用的雾效 |
| minecraft:fog_mesa_plateau_stone | Fog used in the stone mesa plateau biome. | | minecraft:fog_mesa_plateau_stone | 石质平顶山高原生物群系使用的雾效 |
| minecraft:fog_mushroom_island | Fog used in the mushroom island biome. | | minecraft:fog_mushroom_island | 蘑菇岛生物群系使用的雾效 |
| minecraft:fog_mushroom_island_shore | Fog used in the mushroom island shore biome. | | minecraft:fog_mushroom_island_shore | 蘑菇岛海岸生物群系使用的雾效 |
| minecraft:fog_ocean | Fog used in the ocean biome. | | minecraft:fog_ocean | 海洋生物群系使用的雾效 |
| minecraft:fog_plains | Fog used in the plains biome. | | minecraft:fog_plains | 平原生物群系使用的雾效 |
| minecraft:fog_river | Fog used in the river biome. | | minecraft:fog_river | 河流生物群系使用的雾效 |
| minecraft:fog_roofed_forest | Fog used in the roofed forest biome. | | minecraft:fog_roofed_forest | 黑森林生物群系使用的雾效 |
| minecraft:fog_savanna | Fog used in the savanna biome. | | minecraft:fog_savanna | 热带草原生物群系使用的雾效 |
| minecraft:fog_savanna_mutated | Fog used in the mutated savanna biome. | | minecraft:fog_savanna_mutated | 突变热带草原生物群系使用的雾效 |
| minecraft:fog_savanna_plateau | Fog used in the savanna plateau biome. | | minecraft:fog_savanna_plateau | 热带高原生物群系使用的雾效 |
| minecraft:fog_soulsand_valley | Fog used in the soulsand valley biome. Adds a dark green tint to the sky | | minecraft:fog_soulsand_valley | 灵魂沙峡谷生物群系使用的雾效,为天空边缘添加深绿色调 |
| minecraft:fog_stone_beach | Fog used in the stone beach biome. | | minecraft:fog_stone_beach | 石滩生物群系使用的雾效 |
| minecraft:fog_sunflower_plains | Fog used in the sunflower plains biome. | | minecraft:fog_sunflower_plains | 向日葵平原生物群系使用的雾效 |
| minecraft:fog_swampland | Fog used in the swamp biome. | | minecraft:fog_swampland | 沼泽生物群系使用的雾效 |
| minecraft:fog_swampland_mutated | Fog used in the mutated swamp biome. | | minecraft:fog_swampland_mutated | 突变沼泽生物群系使用的雾效 |
| minecraft:fog_taiga | Fog used in the taiga biome. | | minecraft:fog_taiga | 针叶林生物群系使用的雾效 |
| minecraft:fog_taiga_hills | Fog used in the taiga hills biome. | | minecraft:fog_taiga_hills | 针叶林丘陵生物群系使用的雾效 |
| minecraft:fog_taiga_mutated | Fog used in the mutated taiga hills biome. | | minecraft:fog_taiga_mutated | 突变针叶林丘陵生物群系使用的雾效 |
| minecraft:fog_the_end | Fog used in the end biome. Adds a black tint to the edge of the sky | | minecraft:fog_the_end | 末地生物群系使用的雾效,为天空边缘添加黑色调 |
| minecraft:fog_warm_ocean | Fog used in the warm ocean biome. | | minecraft:fog_warm_ocean | 温暖海洋生物群系使用的雾效 |
| minecraft:fog_warped_forest | Fog used in the warped forest biome. Adds a dark red tint to the edge of the sky | | minecraft:fog_warped_forest | 诡异森林生物群系使用的雾效,为天空边缘添加深红色调 |
[Original Credit](https://www.youtube.com/watch?time_continue=52&v=SA79ulIgypg&feature=emb_logo) [原始来源](https://www.youtube.com/watch?time_continue=52&v=SA79ulIgypg&feature=emb_logo)
## 自动生成列表
## Auto-generated
<!-- page_dumper_start --> <!-- page_dumper_start -->
| ID | Biome used in | | ID | 适用的生物群系 |
| ---------------------------------------------- | -------------------------------- | | ---------------------------------------------- | -------------------------------- |
| minecraft:fog_bamboo_jungle | bamboo_jungle | | minecraft:fog_bamboo_jungle | bamboo_jungle |
| minecraft:fog_bamboo_jungle_hills | bamboo_jungle_hills | | minecraft:fog_bamboo_jungle_hills | bamboo_jungle_hills |
@@ -159,5 +162,5 @@ mentions:
| minecraft:fog_the_end | the_end | | minecraft:fog_the_end | the_end |
| minecraft:fog_warm_ocean | warm_ocean | | minecraft:fog_warm_ocean | warm_ocean |
| minecraft:fog_warped_forest | warped_forest | | minecraft:fog_warped_forest | warped_forest |
*Last updated for 1.20.10* *最后更新于1.20.10版本*
<!-- page_dumper_end --> <!-- page_dumper_end -->

View File

@@ -1,3 +1,3 @@
--- ---
title: Documentation title: 文档
--- ---

View File

@@ -1,8 +1,8 @@
--- ---
title: Vanilla Materials title: 原版材质
show_toc: false show_toc: false
tags: tags:
- expert - 专家
mentions: mentions:
- SirLich - SirLich
- Luthorius - Luthorius
@@ -11,15 +11,19 @@ mentions:
- ThomasOrs - ThomasOrs
--- ---
# 原版材质
<!--@include: @/wiki/bedrock-wiki-mirror.md-->
:::warning :::warning
Materials are not for the faint of heart. Be prepared for potential crashes, content log errors, and long loading times. 材质系统不适合心理承受能力较弱者。请做好应对潜在崩溃、内容日志错误和漫长加载时间的准备。
::: :::
Materials are extremely useful for making entities more unique. You can make new ones for your addons, or use pre-existing vanilla materials. 材质在使实体更具独特性方面极为有用。您既可以为附加包创建新材质,也可以使用现有的原版材质。
You can learn more about creating materials [here](/visuals/materials). 您可以通过[此链接](/wiki/visuals/materials)了解更多关于材质创建的内容。
## List of Vanilla Materials ## 原版材质列表
| Vanilla_Material | | Vanilla_Material |
| --------------------------------------------------------------------------------------- | | --------------------------------------------------------------------------------------- |
@@ -81,339 +85,264 @@ You can learn more about creating materials [here](/visuals/materials).
| [opaque_block_color](#opaque-block-color) | | [opaque_block_color](#opaque-block-color) |
| [opaque_block_color_uv2](#opaque-block-color-uv2) | | [opaque_block_color_uv2](#opaque-block-color-uv2) |
## Properties ## 材质属性
Materials can have a range of different properties which affect their appearance, including: 材质可具备多种影响外观的属性,包括:
### Backface-Culling ### 背面剔除(Backface-Culling
使模型的内表面不被渲染。
This makes the inside faces of models **not** render. ### Alpha通道
启用半透明效果使用纹理的Alpha通道。
### Alpha Channel ### 自发光Emissive
使纹理不受暗光影响呈现发光效果。若使用Alpha通道每个像素的发光强度与其透明度成正比。
Enables analogue translucency, usage of the alpha channel of textures. ### 固定透明度Set Translucency
无论其他属性如何,始终以预设透明度完全渲染。
### Emissive ### 纹理混合Texture Blending
当存在多个纹理时,可根据纹理通过某种滤镜改变实体外观。
Causes the texture to not be affected by dim lighting, and appear to glow. If there is usage of the alpha channel, the emissivity is in direct proportion to how transparent each individual pixel is. ## 材质细节说明
### Set Translucency 以下是各材质的具体说明及已知属性。材质名称仅作功能提示,部分材质可能表现不稳定或存在未记录的用法,以下信息仅包含已验证内容:
Regardless of other properties, is always completely rendered at a pre-determined translucency.
### Texture Blending
When multiple textures are present, may use a filter of sorts to change the entities appearance, based on the textures.
## Details on the Materials
The following is a last of each material, along with general known properties. The names are vague pointers to what each will do, some may act rather unpredictably, or have undocumented usages, so this only is what's certain for each:
:::warning :::warning
The following section has currently **only** been tested for with single textures. Take it all with a pinch of salt. It is highly recommended to experiment with the materials yourself. 以下内容目前**仅针对单纹理**进行过测试,请谨慎参考。强烈建议自行实验材质效果。
::: :::
### alpha_block ### alpha_block
- 背面剔除
- Backface-culling - 完全不透明
- Completely Opaque
### alpha_block_color ### alpha_block_color
- 背面剔除
- Backface-Culling - 透明度处理为半透明
- Translucencies as Transparent
### banner ### banner
在透明物体后方渲染时表现不稳定
Inconsistently renders objects with transparency behind. - 无特殊属性
- N/A
### banner_pole ### banner_pole
在透明物体后方渲染时表现不稳定
Inconsistently renders objects with transparency behind. - 背面剔除
- 透明效果
- Backface-Culling
- Transparency
### beacon_beam ### beacon_beam
- 完全不透明
- Completely Opaque
### beacon_beam_transparent ### beacon_beam_transparent
特性特殊:后方粒子会渲染在前方,呈现"正面剔除"效果
This one is rather different. Particles that are behind it are rendered in front, and it appears to have "Frontface-Culling". - Alpha通道
- Alpha Channel
### charged_creeper ### charged_creeper
在透明物体后方渲染时表现不稳定
Inconsistently renders objects with transparency behind. - 自发光
- 固定透明度
- Emissive
- Set Translucency
### conduit_wind ### conduit_wind
- 透明效果
- Transparency - 透明度处理为半透明
- Translucency as Transparency
### entity ### entity
- 完全不透明
- Completely Opaque - 背面剔除
- Backface Culling
### entity_alphablend ### entity_alphablend
在透明物体后方渲染时表现不稳定
Inconsistently renders objects with transparency behind. - 背面剔除
- Alpha通道
- Backface-Culling
- Alpha Channel
### entity_alphablend_nocolorentity_static ### entity_alphablend_nocolorentity_static
- 未知属性
- Unknown - 可能导致崩溃
- Potential Crash
### entity_alphatest ### entity_alphatest
- 透明效果
- Transparency - 透明度处理为半透明
- Translucency as Transparency
### entity_alphatest_change_color ### entity_alphatest_change_color
- 透明效果
- Transparency - 透明度处理为不透明
- Translucency as Opaque
### entity_alphatest_change_color_glint ### entity_alphatest_change_color_glint
- 未知属性
- Unknown
### entity_alphatest_glint ### entity_alphatest_glint
- 未知属性
- Unknown
### entity_alphatest_glint_item ### entity_alphatest_glint_item
- 未知属性
- Unknown
### entity_alphatest_multicolor_tint ### entity_alphatest_multicolor_tint
- 灰度处理
- Greyscale - 背面剔除
- Backface-Culling - 透明效果
- Transparency - 透明度处理为不透明
- Translucency as Opaque
### entity_beam ### entity_beam
- 透明效果
- Transparency - 透明度处理为半透明
- Translucency as Transparency
### entity_beam_additive ### entity_beam_additive
粒子始终渲染在最上层
Particles always render on top - 透明效果
- 自发光
- Transparency - 背面剔除
- Emissive - 固定透明度
- Backface-Culling
- Set Translucency
### entity_change_color ### entity_change_color
- 完全不透明
- Completely Opaque
### entity_change_color_glint ### entity_change_color_glint
- 未知属性
- Unknown
### entity_custom ### entity_custom
在透明物体后方渲染时表现不稳定
Inconsistently renders objects with transparency behind. - 背面剔除
- Alpha通道
- Backface-Culling
- Alpha Channel
### entity_dissolve_layer0 ### entity_dissolve_layer0
在透明物体后方渲染时表现不稳定
Inconsistently renders objects with transparency behind. - 未知属性
- Unknown
### entity_dissolve_layer1 ### entity_dissolve_layer1
- 未知属性
- Unknown
### entity_emissive ### entity_emissive
- 自发光
- Emissive - 完全不透明
- Completely Opaque - 背面剔除
- Backface-Culling
### entity_emissive_alpha ### entity_emissive_alpha
- 自发光
- Emissive - Alpha通道
- Alpha Channel - 透明效果
- Transparency
### entity_emissive_alpha_one_sided ### entity_emissive_alpha_one_sided
- 自发光
- Emissive - Alpha通道
- Alpha Channel - 透明效果
- Transparency - 背面剔除
- Backface-Culling
### entity_flat_color_line ### entity_flat_color_line
- 背面剔除
- Backface-Culling - 完全不透明
- Completely Opaque
### entity_glint ### entity_glint
- 未知属性
- Unknown
### entity_lead_base ### entity_lead_base
在透明物体后方渲染时表现不稳定
Inconsistently renders objects with transparency behind. - Alpha通道
- Alpha Channel
### entity_loyalty_rope ### entity_loyalty_rope
- 未知属性
- Unknown
### entity_multitexture ### entity_multitexture
- 未知属性
- Unknown
### entity_multitexture_alpha_test ### entity_multitexture_alpha_test
- 未知属性
- Unknown
### entity_multitexture_alpha_test_color_mask ### entity_multitexture_alpha_test_color_mask
- 未知属性
- Unknown
### entity_multitexture_color_mask ### entity_multitexture_color_mask
- 未知属性
- Unknown
### entity_multitexture_masked ### entity_multitexture_masked
- 未知属性
- Unknown
### entity_multitexture_multiplicative_blend ### entity_multitexture_multiplicative_blend
- 未知属性
- Unknown
### entity_nocull ### entity_nocull
- 完全不透明
- Completely Opaque
### guardian_ghost ### guardian_ghost
在透明物体后方渲染时表现不稳定
Inconsistently renders objects with transparency behind. - 背面剔除
- Alpha通道
- Backface-Culling
- Alpha Channel
### item_in_hand ### item_in_hand
- 完全不透明
- Completely Opaque - 背面剔除
- Backface-Culling
### item_in_hand_entity_alphatest ### item_in_hand_entity_alphatest
- 透明效果
- Transparency - 根据透明度等级决定是否透明
- Translucency into either Opaque or Transparent depends on level.
### item_in_hand_entity_alphatest_color ### item_in_hand_entity_alphatest_color
- 透明效果
- Transparency - 根据透明度等级决定是否透明
- Translucency into either Opaque or Transparent depends on level.
### item_in_hand_glint ### item_in_hand_glint
- 未知属性
- Unknown
### item_in_hand_multicolor_tint ### item_in_hand_multicolor_tint
- 灰度处理
- Greyscale - 完全不透明
- Completely Opaque - 背面剔除
- Backface-Culling
### map ### map
- 透明效果
- Transparency - 根据透明度等级决定是否透明
- Translucency into either Opaque or Transparent depends on level.
### map_decoration ### map_decoration
- 背面剔除
- Backface-Culling - 透明效果
- Transparency - 根据透明度等级决定是否透明
- Translucency into either Opaque or Transparent depends on level.
### map_marker ### map_marker
- 背面剔除
- Backface-Culling - 透明效果
- Transparency - 根据透明度等级决定是否透明
- Translucency into either Opaque or Transparent depends on level. - 可能导致崩溃
- Potential Crash
### moving_block ### moving_block
- 完全不透明
- Completely Opaque - 背面剔除
- Backface-Culling
### moving_block_alpha ### moving_block_alpha
- 背面剔除
- Backface-Culling - 透明效果
- Transparency - 根据透明度等级决定是否透明
- Translucency into either Opaque or Transparent depends on level.
### moving_block_alpha_seasons ### moving_block_alpha_seasons
- 根据透明度等级决定是否透明
- Translucency into either Opaque or Transparent depends on level. - 透明效果
- Transparency
### moving_block_alpha_single_side ### moving_block_alpha_single_side
- 背面剔除
- Backface-Culling - 透明效果
- Transparency - 根据透明度等级决定是否透明
- Translucency into either Opaque or Transparent depends on level.
### moving_block_blend ### moving_block_blend
在透明物体后方渲染时表现不稳定
Inconsistently renders objects with transparency behind. - 背面剔除
- Alpha通道
- Backface-Culling
- Alpha Channel
### moving_block_double_side ### moving_block_double_side
- 完全不透明
- Completely Opaque
### moving_block_seasons ### moving_block_seasons
- 完全不透明
- Completely Opaque - 背面剔除
- Backface-Culling
### opaque_block ### opaque_block
- 完全不透明
- Completely Opaque - 背面剔除
- Backface-Culling
### opaque_block_color ### opaque_block_color
- 完全不透明
- Completely Opaque - 背面剔除
- Backface-Culling
### opaque_block_color_uv2 ### opaque_block_color_uv2
- 完全不透明
- Completely Opaque - 背面剔除
- Backface-Culling
:::warning :::warning
Please note, that these have also only been tested using a RenderDragon platform. Non-RenderDragon visuals may differ. 请注意以上测试结果均基于RenderDragon渲染平台。非RenderDragon的视觉效果可能存在差异。
::: :::

View File

@@ -1,5 +1,5 @@
--- ---
title: Pack Folder Structure title: 包文件夹结构
show_toc: false show_toc: false
mentions: mentions:
- SirLich - SirLich
@@ -12,6 +12,10 @@ mentions:
- SmokeyStack - SmokeyStack
--- ---
# 包文件夹结构
<!--@include: @/wiki/bedrock-wiki-mirror.md-->
<FolderView :paths="[ <FolderView :paths="[
'BP/manifest.json', 'BP/manifest.json',
'BP/pack_icon.png', 'BP/pack_icon.png',
@@ -32,7 +36,7 @@ mentions:
'BP/scripts/exampleScript.js', 'BP/scripts/exampleScript.js',
'BP/spawn_rules/example.spawn.json', 'BP/spawn_rules/example.spawn.json',
'BP/texts/languages.json', 'BP/texts/languages.json',
'BP/texts/\*.lang', 'BP/texts/*.lang',
'BP/trading/example.trade.json', 'BP/trading/example.trade.json',
'BP/trading/economy_trades/example.trade.json', 'BP/trading/economy_trades/example.trade.json',
'BP/structures/example.mcstructure', 'BP/structures/example.mcstructure',
@@ -92,9 +96,9 @@ mentions:
'RP/texts/zh_TW.lang', 'RP/texts/zh_TW.lang',
'RP/texts/zh_TW.lang', 'RP/texts/zh_TW.lang',
'RP/texts/ja_JP/font/glyph_2E.png', 'RP/texts/ja_JP/font/glyph_2E.png',
'RP/texts/ja_JP/font/\*.png', 'RP/texts/ja_JP/font/*.png',
'RP/texts/zh_TW/font/glyph_2E.png', 'RP/texts/zh_TW/font/glyph_2E.png',
'RP/texts/zh_TW/font/\*.png', 'RP/texts/zh_TW/font/*.png',
'RP/textures/item_texture.json', 'RP/textures/item_texture.json',
'RP/textures/terrain_texture.json', 'RP/textures/terrain_texture.json',
'RP/textures/flipbook_textures.json', 'RP/textures/flipbook_textures.json',
@@ -109,5 +113,5 @@ mentions:
'RP/textures/entity/example.png', 'RP/textures/entity/example.png',
'RP/textures/items/example.png', 'RP/textures/items/example.png',
'RP/textures/particle/example.png', 'RP/textures/particle/example.png',
'RP/ui/\*.json' 'RP/ui/*.json'
]"></FolderView> ]"></FolderView>

View File

@@ -1,5 +1,5 @@
--- ---
title: Projectiles title: 投射物
mentions: mentions:
- SirLich - SirLich
- stirante - stirante
@@ -9,248 +9,250 @@ mentions:
- ThomasOrs - ThomasOrs
--- ---
## Overview # 投射物
This page intends to document all different fields you can use inside `minecraft:projectile` entity behavior component. <!--@include: @/wiki/bedrock-wiki-mirror.md-->
## 概述
本文档旨在记录`minecraft:projectile`实体行为组件中可使用的所有字段。
:::warning :::warning
_Disclaimer: this component has been mostly documented based on projectiles found in the game or reverse engineering the game._ _免责声明:该组件的文档主要基于游戏中存在的投射物或通过逆向工程获得。_
_This information was last tested on **1.18.2**._ _最后测试版本为 **1.18.2**_
::: :::
| Name | Type | Default Value | Description | | 字段名称 | 类型 | 默认值 | 描述 |
| ------------------------- | ---------------- | ------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | | ------------------------- | ----------------- | ------------- | -------------------------------------------------------------------------------------------------------------------------------------- |
| anchor | Integer | | | | anchor | 整数 | | |
| angle_offset | Decimal | 0 | Determines the angle at which the projectile is thrown | | angle_offset | 小数 | 0 | 决定投射物被抛射时的角度 |
| catch_fire | Boolean | false | If true, the entity hit will be set on fire | | catch_fire | 布尔值 | false | 若为true,被击中的实体将被点燃 |
| crit_particle_on_hurt | Boolean | false | If true, the projectile will produce critical hit particles when it happens | | crit_particle_on_hurt | 布尔值 | false | 若为true,投射物在造成暴击时会产生特殊粒子效果 |
| destroy_on_hurt | Boolean | false | If true, this entity will be destroyed when hit | | destroy_on_hurt | 布尔值 | false | 若为true,投射物在击中时会被销毁 |
| filter | String | | Entity Definitions defined here can't be hurt by the projectile | | filter | 字符串 | | 此处定义的实体类型不会被投射物伤害 |
| fire_affected_by_griefing | Boolean | false | If true, whether the projectile causes fire is affected by the mob griefing game rule | | fire_affected_by_griefing | 布尔值 | false | 若为true,投射物的引燃效果受游戏规则"mobGriefing"影响 |
| gravity | Decimal | 0.05 | The gravity applied to this entity when thrown. The higher the value, the faster the entity falls | | gravity | 小数 | 0.05 | 投射物抛射时应用的引力值。数值越大下坠越快 |
| hit_ground_sound | String | | The sound that plays when the projectile hits ground | | hit_ground_sound | 字符串 | | 投射物击中地面时播放的音效 |
| hit_sound | String | | The sound that plays when the projectile hits an entity | | hit_sound | 字符串 | | 投射物击中实体时播放的音效 |
| homing | Boolean | false | If true, the projectile homes in to the nearest. **Does not work on 1.18.2** entity | | homing | 布尔值 | false | 若为true,投射物会自动追踪最近目标。**在1.18.2版本中不可用** |
| inertia | Decimal | 0.99 | The fraction of the projectile's speed maintained every frame while traveling in air | | inertia | 小数 | 0.99 | 投射物在空气中飞行时每帧保留的速度比例 |
| is_dangerous | Boolean | false | If true, the projectile will be treated as dangerous to the players | | is_dangerous | 布尔值 | false | 若为true,投射物将被视为对玩家具有威胁性 |
| knockback | Boolean | true | If true, the projectile will knock back the entity it hits | | knockback | 布尔值 | true | 若为true,投射物会击退被击中的实体 |
| lightning | Boolean | false | If true, the entity hit will be struck by lightning | | lightning | 布尔值 | false | 若为true,被击中的实体将遭受雷击 |
| liquid_inertia | Decimal | 0.6 | The fraction of the projectile's speed maintained every frame while traveling in water | | liquid_inertia | 小数 | 0.6 | 投射物在水中飞行时每帧保留的速度比例 |
| multiple_targets | Boolean | true | If true, the projectile can hit multiple entities per flight | | multiple_targets | 布尔值 | true | 若为true,投射物在飞行过程中可以击中多个实体 |
| offset | Vector [a, b, c] | [0, 0.5, 0] | The offset from the entity's anchor where the projectile will spawn | | offset | 三维向量 [a,b,c] | [0, 0.5, 0] | 投射物生成时相对于实体锚点的偏移量 |
| on_fire_time | Decimal | 5 | Time in seconds that the entity hit will be on fire for | | on_fire_time | 小数 | 5 | 被击中实体持续燃烧的时间(秒) |
| on_hit | Object | | Projectile's behavior on hit. More info [below](#on_hit) | | on_hit | 对象 | | 投射物击中时的行为。详见[下方说明](#on_hit) |
| particle | String | iconcrack | Particle to use upon collision | | particle | 字符串 | iconcrack | 碰撞时使用的粒子效果 |
| potion_effect | Integer | -1 | Defines the effect the arrow will apply to the entity it hits | | potion_effect | 整数 | -1 | 定义箭矢击中实体时施加的药水效果 |
| power | Decimal | 1.3 | Determines the velocity of the projectile | | power | 小数 | 1.3 | 决定投射物的初速度 |
| reflect_on_hurt | Boolean | false | If true, this entity will be reflected back when hit | | reflect_on_hurt | 布尔值 | false | 若为true,投射物被击中时会反弹 |
| semi_random_diff_damage | Boolean | false | If true, damage will be randomized based on damage and speed | | semi_random_diff_damage | 布尔值 | false | 若为true,伤害值将基于基础伤害和速度进行随机计算 |
| shoot_sound | String | | The sound that plays when the projectile is shot | | shoot_sound | 字符串 | | 投射物发射时播放的音效 |
| shoot_target | Boolean | true | If true, the projectile will be shot towards the target of the entity firing it | | shoot_target | 布尔值 | true | 若为true,投射物将朝向发射者的目标方向射出 |
| should_bounce | Boolean | false | If true, the projectile will bounce upon hit | | should_bounce | 布尔值 | false | 若为true,投射物击中时会反弹 |
| splash_potion | Boolean | false | If true, the projectile will be treated like a splash potion | | splash_potion | 布尔值 | false | 若为true,投射物将被视为喷溅药水 |
| splash_range | Decimal | 4 | Radius in blocks of the 'splash' effect | | splash_range | 小数 | 4 | '溅射'效果的半径(方块) |
| stop_on_hurt | Boolean | | | | stop_on_hurt | 布尔值 | | |
| uncertainty_base | Decimal | 0 | The base accuracy. Accuracy is determined by the formula uncertaintyBase - difficultyLevel \* uncertaintyMultiplier | | uncertainty_base | 小数 | 0 | 基础精准度。实际精准度计算公式为:uncertaintyBase - difficultyLevel \* uncertaintyMultiplier |
| uncertainty_multiplier | Decimal | 0 | Determines how much difficulty affects accuracy. Accuracy is determined by the formula uncertaintyBase - difficultyLevel \* uncertaintyMultiplier | | uncertainty_multiplier | 小数 | 0 | 难度对精准度的影响系数。实际精准度计算公式为:uncertaintyBase - difficultyLevel \* uncertaintyMultiplier |
| hit_water | Boolean | false | If true, liquid blocks will be treated as solid. **Requires "Education Edition" toggle active** | | hit_water | 布尔值 | false | 若为true,液态方块将被视为固体。**需要启用"教育版"功能** |
## on_hit ## on_hit
This object contains all behaviors, that can be executed, when projectile hits something. 该对象包含投射物击中目标时可执行的所有行为。
### arrow_effect ### arrow_effect
_Exact behavior unknown_ _具体作用未知_
### teleport_owner ### teleport_owner
Teleports shooter to the hit location. 将发射者传送到击中位置。
### catch_fire ### catch_fire
_Exact behavior unknown_ _具体作用未知_
点燃目标
Sets target on fire
### ignite ### ignite
_Exact behavior unknown_ _具体作用未知_
点燃目标
Sets target on fire
### remove_on_hit ### remove_on_hit
Removes the projectile when it hits something. 击中目标后移除投射物。
### douse_fire ### douse_fire
_Exact behavior unknown_ _具体作用未知_
### impact_damage ### impact_damage
Deals damage on hit. 造成碰撞伤害。
| Name | Type | Description | | 字段名称 | 类型 | 描述 |
| ------------------------------ | -------------------------------- | ---------------------------------------------------------------------------------------------------------------------------- | | ------------------------------ | --------------------------------- | --------------------------------------------------------------------------------------------------------------------- |
| damage | Integer/Integer Array [min, max] | Damage dealt to entity on hit | | damage | 整数/整数数组 [min, max] | 对实体造成的伤害值 |
| semi_random_diff_damage | Boolean | | | semi_random_diff_damage | 布尔值 | |
| max_critical_damage | Decimal | | | max_critical_damage | 小数 | |
| min_critical_damage | Decimal | | | min_critical_damage | 小数 | |
| power_multiplier | Decimal | | | power_multiplier | 小数 | |
| channeling | Boolean | | | channeling | 布尔值 | |
| set_last_hurt_requires_damage | Boolean | | | set_last_hurt_requires_damage | 布尔值 | |
| destroy_on_hit_requires_damage | Boolean | | | destroy_on_hit_requires_damage | 布尔值 | |
| filter | String | Entity to affect. Much more primitive than filters used elsewhere, as it cannot "test" for anything other than an identifier | | filter | 字符串 | 受影响的实体类型。此过滤器较为基础,只能通过标识符进行匹配 |
| destroy_on_hit | Boolean | | | destroy_on_hit | 布尔值 | |
| knockback | Boolean | | | knockback | 布尔值 | |
| catch_fire | Boolean | Dictates wether or not targets will be engulfed in flames | | catch_fire | 布尔值 | 控制是否点燃目标 |
### definition_event ### definition_event
Calls an event on hit. 触发击中事件。
| Name | Type | Description | | 字段名称 | 类型 | 描述 |
| ------------------ | ------- | --------------------------------------------------- | | ---------------------- | -------- | ------------------------------------------- |
| affect_projectile | Boolean | Event will be triggered for projectile entity | | affect_projectile | 布尔值 | 为投射物实体触发事件 |
| affect_shooter | Boolean | Event will be triggered for shooter entity | | affect_shooter | 布尔值 | 为发射者实体触发事件 |
| affect_target | Boolean | Event will be triggered for hit entity | | affect_target | 布尔值 | 为被击中实体触发事件 |
| affect_splash_area | Boolean | Event will be triggered for all entities in an area | | affect_splash_area | 布尔值 | 为区域内所有实体触发事件 |
| splash_area | Decimal | Area of entities | | splash_area | 小数 | 实体作用范围半径 |
| event_trigger | Object | Event to trigger. Structure below. | | event_trigger | 对象 | 要触发的事件。结构如下: |
| Name | Type | Description | | 字段名称 | 类型 | 描述 |
| ------- | ------ | ------------------------------------- | | ----------- | -------- | ----------------------------- |
| event | String | Event to trigger | | event | 字符串 | 要触发的事件名称 |
| target | String | Target of the event | | target | 字符串 | 事件目标 |
| filters | Object | Criteria required in order to trigger | | filters | 对象 | 触发事件所需的过滤条件 |
### stick_in_ground ### stick_in_ground
Sticks the projectile into the ground. 将投射物插入地面。
| Name | Type | Description | | 字段名称 | 类型 | 描述 |
| ---------- | ------- | ----------- | | -------------- | -------- | ---- |
| shake_time | Decimal | | | shake_time | 小数 | |
### spawn_aoe_cloud ### spawn_aoe_cloud
Spawns an area of effect cloud of potion effect. 生成药水效果的区域云。
| Name | Type | Description | | 字段名称 | 类型 | 描述 |
| ------------------- | ----------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | ----------------------- | ------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------- |
| radius | Decimal | Radius of the cloud | | radius | 小数 | 云效果半径 |
| radius_on_use | Decimal | | | radius_on_use | 小数 | |
| potion | Integer | Lingering Potion ID | | potion | 整数 | 滞留药水ID |
| particle | String | [Vanilla Particles](/particles/vanilla-particles) emitter of the cloud. Only accepts Vanilla Particles. **dragonbreath** enables the usage of Bottles to obtain Dragon's Breath. | | particle | 字符串 | 区域云的[原版粒子效果](/wiki/particles/vanilla-particles)。仅接受原版粒子。**dragonbreath**允许使用瓶子收集龙息 |
| duration | Integer | Duration of the cloud in seconds | | duration | 整数 | 云效果持续时间(秒) |
| color | Integer array [r, g, b] | Color of the particles | | color | 整数数组 [r, g, b] | 粒子颜色 |
| affect_owner | Boolean | Is potion effect affecting the shooter. Does not appear to apply to the player | | affect_owner | 布尔值 | 药水效果是否影响发射者(对玩家无效) |
| reapplication_delay | Integer | Delay in ticks between application of the potion effect | | reapplication_delay | 整数 | 药水效果重复施加的时间间隔(刻) |
#### Potion IDs #### 药水ID
| Potion | Regular | Extended | Enhanced (Level II) | | 药水名称 | 普通 | 延长版 | 强化版II级 |
| ------------------------- | ------- | -------- | ------------------- | | ------------------------ | ------- | ------- | ------------- |
| Water Bottle | 0 | | | | 水瓶 | 0 | | |
| Mundane Potion | 1 | 2 | | | 平凡药水 | 1 | 2 | |
| Thick Potion | 3 | | | | 浓稠药水 | 3 | | |
| Awkward Potion | 4 | | | | 粗制药水 | 4 | | |
| Potion of Night Vision | 5 | 6 | | | 夜视药水 | 5 | 6 | |
| Potion of Invisibility | 7 | 8 | | | 隐身药水 | 7 | 8 | |
| Potion of Leaping | 9 | 10 | 11 | | 跳跃药水 | 9 | 10 | 11 |
| Potion of Fire Resistance | 12 | 13 | | | 抗火药水 | 12 | 13 | |
| Potion of Swiftness | 14 | 15 | 16 | | 迅捷药水 | 14 | 15 | 16 |
| Potion of Slowness | 17 | 18 | | | 迟缓药水 | 17 | 18 | |
| Potion of Water Breathing | 19 | 20 | | | 水肺药水 | 19 | 20 | |
| Potion of Healing | 21 | | 22 | | 治疗药水 | 21 | | 22 |
| Potion of Harming | 23 | | 24 | | 伤害药水 | 23 | | 24 |
| Potion of Poison | 25 | 26 | 27 | | 剧毒药水 | 25 | 26 | 27 |
| Potion of Regeneration | 28 | 29 | 30 | | 再生药水 | 28 | 29 | 30 |
| Potion of Strength | 31 | 32 | 33 | | 力量药水 | 31 | 32 | 33 |
| Potion of Weakness | 34 | 35 | | | 虚弱药水 | 34 | 35 | |
| Potion of Decay | 36 | | | | 衰变药水 | 36 | | |
| Potion of Turtle Master | 37 | 38 | 39 | | 神龟药水 | 37 | 38 | 39 |
| Potion of Slow Falling | 40 | 41 | | | 缓降药水 | 40 | 41 | |
| Potion of Slowness IV | 42 | | | | 迟缓IV药水 | 42 | | |
| Potion of Crashing | 43+ | | | | 跳跃提升IV药水 | 43+ | | |
### spawn_chance ### spawn_chance
Spawns an entity on hit. 击中时生成实体。
| Name | Type | Description | | 字段名称 | 类型 | 描述 |
| --------------------------- | ------- | ------------------------------------------- | | ------------------------------- | -------- | ------------------------------- |
| first_spawn_percent_chance | Decimal | | | first_spawn_percent_chance | 小数 | |
| second_spawn_percent_chance | Decimal | | | second_spawn_percent_chance | 小数 | |
| first_spawn_count | Integer | | | first_spawn_count | 整数 | |
| second_spawn_count | Integer | | | second_spawn_count | 整数 | |
| spawn_definition | String | ID of the entity to spawn | | spawn_definition | 字符串 | 要生成的实体ID |
| spawn_baby | Boolean | Whether the spawned entity should be a baby | | spawn_baby | 布尔值 | 生成的实体是否为幼体 |
### particle_on_hit ### particle_on_hit
Spawns particles on hit. 击中时生成粒子效果。
| Name | Type | Description |
| ------------- | ------- | -------------------------------------------------------- |
| particle_type | String | [Vanilla Particles](/particles/vanilla-particles) to use |
| num_particles | Integer | Number of particles |
| on_entity_hit | Boolean | Whether it should spawn particles on entity hit |
| on_other_hit | Boolean | Whether it should spawn particles on other hit |
| 字段名称 | 类型 | 描述 |
| ----------------- | -------- | ----------------------------------------------- |
| particle_type | 字符串 | 使用的[原版粒子效果](/wiki/particles/vanilla-particles) |
| num_particles | 整数 | 粒子数量 |
| on_entity_hit | 布尔值 | 是否在击中实体时生成粒子 |
| on_other_hit | 布尔值 | 是否在其他碰撞时生成粒子 |
### mob_effect ### mob_effect
Applies a mob effect to the target. 对目标施加生物状态效果。
| Name | Type | Description | | 字段名称 | 类型 | 描述 |
| -------------- | ------- | ------------------------------------------- | | ------------------ | -------- | ------------------------------- |
| effect | String | Effect | | effect | 字符串 | 效果类型 |
| duration | Integer | Duration of the effect | | duration | 整数 | 效果持续时间 |
| durationeasy | Integer | Duration of the effect on easy difficulty | | durationeasy | 整数 | 简单难度下的持续时间 |
| durationnormal | Integer | Duration of the effect on normal difficulty | | durationnormal | 整数 | 普通难度下的持续时间 |
| durationhard | Integer | Duration of the effect on hard difficulty | | durationhard | 整数 | 困难难度下的持续时间 |
| amplifier | Integer | Effect amplifier | | amplifier | 整数 | 效果等级 |
| ambient | Boolean | | | ambient | 布尔值 | |
| visible | Boolean | | | visible | 布尔值 | |
### grant_xp ### grant_xp
Despite the name, this actually spawns a number of experience orbs, being worth the amount stated. 尽管名称如此,该行为实际上是生成指定数量的经验球。
| Name | Type | Description | | 字段名称 | 类型 | 描述 |
| ----- | ------- | ----------------------------------------------------------------------------------------------- | | --------- | -------- | ------------------------------------------- |
| minXP | Integer | Minimum amount of experience to give | | minXP | 整数 | 给予的最小经验值 |
| maxXP | Integer | Maximum amount of experience to give | | maxXP | 整数 | 给予的最大经验值 |
| xp | Integer | Constant amount of experience to give. When set, it will be used instead of min and max values. | | xp | 整数 | 固定经验值。设置后将覆盖min和max值 |
### freeze_on_hit ### freeze_on_hit
_Exact behavior unknown_ _具体作用未知_
_Requires Education Edition toggle to be enabled._ _需要启用教育版功能_
Freezes water on hit. 冻结命中点周围的水。
| Name | Type | Description | | 字段名称 | 类型 | 描述 |
| ------------- | ------- | ----------------------------- | | ----------------- | -------- | --------------------- |
| shape | String | "sphere" or "cube" | | shape | 字符串 | "sphere" "cube" |
| snap_to_block | Boolean | | | snap_to_block | 布尔值 | |
| size | Integer | The size of the freeze effect | | size | 整数 | 冻结效果的范围大小 |
### hurt_owner ### hurt_owner
_Exact behavior unknown. Right now it crashes minecraft probably because of wrong parameters_ _具体作用未知。当前版本可能导致游戏崩溃(可能参数错误)_
| Name | Type | Description | | 字段名称 | 类型 | 描述 |
| ------------ | ------- | ----------- | | ---------------- | -------- | ---- |
| owner_damage | Integer | | | owner_damage | 整数 | |
| knockback | Boolean | | | knockback | 布尔值 | |
| ignite | Boolean | | | ignite | 布尔值 | |
### thrown_potion_effect ### thrown_potion_effect
_Exact behavior unknown. Right now it crashes minecraft probably because it's only valid for thrown potions_ _具体作用未知。当前版本可能导致游戏崩溃(可能仅适用于投掷药水)_
## Additional Information ## 补充说明
When it comes to creating a custom projectile, such as an arrow or trident variant, or something entirely your own, you may want to consider defining a [runtime identifier](/entities/runtime-identifier) to ensure that it acts as intended. Not doing so may result in unintended behaviour, from odd visuals to incorrect knockback direction and arrows that you can kill with your bare hands.
在创建自定义投射物(如箭矢变体或全新物品)时,建议定义[运行时标识符](/wiki/entities/runtime-identifier)来确保预期行为。未正确设置可能导致异常表现,包括显示错误、击退方向异常,甚至出现可用徒手摧毁的箭矢等问题。

View File

@@ -1,5 +1,5 @@
--- ---
title: Molang Queries title: Molang 查询
toc_max_level: 2 toc_max_level: 2
mentions: mentions:
- SirLich - SirLich
@@ -17,142 +17,142 @@ mentions:
- ThomasOrs - ThomasOrs
--- ---
The bedrock documentation for Molang is notoriously bad. This page will attempt to remedy this by providing additional details for individual queries, _where possible_. This page is intended to be searched, not read in full. Use the side-bar, or use `ctrl-f` to navigate. # Molang 查询
<!--@include: @/wiki/bedrock-wiki-mirror.md-->
基岩版官方Molang文档存在诸多不足。本页面旨在通过为各个查询提供额外详细信息在可能的情况下改善这一现状。建议通过侧边栏导航或使用`Ctrl+F`进行搜索查阅,无需全文通读。
:::tip :::tip
This page is not an exhaustive list list! It only contains queries we've written extra information for. The full list of queries can be found [here](https://bedrock.dev/docs/stable/Molang#List%20of%20Entity%20Queries)! 本页面并非完整列表!仅包含我们补充了额外信息的查询。完整查询列表可访问[此处](https://bedrock.dev/docs/stable/Molang#List%20of%20Entity%20Queries)查看!
::: :::
## query.armor_texture_slot ## query.armor_texture_slot
Formatted like: `query.armor_texture_slot(x) = y`. 语法格式:`query.armor_texture_slot(x) = y`
Where `x` and `y` are both integer arguments, from the following table: 其中`x``y`均为整型参数,对应以下表格:
### X ### X 参数
| Argument | Slot | | 参数值 | 装备槽位 |
| -------- | ---------- | | ------ | ---------- |
| 0 | Helmet | | 0 | 头盔 |
| 1 | Chestplace | | 1 | 胸甲 |
| 2 | Leggings | | 2 | 护腿 |
| 3 | Boots | | 3 | 靴子 |
### Y ### Y 参数(常规)
| Argument | Type | | 参数值 | 材质类型 |
| -------- | --------------------- | | ------ | ------------------ |
| -1 | none | | -1 | 无装备 |
| 0 | Leather armor piece | | 0 | 皮革护甲 |
| 1 | Chain armor piece | | 1 | 锁链护甲 |
| 2 | Iron armor piece | | 2 | 铁护甲 |
| 3 | Diamond armor piece | | 3 | 钻石护甲 |
| 4 | Gold armor piece | | 4 | 金护甲 |
| 5 | Elytra | | 5 | 鞘翅 |
| 6 | Turtle helmet | | 6 | 海龟壳头盔 |
| 7 | Netherite armor piece | | 7 | 下界合金护甲 |
### Y for horses ### Y 参数(马匹)
| Argument | Type | | 参数值 | 材质类型 |
| -------- | --------------------- | | ------ | ------------------ |
| 1 | Leather armor piece | | 1 | 皮革马铠 |
| 2 | Iron armor piece | | 2 | 铁马铠 |
| 3 | Gold armor piece | | 3 | 金马铠 |
| 4 | Diamond armor piece | | 4 | 钻石马铠 |
### Example ### 示例
`query.armor_texture_slot(3) == 1`: queries for Iron Boots. `query.armor_texture_slot(3) == 1`:检测是否穿着铁靴子
## query.armor_material_slot ## query.armor_material_slot
Formatted like: `query.armor_material_slot(x) = y`. 语法格式:`query.armor_material_slot(x) = y`
Where `x` and `y` are both integer arguments, from the following table: 其中`x``y`均为整型参数,对应以下表格:
### X ### X 参数
| Argument | Slot | | 参数值 | 装备槽位 |
| -------- | ---------- | | ------ | ---------- |
| 0 | Helmet | | 0 | 头盔 |
| 1 | Chestplace | | 1 | 胸甲 |
| 2 | Leggings | | 2 | 护腿 |
| 3 | Boots | | 3 | 靴子 |
### Y ### Y 参数(推测值)
Unknown, possibly: | 参数值 | 材质类型 |
| ------ | ---------------------- |
| Argument | Slot | | 0 | 默认护甲材质 |
| -------- | -------------------------- | | 1 | 附魔护甲材质 |
| 0 | Default armor material | | 2 | 皮革护甲材质 |
| 1 | Enchanted armor material | | 3 | 附魔皮革护甲材质 |
| 2 | Leather armor material |
| 3 | Leather enchanted material |
## query.armor_color_slot ## query.armor_color_slot
_Notice: As of version `1.16.100.51`, this query is crashing minecraft. It might be fixed in later versions._ *注意:截至版本`1.16.100.51`,此查询会导致游戏崩溃,可能在后续版本修复*
Formatted like: `color = query.armor_color_slot(slot, channel)`. 语法格式:`color = query.armor_color_slot(slot, channel)`
Where `slot` and `channel` are both integer arguments, from the following tables: 其中`slot``channel`均为整型参数,对应以下表格:
### Slot ### Slot 参数
| Argument | Slot | | 参数值 | 装备槽位 |
| -------- | ---------- | | ------ | ---------- |
| 0 | Helmet | | 0 | 头盔 |
| 1 | Chestplace | | 1 | 胸甲 |
| 2 | Leggings | | 2 | 护腿 |
| 3 | Boots | | 3 | 靴子 |
### Channel ### Channel 参数
| Argument | Slot | | 参数值 | 颜色通道 |
| -------- | ------------- | | ------ | -------------- |
| 0 | Red channel | | 0 | 红色通道 |
| 1 | Green channel | | 1 | 绿色通道 |
| 2 | Blue channel | | 2 | 蓝色通道 |
| 3 | Alpha channel | | 3 | 透明度通道 |
### Color ### 返回值
Query returns color value in specified channel. 返回指定通道的颜色值0-1范围
## query.get_equipped_item_name ## query.get_equipped_item_name
:::warning :::warning
**DEPRECATED QUERY:** It is recommended to use the new query (`query.is_item_name_any`) if possible as it is more of an updated version of this query. However, this query will still continue to work in the future for backwards compatibility. **已弃用查询**:建议优先使用新查询`query.is_item_name_any`,此查询未来仍会保留以兼容旧版本
::: :::
Formatted like: `query.get_equipped_item_name('main_hand') = 'item_name'` 语法格式:`query.get_equipped_item_name('main_hand') = 'item_name'`
Takes one optional hand slot as a parameter (0 or 'main_hand' for main hand, 1 or 'off_hand' for off hand), and a second parameter (0=default) if you would like the equipped item or any non-zero number for the currently rendered item, and returns the name of the item in the requested slot (defaulting to the main hand if no parameter is supplied) if there is one, otherwise returns ''. 接受一个可选的手部槽位参数0或'main_hand'表示主手1或'off_hand'表示副手第二个参数0=默认)用于选择装备物品或当前渲染物品,返回对应槽位的物品名称(无参数时默认主手),无物品时返回空字符串。
Where `item_name` is the item you want to test for. No namespace, and please notice the quotes. `item_name`需使用不带命名空间的物品ID注意保留引号
Example: `"query.get_equipped_item_name == 'diamond'"` 示例:`"query.get_equipped_item_name == 'diamond'"`
**Can you test for items in the inventory? Yes! Using the new query `query.is_item_name_any`.** **如何检测背包物品?可以使用新查询`query.is_item_name_any`**
## query.get_name ## query.get_name
:::warning :::warning
**DEPRECATED QUERY:** It is recommended to use the new query (`query.is_name_any`) if possible as it is more of an updated version of this query. However, this query will still continue to work in the future for backwards compatibility. **已弃用查询**:建议优先使用新查询`query.is_name_any`,此查询未来仍会保留以兼容旧版本
::: :::
Formatted like: `query.get_name == 'Name'` 语法格式:`query.get_name == '名称'`
Turns true if actual in-game displayed name matches name (use OnixClient to see names in third view). 当实体显示名称匹配时返回true需使用OnixClient等工具查看第三方视角名称需在特定条件下使用
Needs to be used in special conditions.
<Spoiler title="Show"> <Spoiler title="展开示例">
<CodeHeader>animation_controllers/ac.json</CodeHeader> ::: code-group
```json [animation_controllers/ac.json]
```json
{ {
"format_version": "1.10.0", "format_version": "1.10.0",
"animation_controllers": { "animation_controllers": {
@@ -174,7 +174,7 @@ Needs to be used in special conditions.
], ],
"animations": [ "animations": [
{ {
"anim": "query.get_name == '...'" // You can use it only here! "anim": "query.get_name == '...'" // 只能在此处使用!
} }
] ]
} }
@@ -183,21 +183,20 @@ Needs to be used in special conditions.
} }
} }
``` ```
:::
</Spoiler> </Spoiler>
## query.is_name_any ## query.is_name_any
Formatted like: `query.get_name('Name1', 'Name2')`. 语法格式:`query.is_name_any('名称1', '名称2')`
Takes one or more arguments.
Turns true if actual in-game displayed name matches one of the given names.
Needs to be used in special conditions.
<Spoiler title="Show"> 接受一个或多个参数当实体显示名称匹配任一参数时返回true需在特定条件下使用
<CodeHeader>animation_controllers/ac.json</CodeHeader> <Spoiler title="展开示例">
```json ::: code-group
```json [animation_controllers/ac.json]
{ {
"format_version": "1.10.0", "format_version": "1.10.0",
"animation_controllers": { "animation_controllers": {
@@ -219,7 +218,7 @@ Needs to be used in special conditions.
], ],
"animations": [ "animations": [
{ {
"anim": "query.is_name_any(...)" // You can use it only here! "anim": "query.is_name_any(...)" // 只能在此处使用!
} }
] ]
} }
@@ -228,340 +227,249 @@ Needs to be used in special conditions.
} }
} }
``` ```
:::
</Spoiler> </Spoiler>
## query.is_item_name_any ## query.is_item_name_any
Formatted like: `query.is_item_name_any('slot.weapon.mainhand', 0, 'namespace:item_name')` 语法格式:`query.is_item_name_any('slot.weapon.mainhand', 0, '命名空间:物品名称')`
Takes the equipment slot name first, followed by the slot index value, and then the list of item names with namespaces after it. 参数顺序:装备槽名称 → 槽位索引 → 带命名空间的物品名称列表
Possible equipment slot are as follows: 可用槽位列表:
| Slot Name | Slot Counts | Description | | 槽位名称 | 槽位数 | 说明 |
| ---------------------- | ----------- | ----------------------------------------------------------------------------------- | | -------------------- | ------ | ----------------------------- |
| `slot.weapon.mainhand` | 0 | Usually any held items are in here | | `slot.weapon.mainhand` | 0 | 主手持握物品 |
| `slot.weapon.offhand` | 0 | Offhand slot for things like `Shield`, `Totem of Undying` or a `Map` | | `slot.weapon.offhand` | 0 | 副手(盾牌、地图等) |
| `slot.armor.head` | 0 | Head armor piece | | `slot.armor.head` | 0 | 头部护甲 |
| `slot.armor.chest` | 0 | Chestplate armor piece | | `slot.armor.chest` | 0 | 胸甲 |
| `slot.armor.legs` | 0 | Leggings armor piece | | `slot.armor.legs` | 0 | 护腿 |
| `slot.armor.feet` | 0 | Boots armor piece | | `slot.armor.feet` | 0 | 靴子 |
| `slot.armor` | 0 | Horse armor | | `slot.armor` | 0 | 马铠 |
| `slot.saddle` | 0 | Saddle slot | | `slot.saddle` | 0 | 鞍具 |
| `slot.hotbar` | 0 to 8 | Player hotbar slots | | `slot.hotbar` | 0-8 | 玩家快捷栏 |
| `slot.inventory` | 0+ (varies) | Entities that has an inventory, like the player, minecart with chests, donkey, etc. | | `slot.inventory` | 可变 | 实体库存(箱子矿车、驴等) |
| `slot.enderchest` | 0 to 26 | Ender chest inventory for players only | | `slot.enderchest` | 0-26 | 末影箱(仅玩家) |
### Test for items within the player's inventory ### 检测玩家背包物品
Formatted like: `t.val = 0; t.i = 0; loop(27, {t.val = q.is_item_name_any('slot.inventory', t.i, 'namespace:item_name'); t.val ? {return t.val;}; t.i = t.i+1;});` 示例代码:
```molang
Replace `namespace:item_name` with any item you wish to check for. This simply loops through all 27 slots of the inventory and returns `1.0` if it has found any slot that has the specified item provided. Note that the hotbar is in a different slot from the main inventory slot so you will have to check that separately. t.val = 0;
t.i = 0;
loop(27, {
t.val = q.is_item_name_any('slot.inventory', t.i, '命名空间:物品名称');
t.val ? {return t.val;};
t.i = t.i+1;
});
```
替换`命名空间:物品名称`为目标物品此代码会遍历27个背包槽位检测到目标物品时返回1.0。注意快捷栏与主背包槽位独立,需分开检测。
## query.is_enchanted ## query.is_enchanted
Formatted like: `is_enchanted = query.is_enchanted`. 语法格式:`is_enchanted = query.is_enchanted`
Return 1.0 or 0.0 based on whether the entity is enchanted. 返回1.0已附魔或0.0(未附魔)
_Currently, can be only used in materials._ *目前仅能在材质中使用*
## query.is_eating ## query.is_eating
This query tracks when certain entities are 'eating'. It's not used for the player. To trigger, use one of the following components: 检测实体是否处于"进食"状态(不适用于玩家)。需配合以下组件使用:
- `minecraft:behavior.eat_carried_item` - `minecraft:behavior.eat_carried_item`
- `minecraft:behavior.snacking` - `minecraft:behavior.snacking`
## query.is_ghost ## query.is_ghost
Formatted like: `is_ghost = query.is_ghost`. 语法格式:`is_ghost = query.is_ghost`
Return 1.0 or 0.0 based on whether the entity is a ghost. 返回1.0幽灵实体或0.0
_Currently, only returns 1.0 for a guardian ghost and is used by its renderer._ *当前仅对守护者幽灵有效,用于渲染控制*
## query.is_grazing ## query.is_grazing
Formatted like: `is_grazing = query.is_grazing`. 语法格式:`is_grazing = query.is_grazing`
Return 1.0 or 0.0 based on whether the entity is eating a block. 检测实体是否在啃食方块(如绵羊吃草)
_Currently, only returns 1.0 for a sheep and entities using runtime identifier of a sheep._ *目前仅对绵羊及使用绵羊运行ID的实体有效*
## query.is_jumping ## query.is_jumping
Formatted like: `is_jumping = query.is_jumping`. 语法格式:`is_jumping = query.is_jumping`
Return 1.0 or 0.0 based on whether the entity is jumping. 返回1.0跳跃中或0.0
For the player, conditions for its activation are: 玩家触发条件:
- 按下跳跃键(包含水中跳跃、攀爬脚手架)
- the jump button is pressed (includes being in water and climbing a scaffolding) - 自动跳跃触发
- OR auto-jump is triggered - 游泳时自动跳跃
- OR swimming with auto-jump - 骑乘实体蓄力跳跃
- OR charging the jump of a ridable entity
## query.modified_move_speed ## query.modified_move_speed
Formatted like: `modified_move_speed = query.modified_move_speed`. 语法格式:`modified_move_speed = query.modified_move_speed`
Returns the current walk speed of the entity modified by status flags such as is_baby or on_fire 返回实体当前移动速度(受幼体、着火等状态影响)
Value example: 参考值:
- 行走约0.86
- Player is walking: around 0.86 - 疾跑1.0
- Player is sprinting: 1.0 - 疾跑跳跃0.35
- Player is sprinting and jumping: 0.35 - 着火行走1.0
- Player is walking on fire: 1.0 - 着火疾跑:1.0
- Player is sprinting on fire: 1.0 - 着火疾跑跳跃0.525
- Player is sprinting and jumping on fire: 0.525
## query.log ## query.log
Content log is NOT debug log, they're different files. `query.log` outputs to the debug log only. 将日志输出到调试日志注意content logdebug log不同)
## query.on_fire_time ## query.on_fire_time
Formatted like: `on_fire_time = query.on_fire_time`. 语法格式:`on_fire_time = query.on_fire_time`
Returns the time in ticks since the entity started or stopped being on fire, else it returns 0.0 返回实体着火/灭火后的持续时间(刻),未着火时返回0.0
Value example: 计时规则:
- 实体生成0
- Entity is summoned: value is 0 - 点燃开始递增1刻/次)
- Entity is ignited: value is 0 and starts counting up 1 every tick - 灭火重置0并继续递增
- Entity is on fire for 2 seconds already: value is 40 and still counts up 1 every tick - 重复点燃/灭火:每次状态变化重置计时
- Entity stops being on fire: value resets to 0 and continues to count up 1 every tick despite not being on fire
- Entity is ignited second time: value resets to 0 and continues counting up 1 every tick
- Entity stops being on fire the second time: value resets to 0 and continues to count up 1 every tick despite not being on fire
Basically it's tick timer that starts after entity is first ignited and resets every time it changes from/to being on fire.
## query.scoreboard ## query.scoreboard
Formatted like: `query.scoreboard('objective_name') > 0` 语法格式:`query.scoreboard('计分项名称') > 数值`
Returns 1.0 or 0.0 if the queried value is within the specified range provided. Or based on score count, molang operator and number. 根据计分板值返回1.0或0.0
Note that sometimes it might not work because of unknown reasons. One of which is that this cannot query scoreboard objective names with uppercase letters. In this case, for example, objective `testfoo` will work but **not** `testFoo`. 注意:
- 无法检测含大写字母的计分项(如`testFoo`无效,需使用`testfoo`
- 部分情况可能异常
## query.structural_integrity ## query.structural_integrity
Formatted like: `structural_integrity = query.structural_integrity`. 语法格式:`structural_integrity = query.structural_integrity`
Used by boats and minecarts for destroying it. It will decrease when attacking the entity and will recover with time. 用于船和矿车的耐久系统(受攻击减少,随时间恢复)
Probably unusable by anything other than boats and minecarts.
*可能无法用于其他实体*
## variable.attack_time ## variable.attack_time
### Explanation ### 说明
This variable is setup as IF it was a query. In other words, it can be used on any entity, both on the client and server, regardless of whether you setup/define the variable correctly. 该变量作为查询使用,可在任意实体(客户端/服务端)生效,无需预先定义
### For entities ### 实体行为
The variable tracks when the entity is swinging to attack. When not attacking, it will return 0.0, when attacking it will range from 0.0 to the total attack time, which may be around 0.3 or something similar. For players, this value ranges from 0.0 to 1.0. The variable returns a percentage, in the form of a decimal, for how far into the attack the entity is. For example, if an entity is halfway into its attack swing, then the variable will return 0.5. It increments linearly. 追踪实体攻击动作进度:
- 未攻击0.0
- 攻击中0.0~总攻击时间约0.3
- 玩家0.0~1.0(线性增长)
### For the Player ### 玩家行为
For the player, the variable will track whenever the arm bones are swinging, this includes: 追踪手臂摆动动作(包含以下情况):
- 放置方块
- placing blocks - 放置实体
- placing entities - 交互动作(当启用摆动时)
- interacting (when swing is enabled) - 近战攻击
- melee attack
## query.is_roaring ## query.is_roaring
Evaluates to true when a `knockback_roar` attack is happening. 当实体执行`knockback_roar`攻击时返回true
## query.head_x_rotation ## query.head_x_rotation
Formatted like: `query.head_x_rotation(x)` 语法格式:`query.head_x_rotation(x)`
Where `x` specifies the head of the entity. It is not really relevant for any entity but the wither. `x`参数指定头部编号(主要用于凋灵)
Returns head pitch. looking up returns `-89.9`, looking all the way down returns `89.9`. 返回值:
- 仰角(向上-89.9向下89.9
## query.head_y_rotation ## query.head_y_rotation
Formatted like: `query.head_y_rotation(x)` 语法格式:`query.head_y_rotation(x)`
Where `x` specifies the head of the entity. It is not really relevant for any entity but the wither. `x`参数指定头部编号(主要用于凋灵)
Returns yaw of the head from `-179.9` to `179.9`. the values wrap around so like if you are at `-179.9` and you turn just a little bit, it instantly goes to `179.9`. 返回值:
- 偏航角(-179.9~179.9,循环变化)
## query.target_x_rotation and query.target_y_rotation ## query.target_x_rotation query.target_y_rotation
Identical to the respective `query.head_*_rotation`, however has no optional argument for selecting head. 功能同`query.head_*_rotation`,但无需指定头部参数
## query.time_of_day ## query.time_of_day
Returns the time of day (midnight=0.0, sunrise=0.25, noon=0.5, sunset=0.75) of the dimension the entity is in. 返回维度时间(午夜=0.0,日出=0.25,正午=0.5,日落=0.75
Day time is calculated via this formula:
`f(x) = (x*0.25/2400)mod 1` 计算公式:`(当前刻数*0.25/2400) mod 1`
query.time_of_day - day time table 时间对应表:
<Spoiler title="Show"> <Spoiler title="展开时间表">
| `query.time_of_day` | Day Time | | query.time_of_day | 游戏刻数 |
| ------------------- | -------- | | ----------------- | -------- |
| 0.00 | 18000 | | 0.00 | 18000 |
| 0.01 | 18240 | | 0.25 | 0 |
| 0.02 | 18480 | | 0.50 | 6000 |
| 0.03 | 18720 | | 0.75 | 12000 |
| 0.04 | 18960 | | ... | ... |
| 0.05 | 19200 |
| 0.06 | 19440 |
| 0.07 | 19680 |
| 0.08 | 19920 |
| 0.09 | 20162 |
| 0.10 | 20400 |
| 0.11 | 20640 |
| 0.12 | 20880 |
| 0.13 | 21120 |
| 0.14 | 21360 |
| 0.15 | 21602 |
| 0.16 | 21840 |
| 0.17 | 22080 |
| 0.18 | 22322 |
| 0.19 | 22560 |
| 0.20 | 22800 |
| 0.21 | 23040 |
| 0.22 | 23280 |
| 0.23 | 23520 |
| 0.24 | 23760 |
| 0.25 | 0 |
| 0.26 | 240 |
| 0.27 | 480 |
| 0.28 | 720 |
| 0.29 | 960 |
| 0.30 | 1202 |
| 0.31 | 1440 |
| 0.32 | 1680 |
| 0.33 | 1922 |
| 0.34 | 2160 |
| 0.35 | 2400 |
| 0.36 | 2642 |
| 0.37 | 2880 |
| 0.38 | 3120 |
| 0.39 | 3360 |
| 0.40 | 3600 |
| 0.41 | 3840 |
| 0.42 | 4080 |
| 0.43 | 4320 |
| 0.44 | 4560 |
| 0.45 | 4800 |
| 0.46 | 5040 |
| 0.47 | 5280 |
| 0.48 | 5520 |
| 0.49 | 5760 |
| 0.50 | 6000 |
| 0.51 | 6240 |
| 0.52 | 6480 |
| 0.53 | 6720 |
| 0.54 | 6960 |
| 0.55 | 7200 |
| 0.56 | 7440 |
| 0.57 | 7680 |
| 0.58 | 7920 |
| 0.59 | 8160 |
| 0.60 | 8402 |
| 0.61 | 8640 |
| 0.62 | 8880 |
| 0.63 | 9120 |
| 0.64 | 9360 |
| 0.65 | 9600 |
| 0.66 | 9842 |
| 0.67 | 10080 |
| 0.68 | 10320 |
| 0.69 | 10560 |
| 0.70 | 10800 |
| 0.71 | 11040 |
| 0.72 | 11282 |
| 0.73 | 11520 |
| 0.74 | 11760 |
| 0.75 | 12000 |
| 0.76 | 12240 |
| 0.77 | 12480 |
| 0.78 | 12720 |
| 0.79 | 12962 |
| 0.80 | 13200 |
| 0.81 | 13440 |
| 0.82 | 13680 |
| 0.83 | 13920 |
| 0.84 | 14160 |
| 0.85 | 14402 |
| 0.86 | 14640 |
| 0.87 | 14880 |
| 0.88 | 15120 |
| 0.89 | 15360 |
| 0.90 | 15600 |
| 0.91 | 15842 |
| 0.92 | 16080 |
| 0.93 | 16320 |
| 0.94 | 16560 |
| 0.95 | 16800 |
| 0.96 | 17040 |
| 0.97 | 17282 |
| 0.98 | 17520 |
| 0.99 | 17760 |
| 1.00 | 18000 |
Credit: [Analysis of query.time_of_day](https://gist.github.com/DoubleF3lix/a03afde0a979dfa41e8525ee92f12ca5) *完整表格详见原文档*
</Spoiler> </Spoiler>
## query.eye_target_x_rotation and query.eye_target_y_rotation ## query.eye_target_x_rotation query.eye_target_y_rotation
Not valid for player. not really sure what its good for. 不适用于玩家,具体用途待验证
## variable.short_arm_offset_right ## variable.short_arm_offset_right
Returns the offset factor for the player's rightarm bone compared to the default skin geometry. Slim-armed (3 pixel wide) skins will return `0.5` when equipped on the player. Normal (4 pixel wide) skins will return `0.0` when equipped on the player. Note: the player must go into 1st person perspective at least once for this variable to be initialized and usable elsewhere on the entity. 返回玩家右臂骨骼偏移因子:
- 细臂皮肤3像素宽0.5
- 常规皮肤4像素宽0.0
*注意:需进入第一人称视角初始化变量*
## variable.short_arm_offset_left ## variable.short_arm_offset_left
Identical behavior to `variable.short_arm_offset_right` except it references the player leftarm bone. 功能同`variable.short_arm_offset_right`,对应左臂骨骼
## query.movement_direction ## query.movement_direction
Returns one of the 3 components from the normalized vector of the entity movement meaning the magnitude/modulus/length of the vector is between 0 and 1. 返回实体移动方向向量的归一化分量模长0~1
**Note**: As of writing the documentation, the value returned from any of the axis will change depending on the speed of the entity (If the entity is on the ground the value will be less than the value of the entity if it were in the air even if it is moving in the same direction). 注意:实际值受移动速度影响(地面移动值小于空中相同方向)
To get the actual normalized velocity vector of the entity movement you will have to normalize the values. Here is the Molang setup: 归一化处理示例:
```molang
``` variable.mag = math.sqrt(math.pow(query.movement_direction(0),2) + ...);
variable.mag = math.sqrt( math.pow( query.movement_direction(0), 2 ) + math.pow( query.movement_direction(1), 2) + math.pow( query.movement_direction(2), 2)); variable.xNorm = query.movement_direction(0)/variable.mag;
variable.xNorm = query.movement_direction(0) / variable.mag; // y/z同理
variable.yNorm = query.movement_direction(1) / variable.mag;
variable.zNorm = query.movement_direction(2) / variable.mag;
``` ```
For more information on normalized vectors you can play around with this <a href=https://www.desmos.com/calculator/hhoamwgve2>Desmos graph</a> | 参数 | 轴向 |
| ---- | ---- |
| 0 | X轴 |
| 1 | Y轴 |
| 2 | Z轴 |
| Argument | Axis | ## query.block_neighbor_has_any_tag 与 query.relative_block_has_any_tag
| -------- | ---- |
| 0 | X |
| 1 | Y |
| 2 | Z |
## query.block_neighbor_has_any_tag and query.relative_block_has_any_tag *需启用`Experimental Molang Features`*
Requires `Experimental Molang Features` to use. From the docs `Takes a relative position and one or more tag names, and returns either 0 or 1 based on if the block at that position has any of the tags provided`. This is useful for using connecting blocks or detecting entities. 语法:
- `q.block_neighbor_has_any_tag(x,y,z,'标签')`
- `q.relative_block_has_any_tag(x,y,z,'标签')`
`query.block_neighbor_has_any_tag` - Takes block position 示例:
`query.relative_block_has_any_tag` - Takes entity position - `q.relative_block_has_any_tag(0,-1,0,'grass')`:检测实体下方草方块
- 支持多标签检测:`q.query(0,-1,0,'grass','plant')`
The syntax for it is `q.block_neighbor_has_any_tag(x,y,z,'tag_name')` and `q.relative_block_has_any_tag(x,y,z,'tag_name')`. 可检测原版与[自定义方块标签](/wiki/blocks/block-tags)
Example:
- `q.relative_block_has_any_tag(0,-1,0,'grass')` would try to detect a block with the grass tag one block under the entity.
- `q.block_neighbor_has_any_tag(0,-1,0,'grass')` would try to detect a block with the grass tag one block under the block.
To do multiple tags you would use `q.correct_query(0,-1,0,'grass', 'plant')` with `correct_query` being replaced by the right query.
Note that this can also detect custom tags and [vanilla tags](/blocks/block-tags)

View File

@@ -1,5 +1,5 @@
--- ---
title: Shared Constructs title: 共享结构体
nav_order: 1 nav_order: 1
tags: tags:
- Stable - Stable
@@ -9,32 +9,34 @@ mentions:
- ThomasOrs - ThomasOrs
--- ---
A few JSON constructs are expressible in multiple locations in the add-ons system. # 共享结构体
## Range Objects <!--@include: @/wiki/bedrock-wiki-mirror.md-->
Range objects define a spread between two numbers.
<CodeHeader>Range Object Example</CodeHeader> 在附加包系统中部分JSON结构体可以在多个模块中通用。
```json ## 范围对象
范围对象用于定义两个数值之间的区间。
::: code-group
```json [范围对象示例]
{ {
"min": 2, "min": 2,
"max": 4 "max": 4
} }
``` ```
When provided, a random value will be selected inclusively between the minimum and maximum. Rolls are not retained; a new random value will be rolled each instance the range object would be used. The maximum must not be less than the minimum, but they may be equal to affix rolls to a specific value. 当使用该对象时,系统会在最小值(含)和最大值(含)之间随机选取一个数值。每次调用范围对象都会重新进行随机取值。最大值不可小于最小值,但允许两者相等以实现固定取值。
## Fraction Objects ## 分数对象
Fraction objects define a fraction using a numerator and denominator. 分数对象通过分子和分母定义分数关系。
<CodeHeader>Fraction Object Example</CodeHeader> ::: code-group
```json [分数对象示例]
```json
{ {
"numerator": 3, "numerator": 3,
"denominator": 5 "denominator": 5
} }
``` ```
The value used in place of the object will be the computed division, `numerator` ÷ `denominator`. Both the numerator and denominator must be at least `1`, and the denominator cannot be equal to the numerator. 该对象在计算时将使用分子除以分母的商值(即 `分子` ÷ `分母`)。分子和分母的数值必须大于等于 `1`且分母不能等于分子即不能形成值为1的分数

View File

@@ -1,6 +1,6 @@
--- ---
title: 创建船只 title: 创建船只
category: 教程 category: 巧思案例
tags: tags:
- 配方 - 配方
- 进阶 - 进阶
@@ -24,7 +24,7 @@ mentions:
## 使用运行时标识符 ## 使用运行时标识符
详细内容请参阅[运行时标识符指南](/entities/runtime-identifier)。使用运行时标识符可以实现船只的大部分硬编码行为,但会导致船只无法随玩家转向且始终面向北方。 详细内容请参阅[运行时标识符指南](/wiki/entities/runtime-identifier)。使用运行时标识符可以实现船只的大部分硬编码行为,但会导致船只无法随玩家转向且始终面向北方。
## 利用组件系统实现 ## 利用组件系统实现

View File

@@ -1,6 +1,6 @@
--- ---
title: 侦测其他实体 title: 侦测其他实体
category: 教程 category: 巧思案例
tags: tags:
- 中级 - 中级
mentions: mentions:
@@ -72,7 +72,7 @@ mentions:
``` ```
::: :::
首个动画用于检测实体存在,第二个检测实体离开。可通过`/event`命令添加[虚拟组件](/entities/dummy-components)或更新[实体属性](https://learn.microsoft.com/zh-cn/minecraft/creator/documents/introductiontoentityproperties)。 首个动画用于检测实体存在,第二个检测实体离开。可通过`/event`命令添加[虚拟组件](/wiki/entities/dummy-components)或更新[实体属性](https://learn.microsoft.com/zh-cn/minecraft/creator/documents/introductiontoentityproperties)。
::: code-group ::: code-group
```json [BP/animation_controllers/pig_animation_controllers.json] ```json [BP/animation_controllers/pig_animation_controllers.json]

View File

@@ -1,6 +1,6 @@
--- ---
title: 禁用团队伤害 title: 禁用团队伤害
category: 教程 category: 巧思案例
tags: tags:
- 中级 - 中级
mentions: mentions:

View File

@@ -1,6 +1,6 @@
--- ---
title: 虚拟实体 title: 虚拟实体
category: 教程 category: 巧思案例
tags: tags:
- 初学者 - 初学者
mentions: mentions:

View File

@@ -1,6 +1,6 @@
--- ---
title: 实体攻击机制 title: 实体攻击机制
category: 教程 category: 巧思案例
mentions: mentions:
- Luthorius - Luthorius
- TheDoctor15 - TheDoctor15
@@ -27,7 +27,7 @@ tags:
### 移动机制 ### 移动机制
生物发起攻击前需要搭载多种[移动组件](/entities/entity-movement)。 生物发起攻击前需要搭载多种[移动组件](/wiki/entities/entity-movement)。
在开始配置攻击行为前,请确保实体具备基础移动和路径规划能力。 在开始配置攻击行为前,请确保实体具备基础移动和路径规划能力。
@@ -234,7 +234,7 @@ tags:
### 远程攻击 ### 远程攻击
按设定间隔发射指定[弹射物](/documentation/projectiles)。 按设定间隔发射指定[弹射物](/wiki/documentation/projectiles)。
::: code-group ::: code-group
```json [原始CodeHeader的值] ```json [原始CodeHeader的值]
@@ -391,7 +391,7 @@ tags:
### 模式切换系统 ### 模式切换系统
通过[事件系统](/entities/entity-events)和组件组实现攻击模式切换。常用传感器组件: 通过[事件系统](/wiki/entities/entity-events)和组件组实现攻击模式切换。常用传感器组件:
| 传感器类型 | 说明 | | 传感器类型 | 说明 |
| ---------------------- | ----------------------- | | ---------------------- | ----------------------- |
@@ -499,7 +499,7 @@ tags:
### 动画资源 ### 动画资源
建议使用[Blockbench](/guide/blockbench)制作动画,需在资源包中包含: 建议使用[Blockbench](/wiki/guide/blockbench)制作动画,需在资源包中包含:
- animations文件夹实体动画定义 - animations文件夹实体动画定义
- animation_controllers文件夹动画控制器 - animation_controllers文件夹动画控制器

View File

@@ -1,6 +1,6 @@
--- ---
title: 实体事件 title: 实体事件
category: 综合 category: 基础
mentions: mentions:
- ChibiMango - ChibiMango
- SirLich - SirLich

View File

@@ -1,6 +1,6 @@
--- ---
title: 实体手持物品 title: 实体手持物品
category: 教程 category: 巧思案例
tags: tags:
- 中等难度 - 中等难度
mentions: mentions:

View File

@@ -1,6 +1,6 @@
--- ---
title: 实体行为包入门指南 title: 实体行为包入门指南
category: 基础知识 category: 基础
nav_order: 1 nav_order: 1
tags: tags:
- 指南 - 指南
@@ -90,7 +90,7 @@ _无法_创建自定义组件。所有组件列表由微软硬编码实现并对
所有组件组均为自定义创建,不可直接引用其他实体的组件组。 所有组件组均为自定义创建,不可直接引用其他实体的组件组。
在原版Minecraft实体中组件组使用`minecraft:`前缀命名(如示例中的`minecraft:cat_persian`。但需特别注意这些_并非_组件。开发者可自由使用任意命名规则例如上文中的`wiki:example_group`。更多命名空间信息请参阅[此文档](/concepts/namespaces)。 在原版Minecraft实体中组件组使用`minecraft:`前缀命名(如示例中的`minecraft:cat_persian`。但需特别注意这些_并非_组件。开发者可自由使用任意命名规则例如上文中的`wiki:example_group`。更多命名空间信息请参阅[此文档](/wiki/concepts/namespaces)。
放在组件组中的组件不会自动生效,必须通过事件激活才能影响实体行为。多个组件组可同时生效。 放在组件组中的组件不会自动生效,必须通过事件激活才能影响实体行为。多个组件组可同时生效。
@@ -163,7 +163,7 @@ _仅能对组件组进行添加/移除操作_无法直接操作单个组件
当玩家与该实体交互时,将触发`"wiki:on_interact"`事件,添加`"wiki:interacted"`组件组,从而激活缩放效果。 当玩家与该实体交互时,将触发`"wiki:on_interact"`事件,添加`"wiki:interacted"`组件组,从而激活缩放效果。
想深入了解事件的更多用法,请参阅[实体事件](/entities/entity-events)页面。 想深入了解事件的更多用法,请参阅[实体事件](/wiki/entities/entity-events)页面。
<BButton link="/entities/entity-events">实体事件详解</BButton> <BButton link="/entities/entity-events">实体事件详解</BButton>

View File

@@ -1,6 +1,6 @@
--- ---
title: 实体资源包入门指南 title: 实体资源包入门指南
category: 基础指南 category: 基础
nav_order: 2 nav_order: 2
tags: tags:
- 新手教程 - 新手教程
@@ -22,7 +22,7 @@ mentions:
资源包中的实体文件定义了构成实体视觉效果的各种资源引用,同时包含了如何渲染这些视觉元素的详细逻辑。 资源包中的实体文件定义了构成实体视觉效果的各种资源引用,同时包含了如何渲染这些视觉元素的详细逻辑。
本文将分解实体文件的每个组成部分并进行详细说明。如需创建自定义实体的完整指引,请参考我们的[新手教程](/guide/custom-entity)。 本文将分解实体文件的每个组成部分并进行详细说明。如需创建自定义实体的完整指引,请参考我们的[新手教程](/wiki/guide/custom-entity)。
## 文件大纲 ## 文件大纲
@@ -69,7 +69,7 @@ mentions:
这里的`default``invisible`是简称,分别指向`spider``spider_invisible`材质。需要注意的是单纯的简称定义并不会告知实体何时使用不同材质。 这里的`default``invisible`是简称,分别指向`spider``spider_invisible`材质。需要注意的是单纯的简称定义并不会告知实体何时使用不同材质。
[预置材质列表](/documentation/materials)可供参考。[自定义材质教程](/visuals/materials)适合进阶开发者。 [预置材质列表](/wiki/documentation/materials)可供参考。[自定义材质教程](/wiki/visuals/materials)适合进阶开发者。
## 纹理配置 ## 纹理配置
纹理Textures是映射到模型表面的图像文件。此部分同样使用简称定义系统 纹理Textures是映射到模型表面的图像文件。此部分同样使用简称定义系统
@@ -85,7 +85,7 @@ mentions:
``` ```
::: :::
支持定义多状态纹理(如蜜蜂的不同状态),也可叠加纹理层(参考村民的生物群系基底+职业层组合)。详细应用技巧参见[渲染控制器章节](/entities/render-controllers)。 支持定义多状态纹理(如蜜蜂的不同状态),也可叠加纹理层(参考村民的生物群系基底+职业层组合)。详细应用技巧参见[渲染控制器章节](/wiki/entities/render-controllers)。
## 几何体格式 ## 几何体格式
几何体Geometry由Blockbench等建模工具生成的骨骼模型文件构成 几何体Geometry由Blockbench等建模工具生成的骨骼模型文件构成
@@ -123,7 +123,7 @@ mentions:
``` ```
::: :::
该示例始终使用"default"标识的各类资源。进阶用法可支持动态切换纹理与隐藏模型部件,详情参阅[渲染控制器指南](/entities/render-controllers)。 该示例始终使用"default"标识的各类资源。进阶用法可支持动态切换纹理与隐藏模型部件,详情参阅[渲染控制器指南](/wiki/entities/render-controllers)。
在实体文件中通过标识符指定渲染控制器: 在实体文件中通过标识符指定渲染控制器:
@@ -246,7 +246,7 @@ mentions:
``` ```
::: :::
[自定义粒子教程](/particles/particles) | [动画效果应用](/visuals/animation-effects) [自定义粒子教程](/wiki/particles/particles) | [动画效果应用](/wiki/visuals/animation-effects)
## 生成蛋设置 ## 生成蛋设置
生成蛋Spawn Egg支持纯色或自定义纹理两种风格 生成蛋Spawn Egg支持纯色或自定义纹理两种风格

View File

@@ -1,6 +1,6 @@
--- ---
title: 实体移动 title: 实体移动
category: 教程 category: 巧思案例
mentions: mentions:
- SirLich - SirLich
- sermah - sermah
@@ -33,9 +33,9 @@ mentions:
| 组件 | 说明 | | 组件 | 说明 |
| ---------------------------------------------------------------------------------------------------- | ----------------------------- | | ---------------------------------------------------------------------------------------------------- | ----------------------------- |
| [minecraft:movement](/entities/vanilla-usage-components#movement) | 设置基础移动速度(必需组件) | | [minecraft:movement](/wiki/entities/vanilla-usage-components#movement) | 设置基础移动速度(必需组件) |
| [minecraft:underwater_movement](/entities/vanilla-usage-components#underwater-movement) | 设置水下移动速度 | | [minecraft:underwater_movement](/wiki/entities/vanilla-usage-components#underwater-movement) | 设置水下移动速度 |
| [minecraft:flying_speed](/entities/vanilla-usage-components#flying-speed) | 设置空中飞行速度 | | [minecraft:flying_speed](/wiki/entities/vanilla-usage-components#flying-speed) | 设置空中飞行速度 |
所有实体必须包含`minecraft:movement`组件。其他两个组件按需添加。 所有实体必须包含`minecraft:movement`组件。其他两个组件按需添加。
@@ -116,7 +116,7 @@ mentions:
### 路径规划 ### 路径规划
实现实体自动寻路是常用需求。推荐使用通过"诱饵实体"Marker进行引导的方案。若需要创建诱饵实体请参考[虚拟实体教程](/entities/dummy-entities)。 实现实体自动寻路是常用需求。推荐使用通过"诱饵实体"Marker进行引导的方案。若需要创建诱饵实体请参考[虚拟实体教程](/wiki/entities/dummy-entities)。
#### 实现思路 #### 实现思路

View File

@@ -1,6 +1,6 @@
--- ---
title: 实体属性 title: 实体属性
category: 常规 category: 基础
tags: tags:
- 实验性 - 实验性
mentions: mentions:

View File

@@ -1,6 +1,6 @@
--- ---
title: 飞行实体的控制方法 title: 飞行实体的控制方法
category: 教程 category: 巧思案例
tags: tags:
- 配方 - 配方
- 中级 - 中级

View File

@@ -0,0 +1,10 @@
---
title: 实体 Entities
categories:
- title: 基础
color: blue
- title: 巧思案例
color: green
- title: 文档
color: red
---

View File

@@ -1,6 +1,6 @@
--- ---
title: AOE云区域效果介绍 title: AOE云区域效果介绍
category: 教程 category: 巧思案例
tags: tags:
- 中阶 - 中阶
mentions: mentions:
@@ -18,7 +18,7 @@ mentions:
区域效果云具备以下可被利用的特性: 区域效果云具备以下可被利用的特性:
- 作为[虚拟实体](/entities/dummy-entities),它们在性能表现优异,几乎不影响帧率,且完全静态且不与世界发生碰撞。这使其非常适用于需要围绕玩家或精确定位的场景。 - 作为[虚拟实体](/wiki/entities/dummy-entities),它们在性能表现优异,几乎不影响帧率,且完全静态且不与世界发生碰撞。这使其非常适用于需要围绕玩家或精确定位的场景。
- 不会向客户端发送更新。生成后视觉上会定格在初始位置直至消失,但仍可通过指令自由移动。 - 不会向客户端发送更新。生成后视觉上会定格在初始位置直至消失,但仍可通过指令自由移动。
- 能以高度可配置的方式施加任何药水效果(精准到游戏刻的持续时间设定,调节环境效果、屏幕提示显示、粒子发射等属性)。 - 能以高度可配置的方式施加任何药水效果(精准到游戏刻的持续时间设定,调节环境效果、屏幕提示显示、粒子发射等属性)。
- 具有运行时标识符`minecraft:area_effect_cloud`的实体将继承相同属性。 - 具有运行时标识符`minecraft:area_effect_cloud`的实体将继承相同属性。
@@ -27,7 +27,7 @@ mentions:
投射物组件支持在命中时生成区域效果云。Minecraft正是通过此机制实现投掷滞留药水生成AOE云。 投射物组件支持在命中时生成区域效果云。Minecraft正是通过此机制实现投掷滞留药水生成AOE云。
[投射物组件文档](/documentation/projectiles#spawn-aoe-cloud) [投射物组件文档](/wiki/documentation/projectiles#spawn-aoe-cloud)
## 方法二NBT编辑 ## 方法二NBT编辑
@@ -49,7 +49,7 @@ mentions:
``` ```
::: :::
结构文件编辑指南请参考:[.mcstructure文件解析](/nbt/mcstructure) 结构文件编辑指南请参考:[.mcstructure文件解析](/wiki/nbt/mcstructure)
### NBT数据格式 ### NBT数据格式

View File

@@ -1,6 +1,6 @@
--- ---
title: 无敌实体 title: 无敌实体
category: 教程 category: 巧思案例
tags: tags:
- beginner - beginner
mentions: mentions:

View File

@@ -1,6 +1,6 @@
--- ---
title: 看向实体 title: 看向实体
category: 教程 category: 巧思案例
tags: tags:
- 中级 - 中级
mentions: mentions:

View File

@@ -1,6 +1,6 @@
--- ---
title: NPC 对话框 title: NPC 对话框
category: 通用 category: 基础
tags: tags:
- 中级 - 中级
参与贡献: 参与贡献:

View File

@@ -1,6 +1,6 @@
--- ---
title: 渲染控制器 title: 渲染控制器
category: 常规 category: 基础
tags: tags:
- beginner - beginner
mentions: mentions:
@@ -222,7 +222,7 @@ mentions:
#### 动态分层进阶 #### 动态分层进阶
通过添加更多纹理数组和使用虚拟组件dummy components作为索引可实现更复杂的动态分层效果。关于虚拟组件的详细信息请参阅[此文档](/entities/dummy-components)。 通过添加更多纹理数组和使用虚拟组件dummy components作为索引可实现更复杂的动态分层效果。关于虚拟组件的详细信息请参阅[此文档](/wiki/entities/dummy-components)。
### 动态几何体切换 ### 动态几何体切换

Some files were not shown because too many files have changed in this diff Show More