🪇 事件
简介
events
部分决定了哪些物品/家具/方块将在特定事件中执行预定义行为。在 events
部分下,您需要指定一个事件触发器,例如 "right_click"
表示右键点击动作。在事件触发器下方,您必须传递一个动作列表及其对应的类型。例如,command
用于执行特定命令。
# 格式1
events:
right_click:
- type: command
command: say 1
conditions:
- type: permission
permission: "craftengine.admin"
- type: command
command: say 2
conditions: []
# 格式2
events:
- on: right_click
functions:
- type: command
command: say 1
conditions:
- type: permission
permission: "craftengine.admin"
- type: command
command: say 2
conditions: []
🧨 事件触发器
物品
- break
- right_click
- left_click
- consume
方块
- break
- place
- right_click
- left_click
- step
家具
- break
- place
- right_click
警告
请注意:事件需配置在正确的区域。例如若需实现家具交互时执行指令,应将 events
置于 furniture
部分而非物品部分下。
items:
default:bench:
events: # ❌️
right_click:
- type: command
behavior:
type: furniture_item
furniture:
events: # ✅️
right_click:
- type: command
🔧 函数
取消事件
取消原始事件。
type: cancel_event
运行
按顺序运行一系列函数。这对于共享相同条件的函数非常有用。
type: run
delay: 0 # 可选; 数字; 默认值: 0
functions: # 必填; 映射列表
- type: command
- type: message
命令
以玩家或控制台身份运行命令。
type: command
command: "say 你好 <arg:player.name>" # 必填; 字符串列表/字符串
target: "self" # 可选; 枚举[all, self]/玩家选择器; 默认值: self
# 以玩家身份执行这个指令
as-player: false # 可选; 布尔; 默认值: false
# 以op身份执行这个指令,风险自担
as-op: false # 可选; 布尔; 默认值: false
# 有些自定义指令插件基于事件驱动,使用此选项可能可以兼容
as-event: false # 可选; 布尔; 默认值: false
消息
发送消息或系统动作栏消息
type: message
message: "你好 <papi:player_name>" # 必填; 字符串列表/字符串
target: "self" # 可选; 枚举[all, self]/玩家选择器
overlay: false # 可选; 默认值: false; false = 聊天框 / true = 动作栏
动作栏消息
发送一条动作栏消息
type: actionbar
actionbar: "这是一个动作栏消息" # 必填; 字符串
target: "self" # 可选; 枚举[all, self]/玩家选择器; 默认值: self
屏幕标题消息
发送一条屏幕标题消息
type: title
title: "<red>标题</red>" # 必填; 字符串
subtitle: "<Yellow>副标题</yellow>" # 必填; 字符串
fade-in: 20 # 可选; 数字; 默认值: 10
stay: 10 # 可选; 数字; 默认值: 20
fade-out: 10 # 可选; 数字; 默认值: 5
打开窗口
打开一个图形用户界面窗口
type: open_window #
gui-type: anvil # 必填; 枚举[anvil, enchantment, grindstone, loom, smithing, crafting, cartography];
title: "超级铁砧" # 可选; 字符串
target: "self" # 可选; 枚举[all, self]/玩家选择器; [默认值: self]
放置方块
放置一个方块
type: place_block
block-state: "default:chinese_lantern" # 必填; 字符串
x: <arg:block.block_x> # 可选; 数字; 默认值: <arg:position.x>
y: <arg:block.block_y> # 可选; 数字; 默认值: <arg:position.y>
z: <arg:block.block_z> # 可选; 数字; 默认值: <arg:position.z>
掉落战利品
根据给定的战利品表掉落物品
type: drop_loot
x: <arg:block.block_x> + 0.5 # 可选; 数字; 默认值: <arg:position.x>
y: <arg:block.block_y> + 0.5 # 可选; 数字; 默认值: <arg:position.y>
z: <arg:block.block_z> + 0.5 # 可选; 数字; 默认值: <arg:position.z>
loot:
pools: ...
更新交互游戏刻
更新最后一次交互结束时的游戏刻
type: update_interaction_tick
设置物品数量
设置此事件中当前物品的数量
type: set_count
add: true # 默认值: false
count: -1 # 必填; 数字
target: "self" # 可选; 枚举[all, self]/玩家选择器
设置饥饿值
设置玩家的饥饿值(0~20)
type: set_food
add: true # 可选; 枚举; 默认值: false
food: 4 # 必填; 数字
target: "self" # 可选; 枚举[all, self]/玩家选择器
设置饱和度
设置玩家的饱和度(0~10)
type: set_saturation
add: true
saturation: 2.5
target: "self" # 可选; 枚举[all,self]/玩家选择器
挥手
挥动此事件中涉及的手,或配置中指定的手
type: swing_hand
hand: main_hand # 可选; 枚举[main_hand, off_hand]; 不填会从上下文获取需要挥动的手
粒子效果
生成一个粒子效果
type: particle
particle: minecraft:end_rod # 必填; 字符串
x: "<arg:position.x>" # 可选; 数字; 默认值: <arg:position.x>
y: "<arg:position.y>" # 可选; 数字; 默认值: <arg:position.y>
z: "<arg:position.z>" # 可选; 数字; 默认值: <arg:position.z>
count: 5 # 可选; 数字; 默认值: 1
offset-x: 0.3 # 可选; 数字; 默认值: 0
offset-y: 0.3 # 可选; 数字; 默认值: 0
offset-z: 0.3 # 可选; 数字; 默认值: 0
speed: 0 # 可选; 数字; 默认值: 0
# 以下参数仅在粒子为特定类型时才有效。
# 带物品粒子选项的粒子类型:item
item: default:chinese_lantern
# 带方块粒子选项的粒子类型:block、block_marker、falling_dust、dust_pillar 和 block_crumble
block-state: default:plam_log[axis=y]
# 带幽匿块充能粒子选项的粒子类型:sculk_charge
charge: 1.5
# 带尖啸粒子选项的粒子类型:shriek
shriek: 1
# 带粉末粒子选项的粒子类型:dust
color: 255,255,255
scale: 1.0
# 带粉末颜色过渡选项的粒子类型:dust_color_transition
from: 255,255,255
to: 0,0,0
scale: 4.0
# 带振动粒子选项的粒子类型:vibration
target-x: 0
target-y: 1
target-z: 0
arrival-time: 10
# 带目标颜色粒子选项的粒子类型:trail
target-x: 0
target-y: 1
target-z: 0
duration: 10
状态效果
添加一个状态效果
type: potion_effect
potion-effect: minecraft:blindness # 必填; 字符串
duration: 20 # 可选; 数字; 默认值: 20
amplifier: 0 # 可选; 数字; 默认值: 0
ambient: false # 可选; 布尔; 是否来自信标
particles: true # 可选; 布尔
移除状态效果
移除一个状态效果
type: remove_potion_effect
potion-effect: minecraft:blindness # 如果 'all' 为 true 则为可选; 布尔
all: false # 可选; 布尔; 默认值: false
等级经验
添加技能/职业经验
type: leveler_exp
plugin: AuraSkills # 可选; 字符串
leveler: fishing # 可选; 字符串; 职业/技能 ID
count: 10 # 可选; 数字
设置冷却时间
为玩家设置冷却时间
type: set_cooldown
time: 1m30s
id: my_cooldown_id # 可选; 字符串
add: false # 可选; 布尔; 默认值: false (是否累加冷却时间)
移除冷却时间
为玩家移除冷却时间
type: remove_cooldown
id: my_cooldown_id # 如果 'all' 为 true 则为可选; 字符串
all: false # 可选; 布尔; 默认值: false
播放声音
播放一个声音
type: play_sound
sound: minecraft:xxxx.xxx
x: <arg:position.x> # 如果使用了 'target' 参数则为可选; 数字
y: <arg:position.y> # 如果使用了 'target' 参数则为可选; 数字
z: <arg:position.z> # 如果使用了 'target' 参数则为可选; 数字
target: "self" # 可选; 枚举[all, self]/玩家选择器
pitch: 1 # 可选; 数字; 默认值: 1
volume: 1 # 可选; 数字; 默认值: 1
source: master # 可选; 枚举[music, master, record, weather, block, hostile, neutral, player, ambient, voice, ui]; 默认值: master
MythicMobs 技能
释放 MythicMobs 技能
type: mythic_mobs_skill
skill: skill_id # 必填; 字符串
power: 1.0 # 可选; 数字; 默认值: 1.0
生成家具
生成一个家具
type: spawn_furniture
furniture-id: "default:bench" # 可选; 字符串
x: <arg:position.x> # 可选; 数字; 默认值: <arg:position.x>
y: <arg:position.y> # 可选; 数字; 默认值: <arg:position.y>
z: <arg:position.z> # 可选; 数字; 默认值: <arg:position.z>
pitch: <arg:position.pitch> # 可选; 数字; 默认值: <arg:position.pitch>
yaw: <arg:position.yaw> # 可选; 数字; 默认值: <arg:position.yaw>
anchor-type: ground # 可选; 枚举[ground,ceiling,wall]
play-sound: true # 可选; 布尔; 默认值: true
移除家具
移除一个家具
type: remove_furniture
drop-loot: true # 可选; 布尔; 默认值: true
play-sound: true # 可选; 布尔; 默认值: true
替换家具
替换一个家具
type: replace_furniture
furniture-id: "default:bench"
x: <arg:furniture.x> # 可选; 数字; 默认值: <arg:furniture.x>
y: <arg:furniture.y> # 可选; 数字; 默认值: <arg:furniture.y>
z: <arg:furniture.z> # 可选; 数字; 默认值: <arg:furniture.z>
pitch: <arg:furniture.pitch> # 可选; 数字; 默认值: <arg:furniture.pitch>
yaw: <arg:furniture.yaw> # 可选; 数字; 默认值: <arg:furniture.yaw>
anchor-type: ground # 可选; 枚举[ground,ceiling,wall]
drop-loot: true # 默认值: true
play-sound: true # 默认值: true
传送
传送至指定地点
type: teleport
x: <arg:position.x> # 必填; 数字
y: 100 # 必填; 数字
z: <arg:position.z> + 5 # 必填; 数字
pitch: <arg:player.pitch> # 可选; 默认值: 0
yaw: <arg:player.yaw> # 可选; 默认值: 0
world: world # 可选; 字符串;
弹窗
发送一个弹窗
type: toast
toast: 这是一个弹窗 # 必填; 字符串
advancement-type: goal # 可选; 枚举[goal,task,challenge]; 默认值: goal
icon: minecraft:stone # 必填; 字符串
信息
更多函数即将到来...