فهرست منبع

初始大厅加入游戏系统究极重构

HerobrineXia 6 سال پیش
والد
کامیت
afac4d4960

+ 1 - 2
data/item/functions/disable_slot/check_slot.mcfunction

@@ -7,5 +7,4 @@ execute unless data entity @s Inventory[{Slot:8b,tag:{game_item:1b}}] unless dat
 execute unless data entity @s Inventory[{Slot:8b,tag:{LockItem:1b,LockSlot:8b},Count:1b}] if data entity @s Inventory[{tag:{LockItem:1b,LockSlot:8b},Count:1b}] run clear @s red_dye{LockItem:1b,LockSlot:8b}
 
 # 清除临时物品
-clear @a red_dye{LockTempItem:1b}
-kill @e[type=item,tag=LockTempItem,nbt={Item:{tag:{LockTempItem:1b}}}]
+clear @a red_dye{LockTempItem:1b}

+ 1 - 5
data/item/functions/disable_slot/disable_slot_7.mcfunction

@@ -1,7 +1,3 @@
 clear @s red_dye{LockItem:1b,LockSlot:7b}
-execute if data entity @s Inventory[{Slot:7b}] unless data entity @s Inventory[{Slot:7b,tag:{LockItem:1b}}] at @s run summon item ~ ~ ~ {Item:{id:"red_dye",Count:1b,tag:{LockTempItem:1b,display:{Name:'{"text":"非法物品","color":"red"}'}}},Tags:["LockTempItem"]}
-data modify entity @e[type=item,tag=LockTempItem,limit=1] Item set from entity @s Inventory[{Slot:7b}]
-data modify entity @e[type=item,tag=LockTempItem,limit=1] PickupDelay set value 0
-data modify entity @e[type=item,tag=LockTempItem,limit=1] Thrower set from entity @s UUID
-execute as @e[type=item,tag=LockTempItem,limit=1] run function item:disable_throw
+execute if data entity @s Inventory[{Slot:7b}] unless data entity @s Inventory[{Slot:7b,tag:{LockItem:1b}}] at @s run function item:return_slot/return_slot_7
 replaceitem entity @s hotbar.7 red_dye{LockItem:1b,LockSlot:7b,display:{Name:'{"text":"已锁定","color":"red","bold":true,"italic":false}'}}

+ 1 - 5
data/item/functions/disable_slot/disable_slot_8.mcfunction

@@ -1,7 +1,3 @@
 clear @s red_dye{LockItem:1b,LockSlot:8b}
-execute if data entity @s Inventory[{Slot:8b}] unless data entity @s Inventory[{Slot:8b,tag:{LockItem:1b}}] at @s run summon item ~ ~ ~ {Item:{id:"red_dye",Count:1b,tag:{LockTempItem:1b,display:{Name:'{"text":"非法物品","color":"red"}'}}},Tags:["LockTempItem"]}
-data modify entity @e[type=item,tag=LockTempItem,limit=1] Item set from entity @s Inventory[{Slot:8b}]
-data modify entity @e[type=item,tag=LockTempItem,limit=1] PickupDelay set value 0
-data modify entity @e[type=item,tag=LockTempItem,limit=1] Thrower set from entity @s UUID
-execute as @e[type=item,tag=LockTempItem,limit=1] run function item:disable_throw
+execute if data entity @s Inventory[{Slot:8b}] unless data entity @s Inventory[{Slot:8b,tag:{LockItem:1b}}] at @s run function item:return_slot/return_slot_8
 replaceitem entity @s hotbar.8 red_dye{LockItem:1b,LockSlot:8b,display:{Name:'{"text":"已锁定","color":"red","bold":true,"italic":false}'}}

+ 6 - 0
data/item/functions/lobby_state/check_slot.mcfunction

@@ -0,0 +1,6 @@
+# 第八格
+execute unless data entity @s[tag=lobby_watch] Inventory[{Slot:8b,tag:{lobby_item:1b,lobby_watch:1b}}] run function item:lobby_state/join_game
+execute unless data entity @s[tag=lobby_ready] Inventory[{Slot:8b,tag:{lobby_item:1b,lobby_ready:1b}}] run function item:lobby_state/join_watch
+
+# 清除临时物品
+clear @s red_dye{LockTempItem:1b}

+ 9 - 0
data/item/functions/lobby_state/join_game.mcfunction

@@ -0,0 +1,9 @@
+# 处理第七格
+clear @s gray_dye{lobby_item:1b,lobby_watch:1b}
+kill @e[type=item,nbt={Item:{id:"minecraft:gray_dye",tag:{lobby_item:1b,lobby_watch:1b}}}]
+execute if data entity @s Inventory[{Slot:8b}] unless data entity @s Inventory[{Slot:8b,tag:{lobby_item:1b,lobby_watch:1b}}] at @s run function item:disable_slot/disable_slot_8
+replaceitem entity @s hotbar.8 lime_dye{lobby_item:1b,lobby_ready:1b,display:{Name:'{"text":"已准备(Q切换)","color":"white","bold":true,"italic":false}',Lore:['{"text":"你下一局将参与比赛(如果人数超过8人有概率无法参加)","color":"green","bold":true,"italic":false}']}}
+
+# 处理数据
+tag @s remove hub_watch
+tag @s add hub_ready

