Просмотр исходного кода

奖励物品系统使用皮迪凯特

00ll00 6 лет назад
Родитель
Сommit
9457f46218

+ 1 - 1
data/item/functions/bonus_item/give_items.mcfunction

@@ -3,7 +3,7 @@ setblock 0 0 1 jukebox replace
 data modify block 0 0 1 RecordItem set from block 0 0 0 RecordItem.tag.bonus_give_items[0]
 setblock 0 0 1 air destroy
 tag @s add item_op
-execute as @e[tag=!bonus_old,tag=!item_new,type=item,nbt={"Item":{"tag":{"is_bonus":1b}}},limit=1] run function item:bonus_item/tp
+execute as @e[tag=!bonus_old,tag=!item_new,type=item,predicate=item:bonus/is_bonus,limit=1] run function item:bonus_item/tp
 tag @s remove item_op
 data remove block 0 0 0 RecordItem.tag.bonus_give_items[0]
 execute if data block 0 0 0 RecordItem.tag.bonus_give_items[0] run function item:bonus_item/give_items

+ 1 - 1
data/item/functions/bonus_item/return_item.mcfunction

@@ -3,5 +3,5 @@ data modify block 0 0 1 RecordItem set from block 0 0 0 RecordItem
 data modify block 0 0 1 RecordItem.tag.bonus_new set value 0b
 setblock 0 0 1 air destroy
 tag @s add item_op
-execute as @e[tag=!bonus_old,tag=!item_new,type=item,nbt={"Item":{"tag":{"is_bonus":1b}}},limit=1] run function item:bonus_item/tp
+execute as @e[tag=!bonus_old,tag=!item_new,type=item,predicate=item:bonus/is_bonus,limit=1] run function item:bonus_item/tp
 tag @s remove item_op

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

@@ -3,7 +3,7 @@
 execute as @e[type=item] if data entity @s Thrower run function item:disable_throw
 
 # 检查玩家拾取奖励物品
-execute as @a if data entity @s Inventory[{"tag":{"bonus_new":1b}}] run function item:bonus_item/call
+execute as @a if predicate item:bonus/is_new_bonus_holder 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

+ 7 - 0
data/item/predicates/bonus/is_bonus.json

@@ -0,0 +1,7 @@
+{
+    "condition": "minecraft:entity_properties",
+    "entity": "this",
+    "predicate": {
+        "nbt": "\"Item\":{\"tag\":{\"is_bonus\":1b}}"
+    }
+}

+ 7 - 0
data/item/predicates/bonus/is_new_bonus_holder.json

@@ -0,0 +1,7 @@
+{
+    "condition": "minecraft:entity_properties",
+    "entity": "this",
+    "predicate": {
+        "nbt": "Inventory[{\"tag\":{\"bonus_new\":1b}}]"
+    }
+}