完整版BedrockWiki镜像!

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

View File

@@ -1,5 +1,5 @@
---
title: Molang Queries
title: Molang 查询
toc_max_level: 2
mentions:
- SirLich
@@ -17,142 +17,142 @@ mentions:
- 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
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
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 |
| 1 | Chestplace |
| 2 | Leggings |
| 3 | Boots |
| 参数值 | 装备槽位 |
| ------ | ---------- |
| 0 | 头盔 |
| 1 | 胸甲 |
| 2 | 护腿 |
| 3 | 靴子 |
### Y
### Y 参数(常规)
| Argument | Type |
| -------- | --------------------- |
| -1 | none |
| 0 | Leather armor piece |
| 1 | Chain armor piece |
| 2 | Iron armor piece |
| 3 | Diamond armor piece |
| 4 | Gold armor piece |
| 5 | Elytra |
| 6 | Turtle helmet |
| 7 | Netherite armor piece |
| 参数值 | 材质类型 |
| ------ | ------------------ |
| -1 | 无装备 |
| 0 | 皮革护甲 |
| 1 | 锁链护甲 |
| 2 | 铁护甲 |
| 3 | 钻石护甲 |
| 4 | 金护甲 |
| 5 | 鞘翅 |
| 6 | 海龟壳头盔 |
| 7 | 下界合金护甲 |
### Y for horses
### Y 参数(马匹)
| Argument | Type |
| -------- | --------------------- |
| 1 | Leather armor piece |
| 2 | Iron armor piece |
| 3 | Gold armor piece |
| 4 | Diamond armor piece |
| 参数值 | 材质类型 |
| ------ | ------------------ |
| 1 | 皮革马铠 |
| 2 | 铁马铠 |
| 3 | 金马铠 |
| 4 | 钻石马铠 |
### Example
### 示例
`query.armor_texture_slot(3) == 1`: queries for Iron Boots.
`query.armor_texture_slot(3) == 1`:检测是否穿着铁靴子
## 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 |
| 1 | Chestplace |
| 2 | Leggings |
| 3 | Boots |
| 参数值 | 装备槽位 |
| ------ | ---------- |
| 0 | 头盔 |
| 1 | 胸甲 |
| 2 | 护腿 |
| 3 | 靴子 |
### Y
### Y 参数(推测值)
Unknown, possibly:
| Argument | Slot |
| -------- | -------------------------- |
| 0 | Default armor material |
| 1 | Enchanted armor material |
| 2 | Leather armor material |
| 3 | Leather enchanted material |
| 参数值 | 材质类型 |
| ------ | ---------------------- |
| 0 | 默认护甲材质 |
| 1 | 附魔护甲材质 |
| 2 | 皮革护甲材质 |
| 3 | 附魔皮革护甲材质 |
## 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 |
| 1 | Chestplace |
| 2 | Leggings |
| 3 | Boots |
| 参数值 | 装备槽位 |
| ------ | ---------- |
| 0 | 头盔 |
| 1 | 胸甲 |
| 2 | 护腿 |
| 3 | 靴子 |
### Channel
### Channel 参数
| Argument | Slot |
| -------- | ------------- |
| 0 | Red channel |
| 1 | Green channel |
| 2 | Blue channel |
| 3 | Alpha channel |
| 参数值 | 颜色通道 |
| ------ | -------------- |
| 0 | 红色通道 |
| 1 | 绿色通道 |
| 2 | 蓝色通道 |
| 3 | 透明度通道 |
### Color
### 返回值
Query returns color value in specified channel.
返回指定通道的颜色值0-1范围
## query.get_equipped_item_name
:::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
:::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).
Needs to be used in special conditions.
当实体显示名称匹配时返回true需使用OnixClient等工具查看第三方视角名称需在特定条件下使用
<Spoiler title="Show">
<Spoiler title="展开示例">
<CodeHeader>animation_controllers/ac.json</CodeHeader>
```json
::: code-group
```json [animation_controllers/ac.json]
{
"format_version": "1.10.0",
"animation_controllers": {
@@ -174,7 +174,7 @@ Needs to be used in special conditions.
],
"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>
## query.is_name_any
Formatted like: `query.get_name('Name1', 'Name2')`.
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.
语法格式:`query.is_name_any('名称1', '名称2')`
<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",
"animation_controllers": {
@@ -219,7 +218,7 @@ Needs to be used in special conditions.
],
"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>
## 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.offhand` | 0 | Offhand slot for things like `Shield`, `Totem of Undying` or a `Map` |
| `slot.armor.head` | 0 | Head armor piece |
| `slot.armor.chest` | 0 | Chestplate armor piece |
| `slot.armor.legs` | 0 | Leggings armor piece |
| `slot.armor.feet` | 0 | Boots armor piece |
| `slot.armor` | 0 | Horse armor |
| `slot.saddle` | 0 | Saddle slot |
| `slot.hotbar` | 0 to 8 | Player hotbar slots |
| `slot.inventory` | 0+ (varies) | Entities that has an inventory, like the player, minecart with chests, donkey, etc. |
| `slot.enderchest` | 0 to 26 | Ender chest inventory for players only |
可用槽位列表:
| 槽位名称 | 槽位数 | 说明 |
| -------------------- | ------ | ----------------------------- |
| `slot.weapon.mainhand` | 0 | 主手持握物品 |
| `slot.weapon.offhand` | 0 | 副手(盾牌、地图等) |
| `slot.armor.head` | 0 | 头部护甲 |
| `slot.armor.chest` | 0 | 胸甲 |
| `slot.armor.legs` | 0 | 护腿 |
| `slot.armor.feet` | 0 | 靴子 |
| `slot.armor` | 0 | 马铠 |
| `slot.saddle` | 0 | 鞍具 |
| `slot.hotbar` | 0-8 | 玩家快捷栏 |
| `slot.inventory` | 可变 | 实体库存(箱子矿车、驴等) |
| `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;});`
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.
示例代码:
```molang
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
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
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.snacking`
检测实体是否处于"进食"状态(不适用于玩家)。需配合以下组件使用:
- `minecraft:behavior.eat_carried_item`
- `minecraft:behavior.snacking`
## 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
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
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
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:
- Player is walking: around 0.86
- Player is sprinting: 1.0
- Player is sprinting and jumping: 0.35
- Player is walking on fire: 1.0
- Player is sprinting on fire: 1.0
- Player is sprinting and jumping on fire: 0.525
参考值:
- 行走约0.86
- 疾跑1.0
- 疾跑跳跃0.35
- 着火行走1.0
- 着火疾跑:1.0
- 着火疾跑跳跃0.525
## 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
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:
- Entity is summoned: value is 0
- Entity is ignited: value is 0 and starts counting up 1 every tick
- 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.
计时规则:
- 实体生成0
- 点燃开始递增1刻/次)
- 灭火重置0并继续递增
- 重复点燃/灭火:每次状态变化重置计时
## 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
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
### 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
Evaluates to true when a `knockback_roar` attack is happening.
当实体执行`knockback_roar`攻击时返回true
## 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
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
Returns the time of day (midnight=0.0, sunrise=0.25, noon=0.5, sunset=0.75) of the dimension the entity is in.
Day time is calculated via this formula:
返回维度时间(午夜=0.0,日出=0.25,正午=0.5,日落=0.75
`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 |
| ------------------- | -------- |
| 0.00 | 18000 |
| 0.01 | 18240 |
| 0.02 | 18480 |
| 0.03 | 18720 |
| 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 |
| query.time_of_day | 游戏刻数 |
| ----------------- | -------- |
| 0.00 | 18000 |
| 0.25 | 0 |
| 0.50 | 6000 |
| 0.75 | 12000 |
| ... | ... |
Credit: [Analysis of query.time_of_day](https://gist.github.com/DoubleF3lix/a03afde0a979dfa41e8525ee92f12ca5)
*完整表格详见原文档*
</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
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
Identical behavior to `variable.short_arm_offset_right` except it references the player leftarm bone.
功能同`variable.short_arm_offset_right`,对应左臂骨骼
## 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:
```
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.yNorm = query.movement_direction(1) / variable.mag;
variable.zNorm = query.movement_direction(2) / variable.mag;
归一化处理示例:
```molang
variable.mag = math.sqrt(math.pow(query.movement_direction(0),2) + ...);
variable.xNorm = query.movement_direction(0)/variable.mag;
// y/z同理
```
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 |
| -------- | ---- |
| 0 | X |
| 1 | Y |
| 2 | Z |
## query.block_neighbor_has_any_tag 与 query.relative_block_has_any_tag
## 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')`.
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)
可检测原版与[自定义方块标签](/wiki/blocks/block-tags)