+ 9 - 0
data/item/functions/lobby_state/join_watch.mcfunction

@@ -0,0 +1,9 @@
+# 处理第七格
+clear @s lime_dye{lobby_item:1b,lobby_ready:1b}
+kill @e[type=item,nbt={Item:{id:"minecraft:lime_dye",tag:{lobby_item:1b,lobby_ready:1b}}}]
+execute if data entity @s Inventory[{Slot:8b}] unless data entity @s Inventory[{Slot:8b,tag:{lobby_item:1b,lobby_ready:1b}}] at @s run function item:disable_slot/disable_slot_8
+replaceitem entity @s hotbar.8 gray_dye{lobby_item:1b,lobby_watch:1b,display:{Name:'{"text":"未准备(Q切换)","color":"white","bold":true,"italic":false}',Lore:['{"text":"你下一局将旁观比赛","color":"gray","bold":true,"italic":false}']}}
+
+# 处理数据
+tag @s remove hub_ready
+tag @s add hub_watch

+ 6 - 0
data/item/functions/return_slot/return_slot_7.mcfunction

@@ -0,0 +1,6 @@
+summon item ~ ~ ~ {Item:{id:"red_dye",Count:1b,tag:{LockTempItem:1b,display:{Name:'{"text":"非法物品","color":"red"}'}}},Tags:["LockTempItem"]}
+data modify entity @e[type=item,tag=LockTempItem,limit=1] Item set from entity @s Inventory[{Slot:7b}]
+data modify entity @e[type=item,tag=LockTempItem,limit=1] PickupDelay set value 0
+data modify entity @e[type=item,tag=LockTempItem,limit=1] Thrower set from entity @s UUID
+execute as @e[type=item,tag=LockTempItem,limit=1] run function item:disable_throw
+replaceitem entity @s hotbar.7 air

+ 6 - 0
data/item/functions/return_slot/return_slot_8.mcfunction

@@ -0,0 +1,6 @@
+summon item ~ ~ ~ {Item:{id:"red_dye",Count:1b,tag:{LockTempItem:1b,display:{Name:'{"text":"非法物品","color":"red"}'}}},Tags:["LockTempItem"]}
+data modify entity @e[type=item,tag=LockTempItem,limit=1] Item set from entity @s Inventory[{Slot:8b}]
+data modify entity @e[type=item,tag=LockTempItem,limit=1] PickupDelay set value 0
+data modify entity @e[type=item,tag=LockTempItem,limit=1] Thrower set from entity @s UUID
+execute as @e[type=item,tag=LockTempItem,limit=1] run function item:disable_throw
+replaceitem entity @s hotbar.8 air

+ 4 - 2
data/item/functions/tick2.mcfunction

@@ -5,8 +5,10 @@ execute as @e[type=item] if data entity @s Thrower run function item:disable_thr
 # 检查玩家拾取奖励物品
 execute as @a if data entity @s Inventory[{"tag":{"bonus_new":1b}}] run function item:bonus_item/call
 
-# 检测玩家第九格锁定
-execute if score $state mem matches 1.. as @a run function item:disable_slot/check_slot
+# 检测玩家格子锁定
+execute if score $state mem matches 1.. as @a[tag=!debug] run function item:disable_slot/check_slot
+execute if score $state mem matches 0 as @a run function item:lobby_state/check_slot
+execute if score $state mem matches 0.. run kill @e[type=item,tag=LockTempItem,nbt={Item:{tag:{LockTempItem:1b}}}]
 
 # 检查购买物品
 execute as @a run function item:shop/check

+ 0 - 0
data/lib/functions/sounds/music/hub.mcfunction → data/lib/functions/sounds/music/lobby.mcfunction


+ 5 - 2
data/ltw/functions/state/0/player_enter.mcfunction

@@ -1,5 +1,5 @@
 # 对单个玩家的处理(如果玩家中途加入就会执行此函数)
-function lib:sounds/music/hub
+function lib:sounds/music/lobby
 title @s clear
 title @s actionbar ""
 
@@ -35,4 +35,7 @@ tag @s add gold_return
 
 # 刷新物品
 clear @s[tag=!debug]
-function item:shop/refresh_gold
+function item:shop/refresh_gold
+
+# 默认进入待机状态
+function item:lobby_state/join_watch

+ 1 - 1
data/ltw/functions/state/0/start_gameparty.mcfunction

@@ -2,7 +2,7 @@
 
 # 设置旁观
 tag @a add watcher
-tag @a[tag=hub_ready,sort=random,limit=8,tag=!debug] remove watcher
+tag @a[tag=lobby_ready,sort=random,limit=8,tag=!debug] remove watcher
 tellraw @a[tag=debug] "你正处于 Debug 模式中, 将忽略游戏开始!"
 
 # 设置数据

+ 5 - 4
data/ltw/functions/state/0/tick5.mcfunction

@@ -1,5 +1,6 @@
 # 判断玩家是否处于准备状态
