移除药箭中的某一药水效果。
想不到有什么能曲线救国绕过 sbmj 的办法。
版本:1.16.5
请各位在游戏中实测后再来答题。
想不到有什么能曲线救国绕过 sbmj 的办法。
版本:1.16.5
请各位在游戏中实测后再来答题。
没有方法。除非生成一个新的药箭
仅仅提供思路,不保证可行
用data提取药水箭的那一段nbt并移植到storage列表
遍历storage列表,直到找到你要的那一种药水效果
把那个药水效果扬了
把storage列表里面的东西复制回来
补充一点:遍历列表的可行方案
检测list[0],不是就把这个元素移动到其他地方
然后递归,这样list[0]就是原来的第二个元素了
用data提取药水箭的那一段nbt并移植到storage列表
遍历storage列表,直到找到你要的那一种药水效果
把那个药水效果扬了
把storage列表里面的东西复制回来
补充一点:遍历列表的可行方案
检测list[0],不是就把这个元素移动到其他地方
然后递归,这样list[0]就是原来的第二个元素了
可以通过给原药箭添加标签,然后再用生成新的药箭,删除旧的药箭达到移除,要是不会的话就说。。。。
先mjsb为敬
然后我看到wiki有这句话
但我并没有找到该时间在nbt内的反应(尝试过改life,但不行)。
所以还是笨方法,检测到箭落地后,备份箭的数据至storage,删除需要的药水效果,然后kill掉箭,生成一个新箭,再把数据复制回去。
感谢@chixvv 指出,可以通过/data modify ... merge 的方式编辑实体的根标签。
假定需要移除药水效果的箭拥有标签233,需要移除的药水效果id为1(速度)
tick.mcfunction
main.mcfunction
copy_nbt.mcfunction
tick.mcfunction
main.mcfunction
MC-122008: CustomPotionEffects in arrow entities duplicates with '/execute store' and isn't affected by '/data remove'
MC-122008:箭实体的CustomPotionEffects标签会被“/execute store”翻倍,且不受“/data remove”影响
MC-122008:箭实体的CustomPotionEffects标签会被“/execute store”翻倍,且不受“/data remove”影响
然后我看到wiki有这句话
药箭的自定义效果(NBT标签CustomPotionEffects)会在药箭被卡住30秒后消失
但我并没有找到该时间在nbt内的反应(尝试过改life,但不行)。
所以还是笨方法,检测到箭落地后,备份箭的数据至storage,删除需要的药水效果,然后kill掉箭,生成一个新箭,再把数据复制回去。
感谢@chixvv 指出,可以通过/data modify ... merge 的方式编辑实体的根标签。
假定需要移除药水效果的箭拥有标签233,需要移除的药水效果id为1(速度)
tick.mcfunction
代码:
- execute as @e[type=minecraft:arrow,tag=233] if data entity @s {inGround:1b,life:0s} run function main
代码:
- data modify storage temp arrow set from entity @s {}
- kill @s
- summon minecraft:arrow ~ ~ ~ {Tags:["233"]}
- data remove storage temp arrow.CustomPotionEffects[{Id:1b}]
- execute as @e[type=minecraft:arrow,tag=233,sort=nearest,limit=1] run function copy_nbt
代码:
- data modify entity @s Fire set from storage temp arrow.Fire
- data modify entity @s Motion set from storage temp arrow.Motion
- data modify entity @s NoGravity set from storage temp arrow.NoGravity
- data modify entity @s Pos set from storage temp arrow.Pos
- data modify entity @s Rotation set from storage temp arrow.Rotation
- data modify entity @s Tags set from storage temp arrow.Tags
- data modify entity @s Owner set from storage temp arrow.Owner
- data modify entity @s crit set from storage temp arrow.crit
- data modify entity @s damage set from storage temp arrow.damage
- data modify entity @s pickup set from storage temp arrow.pickup
- data modify entity @s PierceLevel set from storage temp arrow.PierceLevel
- data modify entity @s shake set from storage temp arrow.shake
- data modify entity @s ShotFromCrossbow set from storage temp arrow.ShotFromCrossbow
- data modify entity @s CustomPotionEffects set from storage temp arrow.CustomPotionEffects
- tag @s remove 233
tick.mcfunction
代码:
- execute as @e[type=minecraft:arrow,tag=233] if data entity @s {inGround:1b,life:0s} run function main
代码:
- data modify storage temp arrow set from entity @s {}
- kill @s
- summon minecraft:arrow ~ ~ ~ {Tags:["233"]}
- data remove storage temp arrow.CustomPotionEffects[{Id:1b}]
- execute as @e[type=minecraft:arrow,tag=233,sort=nearest,limit=1] run data modify entity @s {} merge from storage temp arrow