Przeglądaj źródła

增加锁定第九格物品栏

HerobrineXia 6 lat temu
rodzic
commit
dcbe7c2bb8

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

@@ -0,0 +1,7 @@
+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}'}}

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

@@ -4,3 +4,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 as @a unless data entity @s Inventory[{Slot:8b,tag:{GameItem:1b}}] unless data entity @s Inventory[{Slot:8b,tag:{LockItem:1b},Count:1b}] run function item:disable_slot
+
+# 清除临时物品
+clear @a red_dye{LockTempItem:1b}
+kill @e[type=item,tag=LockTempItem]