-tag @a remove hub_ready
-tag @a remove hub_watch
-tag @a[x=-24,y=8,z=-32,dx=5,dy=5,dz=5] add hub_ready
-tag @a[tag=!hub_ready] add hub_watch
+# tag @a remove lobby_ready
+# tag @a remove lobby_watch
+# tag @a[x=-24,y=8,z=-32,dx=5,dy=5,dz=5] add lobby_ready
+# tag @a[tag=!lobby_ready] add lobby_watch
+execute as @a[tag=!lobby_ready,tag=!lobby_watch] run function item:lobby_state/join_watch

+ 2 - 2
data/ltw/functions/state/0/try_start_classic.mcfunction

@@ -1,4 +1,4 @@
 # 尝试开始晶石模式
-tellraw @a[tag=hub_ready] ["",{"text": ">> ","color":"red","bold": true},{"text": "晶石模式尚未完成, 请开始派对模式!","color":"red"}]
-execute as @a[tag=hub_ready] at @s run function lib:sounds/error
+tellraw @a[tag=lobby_ready] ["",{"text": ">> ","color":"red","bold": true},{"text": "晶石模式尚未完成, 请开始派对模式!","color":"red"}]
+execute as @a[tag=lobby_ready] at @s run function lib:sounds/error
 scoreboard players set $countdown mem 0

+ 2 - 2
data/ltw/functions/state/0/try_start_gameparty.mcfunction

@@ -1,7 +1,7 @@
 # 尝试开始派对模式
 
 # 计算玩家数量
-execute store result score $count mem if entity @a[tag=hub_ready]
+execute store result score $count mem if entity @a[tag=lobby_ready]
 
 # 判断玩家数量过少
 execute if score $count mem matches ..2 as @a at @s run function lib:sounds/error
@@ -9,7 +9,7 @@ execute if score $count mem matches ..2 run tellraw @a ["",{"text": ">> ","color
 execute if score $count mem matches ..2 run scoreboard players set $countdown mem 0
 
 # 提示未准备
-execute if score $countdown mem matches 10 run tellraw @a[tag=!hub_ready] [{"text":"","color":"red"},{"text":">> ","bold": true},"你现在还没有准备, 请站在蓝色准备区域以加入游戏!"]
+execute if score $countdown mem matches 10 run tellraw @a[tag=!lobby_ready] [{"text":"","color":"red"},{"text":">> ","bold": true},"你现在还没有准备, 请站在蓝色准备区域以加入游戏!"]
 
 # 判断玩家数量过多
 execute if score $count mem matches 9.. if score $countdown mem matches 15 run tellraw @a [{"text":"","color":"gold"},{"text":">> ","bold": true},"游戏最多支持 8 人, 当前已有 ",{"score": { "name": "$count","objective": "mem"}}, " 人, 将随机抽取 8 人开始游戏!"]

+ 2 - 2
data/test/functions/mini/colormatch.mcfunction

@@ -1,6 +1,6 @@
 # 测试用:快速开始 Color Match
-tag @a add hub_ready
-tag @a remove hub_watch
+tag @a add lobby_ready
+tag @a remove lobby_watch
 tag @a remove watcher
 function ltw:state/0/start_gameparty
 scoreboard players set $round mem 6

+ 2 - 2
data/test/functions/mini/hotpm.mcfunction

@@ -1,6 +1,6 @@
 # 测试用:快速开始 Hot Potato
-tag @a add hub_ready
-tag @a remove hub_watch
+tag @a add lobby_ready
+tag @a remove lobby_watch
 tag @a remove watcher
 function ltw:state/0/start_gameparty
 scoreboard players set $round mem 6

+ 2 - 2
data/test/functions/mini/parkour.mcfunction

@@ -1,6 +1,6 @@
 # 测试用:快速开始跑酷
-tag @a add hub_ready
-tag @a remove hub_watch
+tag @a add lobby_ready
+tag @a remove lobby_watch
 tag @a remove watcher
 function ltw:state/0/start_gameparty
 scoreboard players set $round mem 6

+ 2 - 2
data/test/functions/mini/phantom.mcfunction

@@ -1,6 +1,6 @@
 # 测试用:快速开始幻翼
-tag @a add hub_ready
-tag @a remove hub_watch
+tag @a add lobby_ready
+tag @a remove lobby_watch
 tag @a remove watcher
 function ltw:state/0/start_gameparty
 scoreboard players set $round mem 6

+ 2 - 2
data/test/functions/mini/slime.mcfunction

@@ -1,6 +1,6 @@
 # 测试用:快速开始史莱姆
-tag @a add hub_ready
-tag @a remove hub_watch
+tag @a add lobby_ready
+tag @a remove lobby_watch
 tag @a remove watcher
 function ltw:state/0/start_gameparty
 scoreboard players set $round mem 6

+ 2 - 2
data/test/functions/mini/tntrun.mcfunction

@@ -1,6 +1,6 @@
 # 测试用:快速开始 TNT Run
-tag @a add hub_ready
-tag @a remove hub_watch
+tag @a add lobby_ready
+tag @a remove lobby_watch
 tag @a remove watcher
 function ltw:state/0/start_gameparty
 scoreboard players set $round mem 6