tick5.mcfunction 4.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. # 隐藏/显示 骰子房老板的名片
  2. 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
  3. 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
  4. # 调用节奏方块
  5. function lib:tempo_block/tick5
  6. # TODO: 未完成的重构
  7. ## 20s:提示未准备
  8. #execute if score $start_countdown mem matches 80 run tellraw @a[team=watching] [{"text":"","color":"red"},{"text":">> ","bold": true},"你还没有准备, 如果要参加游戏, 请丢出快捷栏最后一格的物品!"]
  9. ## 让无状态玩家变为旁观状态
  10. #execute as @a[team=!debug,team=!hub_play,team=!hub_watch] run function ltw:state/0/sp/join_watch
  11. ## 给予主大厅进度
  12. #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
  13. #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
  14. #execute as @a at @s if entity @s[x=0,y=28,z=-46,distance=..4] run advancement grant @s only ltw:parkour/explore3
  15. # ————————————————————————————————————————————————————————————————————————————
  16. # 游戏开始倒计时
  17. # ————————————————————————————————————————————————————————————————————————————
  18. # 检查人数
  19. execute store result score #ready_count mem if entity @a[team=hub_play]
  20. execute store result score #total_count mem if entity @a
  21. # 人数足够,开始倒计时
  22. execute if score #ready_count mem matches 3.. if score $start_countdown mem matches 999.. run tellraw @a [{"text":" ❇ ","color":"green"}," 游戏即将开始, 请使用第一格的物品确定自己是否参与!"]
  23. execute if score #ready_count mem matches 3.. if score $start_countdown mem matches 999.. as @a at @s run function lib:sounds/levelup
  24. execute if score #ready_count mem matches 3.. if score $start_countdown mem matches 999.. run scoreboard players set $start_countdown mem 121
  25. # 人数不足,取消倒计时
  26. execute if score #ready_count mem matches ..2 if score $start_countdown mem matches ..999 run tellraw @a [{"text":" ✖ ","color":"red"}," 准备人数不足, 开始倒计时已取消!"]
  27. execute if score #ready_count mem matches ..2 if score $start_countdown mem matches ..999 as @a at @s run function lib:sounds/error
  28. execute if score #ready_count mem matches ..2 if score $start_countdown mem matches ..999 run scoreboard players set $start_countdown mem 9999999
  29. # 20s:提示玩家数量过多
  30. execute if score $start_countdown mem matches 80 if score #ready_count mem matches 9.. run tellraw @a [{"text":" ❇ ","color":"gold"}," 准备人数已超出 8 人的人数上限, 将随机抽取 8 人进行游戏!"]
  31. # 10s:播放倒计时音效
  32. scoreboard players remove $start_countdown mem 1
  33. scoreboard players operation #start_sec mem = $start_countdown mem
  34. scoreboard players operation #start_sec mem /= #4 mem
  35. scoreboard players operation #start_div mem = $start_countdown mem
  36. scoreboard players operation #start_div mem %= #4 mem
  37. 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
  38. # 0s:开始游戏
  39. execute if score $start_countdown mem matches 0 run function ltw:state/0/start_game
  40. # 显示信息
  41. execute if score $start_countdown mem matches 1..999 run title @a[team=!debugging] actionbar [{"text":"","color":"green"},{"score":{"name":"#ready_count","objective":"mem"}},"/",{"score":{"name":"#total_count","objective":"mem"}}," 人已准备 | ","将在 ",{"score":{"name":"#start_sec","objective":"mem"}}," 秒后开始游戏"]
  42. execute if score $start_countdown mem matches 999.. run title @a[team=!debugging] actionbar [{"text":"","color":"red"},{"score":{"name":"#ready_count","objective":"mem"}},"/",{"score":{"name":"#total_count","objective":"mem"}}," 人已准备 | 需要 3 人以开始游戏"]