LTCatt 6 лет назад
Родитель
Сommit
85f780b784

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

@@ -0,0 +1 @@
+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.item_new set value 0b
+fill 0 0 0 0 0 0 air destroy
+tag @s add item_op
+execute as @e[tag=!item_old,type=minecraft:item,nbt={"Item":{"tag":{"item":1b}}},limit=1] run function item:check_item/tp
+tag @s remove item_op

+ 16 - 0
data/item/functions/check_item/run_cmd.mcfunction

@@ -0,0 +1,16 @@
+#as player
+#with forceload 0 0
+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

+ 4 - 0
data/item/functions/check_item/tp.mcfunction

@@ -0,0 +1,4 @@
+#as item
+tp @s @a[tag=item_op,limit=1]
+tag @s add item_old
+data modify entity @s PickupDelay set value 0

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

@@ -1 +1 @@
-summon item ~ ~ ~ {Item:{id:"fishing_rod",Count:1,tag:{"bonus":1b,"bonus_new":1b,"bonus_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:{"bonus":1b,"bonus_new":1b,"bonus_return":1b,"bonus_name":'{"text":"破损的钓鱼竿","color":"green"}'}},CustomName:'{"text":"破损的钓鱼竿","color":"green"}',Tags:["team_green"],Age:-32768,PickupDelay:0,NoGravity:1,Invulnerable:1,CustomNameVisible:1,Glowing:1}

+ 4 - 0
data/ltw/functions/init.mcfunction

@@ -1,6 +1,7 @@
 # 全局初始化
 
 # 游戏数据
+setworldspawn 10 13 10
 forceload remove all
 time set noon
 weather clear
@@ -16,6 +17,9 @@ gamerule randomTickSpeed 0
 gamerule fireDamage false
 gamerule doTileDrops false
 
+# 主寄存区块:将所有需要不卸载的都放里面
+forceload add 0 0
+
 # 记分板
 scoreboard objectives remove mem
 scoreboard objectives add mem dummy "全局变量"