Răsfoiți Sursa

重构物品轮子

HerobrineXia 5 ani în urmă
părinte
comite
4fe96b2099

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

@@ -1,10 +1,8 @@
 # 第八格
 execute unless data entity @s Inventory[{Slot:7b,tag:{game_item:1b}}] unless data entity @s Inventory[{Slot:7b,tag:{LockItem:1b,LockSlot:7b},Count:1b}] run function item:disable_slot/disable_slot_7
-execute unless data entity @s Inventory[{Slot:7b,tag:{LockItem:1b,LockSlot:7b},Count:1b}] if data entity @s Inventory[{tag:{LockItem:1b,LockSlot:7b},Count:1b}] run clear @s barrier{LockItem:1b,LockSlot:7b}
 
 # 第九格
 execute unless data entity @s Inventory[{Slot:8b,tag:{game_item:1b}}] unless data entity @s Inventory[{Slot:8b,tag:{LockItem:1b,LockSlot:8b},Count:1b}] run function item:disable_slot/disable_slot_8
-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 barrier{LockItem:1b,LockSlot:8b}
 
 # 清除临时物品
 clear @a barrier{LockTempItem:1b}

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

@@ -1,3 +1,4 @@
 clear @s barrier{LockItem:1b,LockSlot:7b}
-execute if data entity @s Inventory[{Slot:7b}] unless data entity @s Inventory[{Slot:7b,tag:{LockItem:1b}}] unless data entity @s Inventory[{Slot:7b,tag:{game_item:1b}}] unless data entity @s Inventory[{Slot:7b,tag:{lobby_item:1b}}] at @s run function item:return_slot/return_slot_7
+execute if data entity @s Inventory[{Slot:7b}] run scoreboard players set @s item_slot 7
+execute if data entity @s Inventory[{Slot:7b}] at @s run function item:pop_slot/return_item
 replaceitem entity @s hotbar.7 barrier{LockItem:1b,LockSlot:7b,display:{Name:'{"text":"已锁定","color":"red","italic":false}'}}

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

@@ -1,3 +1,4 @@
 clear @s barrier{LockItem:1b,LockSlot:8b}
-execute if data entity @s Inventory[{Slot:8b}] unless data entity @s Inventory[{Slot:8b,tag:{LockItem:1b}}] unless data entity @s Inventory[{Slot:8b,tag:{game_item:1b}}] unless data entity @s Inventory[{Slot:8b,tag:{lobby_item:1b}}] at @s run function item:return_slot/return_slot_8
+execute if data entity @s Inventory[{Slot:8b}] run scoreboard players set @s item_slot 8
+execute if data entity @s Inventory[{Slot:8b}] at @s run function item:pop_slot/return_item
 replaceitem entity @s hotbar.8 barrier{LockItem:1b,LockSlot:8b,display:{Name:'{"text":"已锁定","color":"red","italic":false}'}}

+ 4 - 1
data/item/functions/init.mcfunction

@@ -1,3 +1,6 @@
 # 计分板初始化
 scoreboard objectives remove UUID
-scoreboard objectives add UUID dummy "UUID"
+scoreboard objectives add UUID dummy "UUID"
+
+scoreboard objectives remove item_slot
+scoreboard objectives add item_slot dummy "item_slot"

+ 5 - 0
data/item/functions/pop_slot/pop_item.mcfunction

@@ -0,0 +1,5 @@
+summon item ~ ~ ~ {Item:{id:"minecraft:barrier",Count:1b,tag:{LockTempItem:1b,display:{Name:'{"text":"非法物品","color":"red"}'}}},Tags:["LockTempItem","PopItem"]}
+function item:pop_slot/select_item
+kill @e[type=item,nbt={Item:{id:"minecraft:barrier"}},tag=LockTempItem]
+data modify entity @e[type=item,tag=LockTempItem,limit=1] Thrower set from entity @s UUID
+tag @e[type=item,tag=LockTempItem] remove LockTempItem

