Ver Fonte

尝试使用更简洁的表达防止物品丢弃

LTCatt há 6 anos atrás
pai
commit
cb862aea6e

+ 13 - 0
data/item/functions/disable_throw.mcfunction

@@ -0,0 +1,13 @@
+# 强制玩家捡起自己丢弃的物品,以物品为执行者
+
+# 存储 UUID
+# execute store result score @s UUID run data get entity @s Thrower[0]
+
+# 更改 NBT
+# data merge entity @s {PickupDelay:0s}
+# data modify entity @s Owner set from entity @s Thrower
+
+# 将物品传送给玩家
+# 修改为了每 tick 执行一次,大概不需要了?
+# tag @s add item_force_tp
+# execute as @a if score @s UUID = @e[type=item,tag=item_force_tp,limit=1] UUID run tp @e[type=item,tag=item_force_tp] @s

+ 0 - 10
data/item/functions/force_pickup.mcfunction

@@ -1,10 +0,0 @@
-# 存储UUID
-execute store result score @s UUID run data get entity @s Thrower[0]
-
-# 更改NBT
-data merge entity @s {PickupDelay:0s}
-data modify entity @s Owner set from entity @s Thrower
-
-# TP玩家
-tag @s add item_force_tp
-execute as @a if score @s UUID = @e[type=item,tag=item_force_tp,limit=1] UUID run tp @e[type=item,tag=item_force_tp] @s

+ 2 - 2
data/item/functions/init.mcfunction

@@ -1,3 +1,3 @@
 # 计分板初始化
-scoreboard objectives remove UUID
-scoreboard objectives add UUID dummy "UUID"
+# scoreboard objectives remove UUID
+# scoreboard objectives add UUID dummy "UUID"

+ 0 - 0
data/item/functions/get_test_item.mcfunction → data/item/functions/test/get_test_item.mcfunction


+ 0 - 0
data/item/functions/test_summon.mcfunction → data/item/functions/test/test_summon.mcfunction


+ 0 - 0
data/item/functions/test_check.mcfunction


+ 2 - 0
data/item/functions/tick1.mcfunction

@@ -0,0 +1,2 @@
+execute as @e[type=item] if data entity @s Thrower run data merge entity @s {PickupDelay:0s}
+execute as @e[type=item] if data entity @s Thrower run data modify entity @s Owner set from entity @s Thrower

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

@@ -1,2 +1,2 @@
-# 以玩家判定有Thrower便强制捡起
-execute as @e[type=item] if data entity @s Thrower run function item:force_pickup
+# 防止玩家丢弃物品:如果物品存在 Thrower 则要求强制捡起
+# execute as @e[type=item] if data entity @s Thrower run function item:disable_throw

+ 1 - 0
data/ltw/functions/clock/tick1.mcfunction

@@ -1,4 +1,5 @@
 # 每 1 Tick 执行一次
 
 # 调用其他模块
+function item:tick1
 execute if score $state mem matches 5 run function ltw:state/5/tick1

+ 1 - 1
data/ltw/functions/clock/tick2.mcfunction

@@ -2,7 +2,7 @@
 schedule function ltw:clock/tick2 2t replace
 
 # 调用其他模块
-function item:tick2
+# function item:tick2
 execute if score $state mem matches 3 run function ltw:state/3/tick2
 execute if score $state mem matches 4 run function ltw:state/4/tick2
 execute if score $state mem matches 5 run function ltw:state/5/tick2