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

+ 1 - 1
data/item/functions/check_item/call.mcfunction

@@ -1 +1 @@
-execute as @a if data entity @s Inventory[{"tag":{"ltw_item_new":1b}}] run function item:check_item/run_cmd
+execute as @a if data entity @s Inventory[{"tag":{"item_new":1b}}] run function item:check_item/run_cmd

+ 5 - 0
data/item/functions/check_item/return_item.mcfunction

@@ -0,0 +1,5 @@
+data modify block 0 0 0 RecordItem.tag.ltw_item_new set value 0b
+fill 0 0 0 0 0 0 air destroy
+tag @s add ltw_item_op
+execute as @e[tag=!ltw_item_old,type=minecraft:item,nbt={"Item":{"tag":{"ltw_item":1b}}},limit=1] run function item:check_item/tp
+tag @s remove ltw_item_op

+ 14 - 9
data/item/functions/check_item/run_cmd.mcfunction

@@ -1,11 +1,16 @@
 #as player
 #with forceload 0 0
-setblock 0 0 0 jukebox
-data modify block 0 0 0 RecordItem set from entity @s Inventory[{"tag":{"ltw_item_new":1b}}]
-tellraw @a [{"selector": "@s"},{"text":"获得了道具:"},{"nbt": "RecordItem.tag.ltw_item_name","block": "0 0 0","interpret": true}]
-data modify block 0 0 0 RecordItem.tag.ltw_item_new set value 0b
-clear @s #item:items{"ltw_item_new":1b}
-fill 0 0 0 0 0 0 air destroy
-tag @s add ltw_item_op
-execute as @e[tag=!ltw_item_old,type=minecraft:item,nbt={"Item":{"tag":{"ltw_item":1b}}},limit=1] run function item:check_item/tp
-tag @s remove ltw_item_op
+setblock 0 0 0 jukebox replace
+data modify block 0 0 0 RecordItem set from entity @s Inventory[{"tag":{"item_new":1b}}]
+#清除原物品
+clear @s #item:items{"item_new":1b}
+
+#通知玩家物品被拾取
+tellraw @a [{"selector": "@s"},{"text":"获得了道具:"},{"nbt": "RecordItem.tag.item_name","block": "0 0 0","interpret": true}]
+
+# TODO 通过判断RecordItem.tag里的自定义标签来决定捡起道具之后的事情(如增加积分)
+
+
+
+#如果有return标签则退回物品
+execute if data block 0 0 0 RecordItem.tag{"item_return":1b} run function item:check_item/return_item

+ 1 - 1
data/item/functions/test/get_test_item.mcfunction

@@ -1 +1 @@
-summon item ~ ~ ~ {Item:{id:"fishing_rod",Count:1,tag:{"ltw_item":1b,"ltw_item_new":1b,"ltw_item_name":'{"text":"[破损的钓鱼竿]","color":"green"}'}},CustomName:'{"text":"破损的钓鱼竿","color":"green"}',Tags:["team_green"],Age:-32768,PickupDelay:0,NoGravity:1,Invulnerable:1,CustomNameVisible:1,Glowing:1}
+summon item ~ ~ ~ {Item:{id:"fishing_rod",Count:1,tag:{"item":1b,"item_new":1b,"item_return":1b,"item_name":'{"text":"[破损的钓鱼竿]","color":"green"}'}},CustomName:'{"text":"破损的钓鱼竿","color":"green"}',Tags:["team_green"],Age:-32768,PickupDelay:0,NoGravity:1,Invulnerable:1,CustomNameVisible:1,Glowing:1}