tick5.mcfunction 3.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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. # ————————————————————————————————————————————————————————————————————————————
  7. # 游戏开始倒计时
  8. # ————————————————————————————————————————————————————————————————————————————
  9. # 检查人数
  10. execute store result score #ready_count mem if entity @a[team=hub_play]
  11. execute store result score #total_count mem if entity @a
  12. # 人数足够,开始倒计时
  13. execute if score #ready_count mem matches 3.. if score $start_countdown mem matches 999.. run tellraw @a [{"text":" ❇ ","color":"green"}," 游戏即将开始, 请使用第一格的物品确定自己是否参与!"]
  14. execute if score #ready_count mem matches 3.. if score $start_countdown mem matches 999.. as @a at @s run function lib:sounds/levelup
  15. execute if score #ready_count mem matches 3.. if score $start_countdown mem matches 999.. run scoreboard players set $start_countdown mem 161
  16. # 人数不足,取消倒计时
  17. execute if score #ready_count mem matches ..2 if score $start_countdown mem matches ..999 run tellraw @a [{"text":" ✖ ","color":"red"}," 准备人数不足, 游戏已取消!"]
  18. execute if score #ready_count mem matches ..2 if score $start_countdown mem matches ..999 as @a at @s run function lib:sounds/error
  19. execute if score #ready_count mem matches ..2 if score $start_countdown mem matches ..999 run scoreboard players set $start_countdown mem 9999999
  20. # 减少倒计时
  21. scoreboard players remove $start_countdown mem 1
  22. # 20s:提示未准备
  23. execute if score $start_countdown mem matches 80 run tellraw @a[team=hub_watch] [{"text":" ✒ ","color":"light_purple"}," 小提示: ",{"text":"如果要加入游戏, 请丢出第一格的灰色染料, 否则将会进入旁观模式!","color":"white"}]
  24. # 10s:播放倒计时音效
  25. scoreboard players operation #start_sec mem = $start_countdown mem
  26. scoreboard players operation #start_sec mem /= #4 mem
  27. scoreboard players operation #start_div mem = $start_countdown mem
  28. scoreboard players operation #start_div mem %= #4 mem
  29. 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
  30. # 0s:开始游戏
  31. execute if score $start_countdown mem matches 0 run function ltw:state/0/sp/start_game
  32. # 显示 ActionBar 信息
  33. execute if score $start_countdown mem matches 999.. run title @a[team=!debug] actionbar [{"text":"","color":"red"},{"score":{"name":"#ready_count","objective":"mem"}},"/",{"score":{"name":"#total_count","objective":"mem"}}," 人已准备 | 需要 3 人以开始游戏"]
  34. execute if score $start_countdown mem matches 1..998 run title @a[team=!debug] actionbar [{"text":"","color":"green"},{"score":{"name":"#ready_count","objective":"mem"}},"/",{"score":{"name":"#total_count","objective":"mem"}}," 人已准备 | 游戏将在 ",{"score":{"name":"#start_sec","objective":"mem"}}," 秒后开始"]
  35. # 替换人数过多的警告
  36. scoreboard players operation #start_div mem = $start_countdown mem
  37. scoreboard players operation #start_div mem %= #20 mem
  38. execute if score $start_countdown mem matches 1..998 if score #start_div mem matches 12.. if score #ready_count mem matches 9.. run title @a actionbar {"text":"人数过多, 将随机抽取 8 人进行游戏","color":"yellow"}