Jelajahi Sumber

容器检查相关

00ll00 6 tahun lalu
induk
melakukan
888afcb29d

+ 15 - 0
data/item/advancements/container/place.json

@@ -0,0 +1,15 @@
+{
+    "criteria": {
+        "place_furnace":{
+            "trigger": "minecraft:placed_block",
+            "conditions": {
+                "item": {
+                    "tag": "item:container"
+                }
+            }
+        }
+    },
+    "rewards": {
+        "function": "item:container/placed/call"
+    }
+}

+ 1 - 0
data/item/functions/container/check/call.mcfunction

@@ -0,0 +1 @@
+execute as @e[tag=container] at @s if block ~ ~ ~ minecraft:furnace if data block ~ ~ ~ Items[{id:"minecraft:nether_star"}] run function item:container/explode

+ 4 - 0
data/item/functions/container/explode.mcfunction

@@ -0,0 +1,4 @@
+#as container as @s
+setblock ~ ~ ~ air
+summon tnt ~ ~ ~ {Fuse:0}
+kill @s

+ 7 - 0
data/item/functions/container/placed/call.mcfunction

@@ -0,0 +1,7 @@
+#as player
+#trigger by advancement
+advancement revoke @s only item:container/place
+scoreboard players set #container.got mem 0
+scoreboard players set #container.dist mem 0
+execute at @s anchored eyes positioned ^ ^ ^1 run function item:container/placed/recu
+say placed

+ 11 - 0
data/item/functions/container/placed/recu.mcfunction

@@ -0,0 +1,11 @@
+#as player
+execute if score #container.got mem matches 0 positioned ~ ~ ~ align xyz store success score #container.got mem unless entity @e[tag=container,dx=0,dy=0,dz=0] if block ~ ~ ~ #item:container run summon minecraft:area_effect_cloud ~.5 ~ ~.5 {Age: -2147483648, Duration: -1, WaitTime: -2147483648, Tags: ["container"]}
+execute if score #container.got mem matches 0 positioned ~1 ~ ~ align xyz store success score #container.got mem unless entity @e[tag=container,dx=0,dy=0,dz=0] if block ~ ~ ~ #item:container run summon minecraft:area_effect_cloud ~.5 ~ ~.5 {Age: -2147483648, Duration: -1, WaitTime: -2147483648, Tags: ["container"]}
+execute if score #container.got mem matches 0 positioned ~-1 ~ ~ align xyz store success score #container.got mem unless entity @e[tag=container,dx=0,dy=0,dz=0] if block ~ ~ ~ #item:container run summon minecraft:area_effect_cloud ~.5 ~ ~.5 {Age: -2147483648, Duration: -1, WaitTime: -2147483648, Tags: ["container"]}
+execute if score #container.got mem matches 0 positioned ~ ~1 ~ align xyz store success score #container.got mem unless entity @e[tag=container,dx=0,dy=0,dz=0] if block ~ ~ ~ #item:container run summon minecraft:area_effect_cloud ~.5 ~ ~.5 {Age: -2147483648, Duration: -1, WaitTime: -2147483648, Tags: ["container"]}
+execute if score #container.got mem matches 0 positioned ~ ~-1 ~ align xyz store success score #container.got mem unless entity @e[tag=container,dx=0,dy=0,dz=0] if block ~ ~ ~ #item:container run summon minecraft:area_effect_cloud ~.5 ~ ~.5 {Age: -2147483648, Duration: -1, WaitTime: -2147483648, Tags: ["container"]}
+execute if score #container.got mem matches 0 positioned ~ ~ ~1 align xyz store success score #container.got mem unless entity @e[tag=container,dx=0,dy=0,dz=0] if block ~ ~ ~ #item:container run summon minecraft:area_effect_cloud ~.5 ~ ~.5 {Age: -2147483648, Duration: -1, WaitTime: -2147483648, Tags: ["container"]}
+execute if score #container.got mem matches 0 positioned ~ ~ ~-1 align xyz store success score #container.got mem unless entity @e[tag=container,dx=0,dy=0,dz=0] if block ~ ~ ~ #item:container run summon minecraft:area_effect_cloud ~.5 ~ ~.5 {Age: -2147483648, Duration: -1, WaitTime: -2147483648, Tags: ["container"]}
+scoreboard players add #container.dist mem 1
+say 1
+execute if score #container.got mem matches 0 if score #container.dist mem matches ..4 positioned ^ ^ ^1 run function item:container/placed/recu

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

@@ -11,4 +11,7 @@ execute if score $state mem matches 1.. as @a unless data entity @s Inventory[{S
 
 # 清除临时物品
 clear @a red_dye{LockTempItem:1b}
-kill @e[type=item,tag=LockTempItem,nbt={Item:{tag:{LockTempItem:1b}}}]
+kill @e[type=item,tag=LockTempItem,nbt={Item:{tag:{LockTempItem:1b}}}]
+
+# 检测容器
+function item:container/check/call

+ 1 - 1
data/item/predicates/bonus/clear_nbt.json

@@ -2,6 +2,6 @@
     "condition":"minecraft:entity_properties",
     "entity": "this",
     "predicate": {
-        "nbt": "\"Item\":{\"tag\":{\"bonus_clear_nbt\":1b}}"
+        "nbt": "{\"Item\":{\"tag\":{\"bonus_clear_nbt\":1b}}}"
     }
 }

+ 1 - 1
data/item/predicates/bonus/is_bonus.json

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

+ 6 - 0
data/item/tags/blocks/container.json

@@ -0,0 +1,6 @@
+{
+    "values": [
+        "minecraft:furnace",
+        "minecraft:chest"
+    ]
+}

+ 6 - 0
data/item/tags/items/container.json

@@ -0,0 +1,6 @@
+{
+    "values": [
+        "minecraft:furnace",
+        "minecraft:chest"
+    ]
+}