HerobrineXia 6 лет назад
Родитель
Сommit
646f8e6f58

+ 0 - 7
data/item/functions/disable_slot.mcfunction

@@ -1,7 +0,0 @@
-clear @s red_dye{LockItem:1b}
-execute if data entity @s Inventory[{Slot:8b}] 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
-replaceitem entity @s hotbar.8 red_dye{LockItem:1b,display:{Name:'{"text":"已锁定","color":"red","bold":true,"italic":false}'}}

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

@@ -0,0 +1,11 @@
+# 第八格
+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 red_dye{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 red_dye{LockItem:1b,LockSlot:8b}
+
+# 清除临时物品
+clear @a red_dye{LockTempItem:1b}
+kill @e[type=item,tag=LockTempItem,nbt={Item:{tag:{LockTempItem:1b}}}]

+ 7 - 0
data/item/functions/disable_slot/disable_slot_7.mcfunction

@@ -0,0 +1,7 @@
+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
+replaceitem entity @s hotbar.7 red_dye{LockItem:1b,LockSlot:7b,display:{Name:'{"text":"已锁定","color":"red","bold":true,"italic":false}'}}

+ 7 - 0
data/item/functions/disable_slot/disable_slot_8.mcfunction

@@ -0,0 +1,7 @@
+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
+replaceitem entity @s hotbar.8 red_dye{LockItem:1b,LockSlot:8b,display:{Name:'{"text":"已锁定","color":"red","bold":true,"italic":false}'}}

+ 1 - 6
data/item/functions/tick2.mcfunction

@@ -6,9 +6,4 @@ 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 unless data entity @s Inventory[{Slot:8b,tag:{game_item:1b}}] unless data entity @s Inventory[{Slot:8b,tag:{LockItem:1b},Count:1b}] run function item:disable_slot
-execute if score $state mem matches 1.. as @a unless data entity @s Inventory[{Slot:8b,tag:{LockItem:1b},Count:1b}] if data entity @s Inventory[{tag:{LockItem:1b},Count:1b}] run clear @s red_dye{LockItem:1b}
-
-# 清除临时物品
-clear @a red_dye{LockTempItem:1b}
-kill @e[type=item,tag=LockTempItem,nbt={Item:{tag:{LockTempItem:1b}}}]
+execute if score $state mem matches 1.. as @a run function item:disable_slot/check_slot