完善scoreboard、初步实现config

This commit is contained in:
延皓 2022-06-23 21:10:09 +08:00
parent d9b5c29fff
commit cb8c0a1079
14 changed files with 71 additions and 1 deletions

View File

@ -7,7 +7,7 @@
"type_specific": { "type_specific": {
"type": "player", "type": "player",
"advancements": { "advancements": {
"adventure" "fz:config/sneak": true
} }
}, },
"flags": { "flags": {
@ -16,5 +16,8 @@
} }
} }
} }
},
"rewards": {
"function": "fz:event/on_unsneak"
} }
} }

View File

@ -0,0 +1,9 @@
# 调用者advancement/fz:unskeak
##### 当玩家蹲起后触发此事件
function #fz:event/on_unsneak
execute if entity @s[y_rotation = 90] run function #fz:module/config/trigger
## 复位进度触发器
advancement revoke @s only fz:sneak
advancement revoke @s only fz:unsneak

View File

@ -0,0 +1 @@
scoreboard objectives add fz.module.config.trigger

View File

@ -0,0 +1,6 @@
# 调用者fz:module/config/trigger
## 如果分数大于0说明玩家点击了按钮
execute as @a if score @s fz.module.config.trigger matches 1.. run function #fz:module/config/on_click
schedule function fz:module/config/loop 1t replace

View File

@ -0,0 +1,7 @@
# 调用者#fz:module/config/on_click
##### 处理玩家点击事件并进行下一步操作
## 重新显示一次按钮
function #fz:module/config/buttons

View File

@ -0,0 +1 @@
schedule clear fz:module/config/loop

View File

@ -0,0 +1,11 @@
# 调用者#fz:module/config/on_trigger
##### 玩家抬头到最高角度并蹲起后触发此函数
## 监听计分板分数的循环schedule是为了避免1tick内执行两次但可有可无
schedule function fz:module/config/loop 0t replace
## 显示按钮
function #fz:module/config/buttons
## 设置或重制超时时间
schedule function #fz:module/config/timeout 300s replace

View File

@ -0,0 +1,5 @@
{
"__comment": "调用者fz:event/on_unsneaked当玩家蹲起后触发此事件",
"replace": false,
"values": []
}

View File

@ -0,0 +1,6 @@
{
"replace": false,
"values": [
"fz:module/config/buttons"
]
}

View File

@ -0,0 +1,7 @@
{
"__comment": "调用者fz:module/config/loop",
"replace": false,
"values": [
"fz:module/config/on_click"
]
}

View File

@ -0,0 +1,6 @@
{
"replace": false,
"values": [
"fz:module/config/timeout"
]
}

View File

@ -0,0 +1,7 @@
{
"__comment": "调用者fz:event/config/on_triggered当玩家抬头到最高角度并蹲起后触发此事件",
"replace": false,
"values": [
"fz:module/config/trigger"
]
}

View File

@ -1,4 +1,5 @@
{ {
"__comment": "调用者fz:module/scoreboard/load",
"__comment_replace": "编写扩展数据包时必须开启覆盖!", "__comment_replace": "编写扩展数据包时必须开启覆盖!",
"replace": true, "replace": true,
"__comment_values": "此处只能填入一个函数!", "__comment_values": "此处只能填入一个函数!",