-
Notifications
You must be signed in to change notification settings - Fork 0
LYOfficial edited this page Jan 23, 2023
·
2 revisions
本页解释了别名,这是一种高级 YAML 技术,它可以让您不必在 drops 文件中重复相同的参数或参数组。 别名通常在 aliases: 文件的 aliases 部分中定义,但事实上,它们可以在任何地方定义。
YAML 允许你使用一种叫做“别名”的高级工具。 这些技巧适用于任何以 YAML 编写的配置文件。
别名允许您定义一个字符串/列表/数字甚至整个数据块,为其命名并在以后仅使用该名称调用它。 调用别名时,您甚至可以修改数据的子部分。
一些例子如下:
aliases:
# 仅定义单个数据的别名示例
- &environ [DAMAGE_ENTITY_EXPLOSION, DAMAGE_FIRE, DAMAGE_CONTACT, DAMAGE_DROWNING, DAMAGE_FALL, DAMAGE_SUFFOCATION]
# 定义数据块的别名示例,使用先前定义的别名
- &environDropNothing
tool: *environ
drop: NOTHING
exclusive: 1 # 这意味着如果发生这种掉落 - 其他都不会,除非他们有相同的数字
otherblocks:
CREATURE_ZOMBIE:
- &environDropNothing # 停止怪物掉落 - 无自然掉落
# 继续任何其他自定义掉落....
以下示例旨在让您在修改别名的一部分时轻松地在不同方块之间复制类似的配置。 请注意 <:: (“合并键”)的使用,因为它允许您修改别名。
aliases:
- &damageall
tool: ALL
drop: AIR
damageattacker: 1
- &dropnothing
tool: ALL
drop: NOTHING
chance: 100
- &defaultdroplow # 这个别名掉落默认物品的几率很小
tool: ALL
drop: DEFAULT
chance: 5
- &specitem # 这个别名专门用来覆盖“工具”
condition later
tool: ALL
drop: DEFAULT
chance: 100
exclusive: 1
otherblocks:
#石头
STONE:
- *dropnothing
- *damageall
- *defaultdroplow
- <<: *specitem
tool: ANY_PICKAXE
DIRT:
- *dropnothing
- *damageall
- *defaultdroplow
- <<: *specitem
tool: ANY_SPADE
又是一个更高级的示例。 注意 &specitem-pick
是如何通过修改 &specitem
别名来定义的。
# enelar 的原始示例
别名:
#1) 用手伤害攻击者,方块没有任何变化。 (&damageall)
#2) 使用错误的工具,方块没有改变。 (&wrongtool)
#3) 使用镐,每个材质的镐都有机会掉落,总是掉落圆石。
#4) 杀死其他玩家。 (用泥土、沙子、鱼、种子等击杀) (&atata)
- &wrongtool
tool: ANY
drop: DENY
exclusive: wrong
- &atata
damageattacker: 20
tool: ANY
drop: NOTHING
toolexcept: [ANY_SPADE, ANY_AXE, ANY_HOE, ANY_PICKAXE]
replacementblock: DEFAULT
message: "WTF! Wrong item... Non RP playing..."
exclusive: atata
- &damageall
tool: ALL
drop: AIR
replacementblock: DEFAULT
message: "Oh, my fingers!"
damageattacker: 1
- &defaultdroplow
tool: ALL
drop: DEFAULT
chance: 5
- &specitem
tool: ALL
drop: DEFAULT
chance: 100
exclusive: 1
- &dropstone
tool: ANY_PICKAXE
drop: COBBLESTONE
exclusive: 1
COAL_ORE:
- <<: *wrongtool
toolexcept: ANY_PICKAXE
- <<: *damageall
damageattacker: 8
- <<: *atata
- <<: *dropstone
- &specitem-pick
<<: *specitem
tool: ANY_PICKAXE
chance: 40
permissions: race_a.COAL_ORE
- <<: *specitem-pick
chance: 60
permissions: race_h.COAL_ORE
- <<: *specitem-pick
chance: 60
permissions: race_t.COAL_ORE
- <<: *specitem-pick
chance: 5
permissions: race_r.COAL_ORE
如果你错过了它,这里是定义 &specitem-pick
的特定部分:
- &specitem-pick # 注意:这个别名必须独占一行
<<: *specitem # 请记住,<<: 允许您修改别名
tool: ANY_PICKAXE # 将工具从 &specitem 的值 ALL 更改为 ANY_PICKAXE
别名也可以与 DropGroups 一起使用,以创建更复杂的别名。
aliases:
- &map_and_compass
dropgroup: mapcompass
chance: 0.01%
drops:
- drop: MAP
- drop: COMPASS
otherblocks:
SAND:
- *map_and_compass
这可能有更多实际应用 (因为您可能不想多次定义 mapcompass drop). 如果我想到一个更实际的例子,我可能会在以后改进这个例子。