搬运一批Bedrock wiki内容,完善翻译
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
---
|
||||
title: Disabling Team-damage
|
||||
category: Tutorials
|
||||
title: 禁用团队伤害
|
||||
category: 教程
|
||||
tags:
|
||||
- intermediate
|
||||
- 中级
|
||||
mentions:
|
||||
- SirLich
|
||||
- solvedDev
|
||||
@@ -12,28 +12,32 @@ mentions:
|
||||
- TCLynx
|
||||
---
|
||||
|
||||
If you wish to disable team damage (so one cannot hurt their teammates), assign a tag with the team name to every teammate (I'm going to use `team1`, `team2`, `team3` and `team4` for this example).
|
||||
WARNING: This will NOT work on realms, the reason for this is that on realms there is a bug where modified player.json files in the behavior packs do not work, and the gmae just ignores them (This may be fixed in the future but as of 1.20.15 it is not fixed. (This also applies to older version of minecraft as well.))
|
||||
Now add this damage sensor component into your `player.json`s `"components": {}`. See comments for explanation.
|
||||
# 禁用团队伤害
|
||||
|
||||
<CodeHeader>BP/entities/player.json#components</CodeHeader>
|
||||
<!--@include: @/wiki/bedrock-wiki-mirror.md-->
|
||||
|
||||
```json
|
||||
若需禁用团队伤害(使玩家无法攻击队友),请为每位玩家分配带有队伍名称的标签(本教程将使用`team1`、`team2`、`team3`和`team4`作为示例)。
|
||||
警告:该方法在领域服(Realms)中**不可用**,原因是领域服存在一个漏洞会导致行为包中修改后的player.json文件失效,游戏会直接忽略这些修改(该问题可能在后续版本中修复,但在1.20.15版本中尚未解决。此问题也影响更早的Minecraft版本)。
|
||||
|
||||
现在将以下伤害感应器组件添加至你的`player.json`文件的`"components": {}`部分。查看注释以获取详细说明。
|
||||
|
||||
::: code-group
|
||||
```json [BP/entities/player.json#components]
|
||||
"minecraft:damage_sensor":{
|
||||
"triggers":[
|
||||
{ //if you already have a damage sensor, simply copy this object into the "triggers" array
|
||||
{ //若已有伤害感应器组件,只需将此对象复制到"triggers"数组中
|
||||
"on_damage":{
|
||||
"filters":{
|
||||
"any_of":[
|
||||
{
|
||||
"all_of":[
|
||||
{ "test":"has_tag", "value":"team1" }, //Does the player have this tag?
|
||||
{ "test":"has_tag", "subject":"other", "value":"team1" } //If so, does the entity they're trying to hurt have this tag?
|
||||
{ "test":"has_tag", "value":"team1" }, //该玩家是否拥有此标签?
|
||||
{ "test":"has_tag", "subject":"other", "value":"team1" } //被攻击实体是否拥有此标签?
|
||||
]
|
||||
},
|
||||
{
|
||||
"all_of":[
|
||||
{ "test":"has_tag", "value":"team2" }, //repeats for every team
|
||||
"all_of":[ //以下为重复结构,为每个队伍添加相同配置
|
||||
{ "test":"has_tag", "value":"team2" },
|
||||
{ "test":"has_tag", "subject":"other", "value":"team2" }
|
||||
]
|
||||
},
|
||||
@@ -58,30 +62,26 @@ Now add this damage sensor component into your `player.json`s `"components": {}`
|
||||
]
|
||||
}
|
||||
},
|
||||
"deals_damage":false //if any of these filters evaluate to true in the current attack interaction, the target will not be hurt.
|
||||
"deals_damage":false //若任意过滤器条件满足,本次攻击将不会造成伤害
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
```
|
||||
:::
|
||||
|
||||
### Projectiles
|
||||
### 抛射物处理
|
||||
|
||||
Due to the primitive filters used by projectile entities, you have to use a completely different method to achieve this.
|
||||
由于抛射物实体使用的原始滤镜系统,实现此功能需要完全不同的方法。该方案需要以下组件:
|
||||
- 标签(Tags)
|
||||
- 周期性检测(Ticking)
|
||||
- 条件伤害(Hurt on Condition)
|
||||
- 函数(Functions)
|
||||
|
||||
The process uses:
|
||||
- Tags
|
||||
- Ticking
|
||||
- Hurt on Condition
|
||||
- Functions
|
||||
|
||||
<CodeHeader>BP/entities/player.json#components</CodeHeader>
|
||||
|
||||
```json
|
||||
|
||||
//"components"
|
||||
"minecraft:timer": { //This is for applying teams to a projectile to nearby
|
||||
"time": [ //untagged projectiles, through an event.
|
||||
::: code-group
|
||||
```json [BP/entities/player.json#components]
|
||||
//"components"部分
|
||||
"minecraft:timer": { //用于通过事件给附近未标记的抛射物添加队伍标签
|
||||
"time": [
|
||||
0.0,
|
||||
0.1
|
||||
],
|
||||
@@ -91,9 +91,9 @@ The process uses:
|
||||
"target": "self"
|
||||
}
|
||||
},
|
||||
"minecraft:hurt_on_condition": { //The projectile will be unable to directly deal
|
||||
"damage_conditions": [ //damage, so instead we'll apply tags to the
|
||||
{ //player, which will trigger this . . .
|
||||
"minecraft:hurt_on_condition": { //使抛射物无法直接造成伤害
|
||||
"damage_conditions": [ //改为通过标签系统触发伤害
|
||||
{
|
||||
"filters": {
|
||||
"test": "has_tag",
|
||||
"value": "damage"
|
||||
@@ -103,9 +103,9 @@ The process uses:
|
||||
}
|
||||
]
|
||||
},
|
||||
"minecraft:damage_sensor": { //. . . which in turn, will trigger an event
|
||||
"triggers": { //to remove this tag, so the damage only
|
||||
"cause": "projectile", //happens once.
|
||||
"minecraft:damage_sensor": { //触发事件来移除damage标签
|
||||
"triggers": { //确保伤害只生效一次
|
||||
"cause": "projectile",
|
||||
"deals_damage": true,
|
||||
"on_damage": {
|
||||
"filters": {
|
||||
@@ -117,15 +117,15 @@ The process uses:
|
||||
}
|
||||
}
|
||||
|
||||
//"events"
|
||||
"wiki:projectile_team": { //The function here will apply tags depending on
|
||||
"run_command": { //which team tags the player has.
|
||||
//"events"部分
|
||||
"wiki:projectile_team": { //根据玩家队伍标签应用对应的抛射物标签
|
||||
"run_command": {
|
||||
"command": [
|
||||
"function wiki-apply_team"
|
||||
]
|
||||
}
|
||||
},
|
||||
"wiki:stop_damage": { //The event that simply removes the damage tag.
|
||||
"wiki:stop_damage": { //移除damage标签的事件
|
||||
"run_command": {
|
||||
"command": [
|
||||
"tag @s remove damage"
|
||||
@@ -133,23 +133,13 @@ The process uses:
|
||||
}
|
||||
}
|
||||
```
|
||||
:::
|
||||
|
||||
<CodeHeader>BP/functions/wiki-apply_team.mcfunction</CodeHeader>
|
||||
::: code-group
|
||||
|
||||
```
|
||||
execute @s[tag=team1] ~ ~ ~ tag @e[rm=0,r=1,c=1,type=arrow,tag=] add team1
|
||||
execute @s[tag=team2] ~ ~ ~ tag @e[rm=0,r=1,c=1,type=arrow,tag=] add team2
|
||||
execute @s[tag=team3] ~ ~ ~ tag @e[rm=0,r=1,c=1,type=arrow,tag=] add team3
|
||||
execute @s[tag=team4] ~ ~ ~ tag @e[rm=0,r=1,c=1,type=arrow,tag=] add team4
|
||||
|
||||
```
|
||||
|
||||
<CodeHeader>BP/entities/arrow.json</CodeHeader>
|
||||
|
||||
```json
|
||||
|
||||
//"components"
|
||||
"on_hit": { //On_hit, trigger an event . . .
|
||||
```json [BP/entities/arrow.json]
|
||||
//"components"部分
|
||||
"on_hit": { //击中时触发事件...
|
||||
"definition_event": {
|
||||
"affect_projectile": true,
|
||||
"event_trigger": {
|
||||
@@ -160,25 +150,35 @@ execute @s[tag=team4] ~ ~ ~ tag @e[rm=0,r=1,c=1,type=arrow,tag=] add team4
|
||||
"remove_on_hit": {}
|
||||
}
|
||||
|
||||
//"events"
|
||||
"wiki:hit": { //. . . which executes a function, applying
|
||||
"run_command": { //the damage tag to any players of a different team!
|
||||
//"events"部分
|
||||
"wiki:hit": { //...执行函数,为不同队伍玩家添加damage标签
|
||||
"run_command": {
|
||||
"command": [
|
||||
"function wiki-apply_damage"
|
||||
]
|
||||
}
|
||||
}
|
||||
```
|
||||
:::
|
||||
|
||||
<CodeHeader>BP/functions/wiki-apply_damage.mcfunction</CodeHeader>
|
||||
::: code-group
|
||||
|
||||
```mcfunction [BP/functions/wiki-apply_team.mcfunction]
|
||||
execute @s[tag=team1] ~ ~ ~ tag @e[rm=0,r=1,c=1,type=arrow,tag=] add team1
|
||||
execute @s[tag=team2] ~ ~ ~ tag @e[rm=0,r=1,c=1,type=arrow,tag=] add team2
|
||||
execute @s[tag=team3] ~ ~ ~ tag @e[rm=0,r=1,c=1,type=arrow,tag=] add team3
|
||||
execute @s[tag=team4] ~ ~ ~ tag @e[rm=0,r=1,c=1,type=arrow,tag=] add team4
|
||||
```
|
||||
:::
|
||||
|
||||
::: code-group
|
||||
|
||||
```mcfunction [BP/functions/wiki-apply_damage.mcfunction]
|
||||
execute @s[tag=team1] ~ ~ ~ tag @p[rm=0,r=1,tag=!team1] add damage
|
||||
execute @s[tag=team2] ~ ~ ~ tag @p[rm=0,r=1,tag=!team2] add damage
|
||||
execute @s[tag=team3] ~ ~ ~ tag @p[rm=0,r=1,tag=!team3] add damage
|
||||
execute @s[tag=team4] ~ ~ ~ tag @p[rm=0,r=1,tag=!team4] add damage
|
||||
|
||||
```
|
||||
:::
|
||||
|
||||
If you modify `arrow.json`, take into consideration the component groups.
|
||||
|
||||
> 注意:若修改`arrow.json`文件,请仔细考虑组件分组(component groups)的影响。
|
||||
Reference in New Issue
Block a user