tick5.mcfunction 4.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. # 让无状态玩家变为准备状态
  2. execute as @a[team=!debugging,team=!playing,team=!watching] run function ltw:state/0/state/join_watch
  3. ## 给予主大厅进度
  4. #execute as @a at @s if entity @s[x=-1,y=22,z=-29,dx=5,dy=3,dz=3] run advancement grant @s only ltw:parkour/explore1
  5. #execute as @a at @s if entity @s[x=6,y=48,z=-32,dx=4,dy=3,dz=9] run advancement grant @s only ltw:parkour/explore2
  6. #execute as @a at @s if entity @s[x=0,y=28,z=-46,distance=..4] run advancement grant @s only ltw:parkour/explore3
  7. # 隐藏/显示老板的名片
  8. execute as @e[type=piglin,tag=shop_piglin_11,tag=lobby_entity] at @s if entity @a[distance=..5] run data modify entity @s CustomNameVisible set value true
  9. execute as @e[type=piglin,tag=shop_piglin_11,tag=lobby_entity] at @s unless entity @a[distance=..5] run data modify entity @s CustomNameVisible set value false
  10. # ————————————————————————————————————————————————————————————————————————————
  11. # 游戏准备检查部分
  12. # ————————————————————————————————————————————————————————————————————————————
  13. # 检查已准备人数
  14. execute store result score $count mem if entity @a[team=playing]
  15. execute store result score #total_count mem if entity @a
  16. # 开始:提示开始
  17. execute if score $count mem matches 3.. if score #start_countdown mem matches 999.. run tellraw @a [{"text":"","color":"green"},{"text": ">> ","bold": true},"游戏即将开始, 请使用快捷栏最后一格确定自己是否参与!"]
  18. execute if score $count mem matches 3.. if score #start_countdown mem matches 999.. as @a at @s run function lib:sounds/levelup
  19. execute if score $count mem matches 3.. if score #start_countdown mem matches 999.. run scoreboard players set #start_countdown mem 121
  20. # 取消:提示取消
  21. execute if score $count mem matches ..2 if score #start_countdown mem matches ..999 run tellraw @a [{"text":"","color":"red"},{"text": ">> ","bold": true},"已准备人数不足, 游戏取消!"]
  22. execute if score $count mem matches ..2 if score #start_countdown mem matches ..999 as @a at @s run function lib:sounds/error
  23. execute if score $count mem matches ..2 if score #start_countdown mem matches ..999 run scoreboard players set #start_countdown mem 9999999
  24. # 播放音效
  25. scoreboard players remove #start_countdown mem 1
  26. scoreboard players operation #start_sec mem = #start_countdown mem
  27. scoreboard players operation #start_sec mem /= #const_4 mem
  28. scoreboard players operation #start_div mem = #start_countdown mem
  29. scoreboard players operation #start_div mem %= #const_4 mem
  30. execute if score #start_sec mem matches 1..10 if score #start_div mem matches 3 run execute as @a at @s run function lib:sounds/hit2
  31. # 20s:提示未准备
  32. execute if score #start_countdown mem matches 80 run tellraw @a[team=watching] [{"text":"","color":"red"},{"text":">> ","bold": true},"你还没有准备, 如果要参加游戏, 请丢出快捷栏最后一格的物品!"]
  33. # 10s:提示玩家数量过多
  34. execute if score #start_countdown mem matches 40 if score $count mem matches 9.. run tellraw @a [{"text":"","color":"gold"},{"text":">> ","bold": true},"已超出游戏最多支持的 8 人人数上限, 将随机抽取 8 人开始游戏!"]
  35. # 0s:开始游戏
  36. execute if score #start_countdown mem matches 0 run function ltw:state/0/start_game
  37. # 显示信息
  38. execute if score #start_countdown mem matches 1..199 run title @a[team=!debugging] actionbar [{"text":"","color":"green"},{"score":{"name":"$count","objective":"mem"}},"/",{"score":{"name":"#total_count","objective":"mem"}}," 人已准备 | ","将在 ",{"score":{"name":"#start_sec","objective":"mem"}}," 秒后开始游戏"]
  39. execute if score #start_countdown mem matches 200.. run title @a[team=!debugging] actionbar [{"text":"","color":"red"},{"score":{"name":"$count","objective":"mem"}},"/",{"score":{"name":"#total_count","objective":"mem"}}," 人已准备 | 需要 3 人以开始游戏"]