+ 6 - 0
data/item/functions/pop_slot/return_item.mcfunction

@@ -0,0 +1,6 @@
+summon item ~ ~ ~ {Item:{id:"minecraft:barrier",Count:1b,tag:{LockTempItem:1b,display:{Name:'{"text":"非法物品","color":"red"}'}}},Tags:["LockTempItem","ReturnItem"]}
+function item:pop_slot/select_item
+kill @e[type=item,nbt={Item:{id:"minecraft:barrier"}},tag=LockTempItem]
+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
+tag @e[type=item,tag=LockTempItem] remove LockTempItem

+ 85 - 0
data/item/functions/pop_slot/select_item.mcfunction

@@ -0,0 +1,85 @@
+execute if score @s item_slot matches 0 run data modify entity @e[type=item,tag=LockTempItem,limit=1] Item set from entity @s Inventory[{Slot:0b}]
+execute if score @s item_slot matches 1 run data modify entity @e[type=item,tag=LockTempItem,limit=1] Item set from entity @s Inventory[{Slot:1b}]
+execute if score @s item_slot matches 2 run data modify entity @e[type=item,tag=LockTempItem,limit=1] Item set from entity @s Inventory[{Slot:2b}]
+execute if score @s item_slot matches 3 run data modify entity @e[type=item,tag=LockTempItem,limit=1] Item set from entity @s Inventory[{Slot:3b}]
+execute if score @s item_slot matches 4 run data modify entity @e[type=item,tag=LockTempItem,limit=1] Item set from entity @s Inventory[{Slot:4b}]
+execute if score @s item_slot matches 5 run data modify entity @e[type=item,tag=LockTempItem,limit=1] Item set from entity @s Inventory[{Slot:5b}]
+execute if score @s item_slot matches 6 run data modify entity @e[type=item,tag=LockTempItem,limit=1] Item set from entity @s Inventory[{Slot:6b}]
+execute if score @s item_slot matches 7 run data modify entity @e[type=item,tag=LockTempItem,limit=1] Item set from entity @s Inventory[{Slot:7b}]
+execute if score @s item_slot matches 8 run data modify entity @e[type=item,tag=LockTempItem,limit=1] Item set from entity @s Inventory[{Slot:8b}]
+execute if score @s item_slot matches 9 run data modify entity @e[type=item,tag=LockTempItem,limit=1] Item set from entity @s Inventory[{Slot:9b}]
+execute if score @s item_slot matches 10 run data modify entity @e[type=item,tag=LockTempItem,limit=1] Item set from entity @s Inventory[{Slot:10b}]
+execute if score @s item_slot matches 11 run data modify entity @e[type=item,tag=LockTempItem,limit=1] Item set from entity @s Inventory[{Slot:11b}]
+execute if score @s item_slot matches 12 run data modify entity @e[type=item,tag=LockTempItem,limit=1] Item set from entity @s Inventory[{Slot:12b}]
+execute if score @s item_slot matches 13 run data modify entity @e[type=item,tag=LockTempItem,limit=1] Item set from entity @s Inventory[{Slot:13b}]
+execute if score @s item_slot matches 14 run data modify entity @e[type=item,tag=LockTempItem,limit=1] Item set from entity @s Inventory[{Slot:14b}]
+execute if score @s item_slot matches 15 run data modify entity @e[type=item,tag=LockTempItem,limit=1] Item set from entity @s Inventory[{Slot:15b}]
+execute if score @s item_slot matches 16 run data modify entity @e[type=item,tag=LockTempItem,limit=1] Item set from entity @s Inventory[{Slot:16b}]
+execute if score @s item_slot matches 17 run data modify entity @e[type=item,tag=LockTempItem,limit=1] Item set from entity @s Inventory[{Slot:17b}]
+execute if score @s item_slot matches 18 run data modify entity @e[type=item,tag=LockTempItem,limit=1] Item set from entity @s Inventory[{Slot:18b}]
+execute if score @s item_slot matches 19 run data modify entity @e[type=item,tag=LockTempItem,limit=1] Item set from entity @s Inventory[{Slot:19b}]
+execute if score @s item_slot matches 20 run data modify entity @e[type=item,tag=LockTempItem,limit=1] Item set from entity @s Inventory[{Slot:20b}]
+execute if score @s item_slot matches 21 run data modify entity @e[type=item,tag=LockTempItem,limit=1] Item set from entity @s Inventory[{Slot:21b}]
+execute if score @s item_slot matches 22 run data modify entity @e[type=item,tag=LockTempItem,limit=1] Item set from entity @s Inventory[{Slot:22b}]
+execute if score @s item_slot matches 23 run data modify entity @e[type=item,tag=LockTempItem,limit=1] Item set from entity @s Inventory[{Slot:23b}]
+execute if score @s item_slot matches 24 run data modify entity @e[type=item,tag=LockTempItem,limit=1] Item set from entity @s Inventory[{Slot:24b}]
+execute if score @s item_slot matches 25 run data modify entity @e[type=item,tag=LockTempItem,limit=1] Item set from entity @s Inventory[{Slot:25b}]
+execute if score @s item_slot matches 26 run data modify entity @e[type=item,tag=LockTempItem,limit=1] Item set from entity @s Inventory[{Slot:26b}]
+execute if score @s item_slot matches 27 run data modify entity @e[type=item,tag=LockTempItem,limit=1] Item set from entity @s Inventory[{Slot:27b}]
+execute if score @s item_slot matches 28 run data modify entity @e[type=item,tag=LockTempItem,limit=1] Item set from entity @s Inventory[{Slot:28b}]
+execute if score @s item_slot matches 29 run data modify entity @e[type=item,tag=LockTempItem,limit=1] Item set from entity @s Inventory[{Slot:29b}]
+execute if score @s item_slot matches 30 run data modify entity @e[type=item,tag=LockTempItem,limit=1] Item set from entity @s Inventory[{Slot:30b}]
+execute if score @s item_slot matches 31 run data modify entity @e[type=item,tag=LockTempItem,limit=1] Item set from entity @s Inventory[{Slot:31b}]
+execute if score @s item_slot matches 32 run data modify entity @e[type=item,tag=LockTempItem,limit=1] Item set from entity @s Inventory[{Slot:32b}]
+execute if score @s item_slot matches 33 run data modify entity @e[type=item,tag=LockTempItem,limit=1] Item set from entity @s Inventory[{Slot:33b}]
+execute if score @s item_slot matches 34 run data modify entity @e[type=item,tag=LockTempItem,limit=1] Item set from entity @s Inventory[{Slot:34b}]
+execute if score @s item_slot matches 35 run data modify entity @e[type=item,tag=LockTempItem,limit=1] Item set from entity @s Inventory[{Slot:35b}]
+execute if score @s item_slot matches 100 run data modify entity @e[type=item,tag=LockTempItem,limit=1] Item set from entity @s Inventory[{Slot:100b}]
+execute if score @s item_slot matches 101 run data modify entity @e[type=item,tag=LockTempItem,limit=1] Item set from entity @s Inventory[{Slot:101b}]
+execute if score @s item_slot matches 102 run data modify entity @e[type=item,tag=LockTempItem,limit=1] Item set from entity @s Inventory[{Slot:102b}]
+execute if score @s item_slot matches 103 run data modify entity @e[type=item,tag=LockTempItem,limit=1] Item set from entity @s Inventory[{Slot:103b}]
+execute if score @s item_slot matches -106 run data modify entity @e[type=item,tag=LockTempItem,limit=1] Item set from entity @s Inventory[{Slot:-106b}]
+
+execute if score @s item_slot matches 0 run replaceitem entity @s inventory.0 air
+execute if score @s item_slot matches 1 run replaceitem entity @s hotbar.1 air
+execute if score @s item_slot matches 2 run replaceitem entity @s hotbar.2 air
+execute if score @s item_slot matches 3 run replaceitem entity @s hotbar.3 air
+execute if score @s item_slot matches 4 run replaceitem entity @s hotbar.4 air
+execute if score @s item_slot matches 5 run replaceitem entity @s hotbar.5 air
+execute if score @s item_slot matches 6 run replaceitem entity @s hotbar.6 air
+execute if score @s item_slot matches 7 run replaceitem entity @s hotbar.7 air
+execute if score @s item_slot matches 8 run replaceitem entity @s hotbar.8 air
+execute if score @s item_slot matches 9 run replaceitem entity @s inventory.0 air
+execute if score @s item_slot matches 10 run replaceitem entity @s inventory.1 air
+execute if score @s item_slot matches 11 run replaceitem entity @s inventory.2 air
+execute if score @s item_slot matches 12 run replaceitem entity @s inventory.3 air
+execute if score @s item_slot matches 13 run replaceitem entity @s inventory.4 air
+execute if score @s item_slot matches 14 run replaceitem entity @s inventory.5 air
+execute if score @s item_slot matches 15 run replaceitem entity @s inventory.6 air
+execute if score @s item_slot matches 16 run replaceitem entity @s inventory.7 air
+execute if score @s item_slot matches 17 run replaceitem entity @s inventory.8 air
+execute if score @s item_slot matches 18 run replaceitem entity @s inventory.9 air
+execute if score @s item_slot matches 19 run replaceitem entity @s inventory.10 air
+execute if score @s item_slot matches 20 run replaceitem entity @s inventory.11 air
+execute if score @s item_slot matches 21 run replaceitem entity @s inventory.12 air
+execute if score @s item_slot matches 22 run replaceitem entity @s inventory.13 air
+execute if score @s item_slot matches 23 run replaceitem entity @s inventory.14 air
+execute if score @s item_slot matches 24 run replaceitem entity @s inventory.15 air
+execute if score @s item_slot matches 25 run replaceitem entity @s inventory.16 air
+execute if score @s item_slot matches 26 run replaceitem entity @s inventory.17 air
+execute if score @s item_slot matches 27 run replaceitem entity @s inventory.18 air
+execute if score @s item_slot matches 28 run replaceitem entity @s inventory.19 air
+execute if score @s item_slot matches 29 run replaceitem entity @s inventory.20 air
+execute if score @s item_slot matches 30 run replaceitem entity @s inventory.21 air
+execute if score @s item_slot matches 31 run replaceitem entity @s inventory.22 air
+execute if score @s item_slot matches 32 run replaceitem entity @s inventory.23 air
+execute if score @s item_slot matches 33 run replaceitem entity @s inventory.24 air
+execute if score @s item_slot matches 34 run replaceitem entity @s inventory.25 air
+execute if score @s item_slot matches 35 run replaceitem entity @s inventory.26 air
+execute if score @s item_slot matches 100 run replaceitem entity @s armor.feet air
+execute if score @s item_slot matches 101 run replaceitem entity @s armor.legs air
+execute if score @s item_slot matches 102 run replaceitem entity @s armor.chest air
+execute if score @s item_slot matches 103 run replaceitem entity @s armor.head air
+execute if score @s item_slot matches -106 run replaceitem entity @s weapon.offhand air
+
+scoreboard players reset @s item_slot

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

@@ -1,6 +0,0 @@
-summon item ~ ~ ~ {Item:{id:"barrier",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] Thrower set from entity @s UUID
-execute as @e[type=item,tag=LockTempItem,limit=1] run function item:disable_throw
-tag @e[type=item,tag=LockTempItem] remove LockTempItem
-replaceitem entity @s hotbar.7 air

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

@@ -1,6 +0,0 @@
-summon item ~ ~ ~ {Item:{id:"barrier",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] Thrower set from entity @s UUID
-execute as @e[type=item,tag=LockTempItem,limit=1] run function item:disable_throw
-tag @e[type=item,tag=LockTempItem] remove LockTempItem
-replaceitem entity @s hotbar.8 air