动作
最后更新于
最后更新于
动作系统提供了由插件提供的预设效果。不过,您也可以使用 API 添加自己的动作。此系统可应用于可以触发动作的任何地方,比如破坏作物、与种植盆互动等。
动作由三部分组成
type: 动作类型
value: 动作的参数
chance: 可选 (0~1 默认: 1)
exp_action:
type: exp
value: '{level} * 3'
下面是一个结合了条件和动作的示例。在此示例中,如果您用空手与成熟的作物互动,它将被收获。如果您用种子与之互动,它将被重新种植。
events:
interact:
action_1:
type: conditional
value:
conditions:
# 要求双手空着
requirement_1:
type: item-in-hand
value:
item: "AIR"
requirement_2:
type: item-in-hand
value:
hand: other
item: "AIR"
actions:
action_1:
type: break
value: true
action_2:
type: swing-hand
value: true
action_2:
type: conditional
value:
conditions:
requirement_1:
type: item-in-hand
value:
item: "customcrops:tomato_seeds"
amount: 1
actions:
action_1:
type: break
value: true
action_2:
type: swing-hand
value: true
action_3:
type: plant
value:
crop: tomato
point: 0
action_4:
type: item-amount
value: -1
message (向玩家发送消息)
messages_action:
type: message
value:
- '<#FF4500>[1st] 恭喜!您获得了一等奖!'
broadcast (向在线玩家发送消息)
broadcast_action:
type: broadcast
value:
- '你好!'
command (执行控制台命令)
command_action:
type: command
value:
- 'money give {player} 200'
player-command (以玩家身份执行命令)
command_action:
type: player-command
value:
- 'say 你好'
random-command (从列表中随机执行一个控制台命令)
command_action:
type: random-command
value:
- 'money give {player} 200'
- 'money give {player} 100'
- 'money give {player} 50'
close-inv (关闭玩家当前正在打开的物品栏)
close_action:
type: close-inv
actionbar
actionbar_action:
type: actionbar
value: '你好'
random-actionbar
actionbar_action:
type: random-actionbar
value:
- '嗨'
- '你好'
- '你妈'
mending (给予玩家可以用于修复的经验)
mending_action:
type: mending
value: 1
force-tick
tick_action:
type: force-tick
swing-hand
swing_action:
type: swing-hand
value: true # true = 主手 | false = 副手
exp (直接给予玩家经验以提升等级)
exp_action:
type: exp
value: 1
chain (作为一组执行动作)
chain_action:
type: exp
value:
action_1: ...
action_2: ...
chance: 0.5
delay (延迟 x 个刻)
delay_action:
type: delay
value:
delay: 20 # 以刻为单位
async: false # 是否异步运行
actions:
action_1: ...
action_2: ...
timer
timer_action:
type: timer
value:
async: false # 是否异步运行
duration: 20 # 以刻为单位
delay: 3 # 以刻为单位
period: 2 # 以刻为单位
actions:
action_1: ...
action_2: ...
hologram (在一段时间内显示全息图)
hologram_action:
type: hologram
value:
duration: 20
text: '{water_bar}'
apply-correction: true # 对每株作物应用高度校正
visible-to-all: false # 决定全息图是否能被所有玩家看到
range: 32 # 决定可见范围
y: 2
x: 0
z: 0
fake-item (在一段时间内显示虚假物品)
fake_item_action:
type: fake-item
value:
duration: 25 # 刻
position: other # other/player
item: customcrops:water_animation
use-item-display: false # 需要1.19.4+
y: 0
x: 0
z: 0
visible-to-all: true
range: 32
food
https://zh.minecraft.wiki/w/%E9%A5%A5%E9%A5%BF
food_action:
type: food
value: 2
saturation
https://zh.minecraft.wiki/w/%E9%A5%A5%E9%A5%BF
saturation_action:
type: saturation
value: 1.5
give-item
item_action:
type: give-item
value:
item: customcrops:tomato
amount: 10
item-amount
item_amount_action:
type: item-amount
value: -1
item_amount_action:
type: item-amount
value:
hand: main #main/off(这是一个可选参数)
amount: -1
durability
durability_action:
type: durability
value: -1
durability_action:
type: durability
value:
slot: OFF_HAND
amount: -1
variation (作物转变为另一种方块并停止生长)
variation_action:
type: variation
value:
gigantic:
item: gigantic_tomato
type: BLOCK # BLOCK / FURNITURE
chance: 0.02
xxx:
item: xxx
type: BLOCK
chance: 0.07
quality-crops
crop_action:
type: quality-crops
value:
to-inventory: false
min: 1
max: 4
items:
1: tomato
2: tomato_silver_star
3: tomato_golden_star
drop-item
drop_action:
type: drop-item
value:
to-inventory: false
ignore-fertilizer: true
item: tomato_seeds
min: 1
max: 2
plant
plant_action:
type: plant
value:
crop: tomato # 配置 ID
point: 0
break
break_action:
type: break
value: true # 是否触发 "break" 事件
particle
particle_action:
type: particle
value:
particle: FLAME
x: 0.5
y: 0.5
z: 0.5
count: 10
offset-x: 0.5
offset-y: 0.5
offset-z: 0.5
extra: 0.0
# 仅当粒子为 ITEM_CRACK 时有效
itemStack: customcrops:xxx
# 仅当粒子为 REDSTONE/DUST_COLOR_TRANSITION 时有效
color: 255,0,0
scale: 1
# 仅当粒子为 DUST_COLOR_TRANSITION 时有效
to-color: 0,0,255
give-money
money_action:
type: give-money
value: 100.12
take-money
money_action:
type: take-money
value: 50.54
title
title_action:
type: title
value:
title: '<green>你好!</green>'
subtitle: '这是副标题!'
fade-in: 20
stay: 30
fade-out: 10
random-title
title_action:
type: random-title
value:
titles:
- '<green>你好!</green>'
- '<green>嗨!</green>'
subtitles:
- '副标题 1'
- '副标题 2'
fade-in: 20
stay: 30
fade-out: 10
sound
sound_action:
type: sound
value:
key: 'minecraft:block.amethyst_block.place'
source: 'player'
volume: 1
pitch: 1
potion-effect
potion_action:
type: potion-effect
value:
type: 'blindness'
duration: 20
amplifier: 0
plugin-exp (来自其他插件的经验,例如工作/技能插件)
plugin_exp_action:
type: plugin-exp
value:
plugin: AureliumSkills
exp: 20
target: FARMING
conditional (只有在玩家满足条件时才能触发动作)
conditional_action:
type: conditional
value:
conditions:
requirement_1:
...
requirement_2:
...
actions:
action_1:
...
action_2:
...
priority (执行满足条件的第一个动作组。)
priority_action:
type: priority
value:
priority_1:
conditions:
...
actions:
...
priority_2:
conditions:
...
actions:
...
others:
actions:
...
level
money_action:
type: level
value: -10
spawn-entity
spawn_entity_action:
type: spawn-entity
value:
id: MythicMobs:XXX_mob # 对于原版实体,使用大写字母,例如"SHEEP"
properties:
level: 0