脑子卡了,想不到解决办法
复制代码执行A,1变2 执行B,2变3 执行C,3变1
顺序执行导致陷入循环,该加什么判断条件
- A execute if entity @s[nbt={SelectedItem:{id:"minecraft:carrot_on_a_stick",tag:{light_sword:1}}}] run item modify entity @s weapon.mainhand st:light_sword/long_sword
- B execute if entity @s[nbt={SelectedItem:{id:"minecraft:carrot_on_a_stick",tag:{light_sword:2}}}] run item modify entity @s weapon.mainhand st:light_sword/giant_sword
- C execute if entity @s[nbt={SelectedItem:{id:"minecraft:carrot_on_a_stick",tag:{light_sword:3}}}] run item modify entity @s weapon.mainhand st:light_sword/short_sword
顺序执行导致陷入循环,该加什么判断条件
- #A.mcfunction
- execute if entity @s[nbt={SelectedItem:{id:"minecraft:carrot_on_a_stick",tag:{light_sword:1}}}] run item modify entity @s weapon.mainhand st:light_sword/long_sword
- #B.mcfunction
- execute if entity @s[nbt={SelectedItem:{id:"minecraft:carrot_on_a_stick",tag:{light_sword:2}}}] run item modify entity @s weapon.mainhand st:light_sword/giant_sword
- #C.mcfunction
- execute if entity @s[nbt={SelectedItem:{id:"minecraft:carrot_on_a_stick",tag:{light_sword:3}}}] run item modify entity @s weapon.mainhand st:light_sword/short_sword
是这样对吧?你说一下你是怎样执行命令的
你的loot_table里的st:light_sword/*是如何?
或者直接发包也行
lytDARK 发表于 2023-12-1 22:58
是这样对吧?你说一下你是怎样执行命令的
你的loot_table里的st:light_sword/*是如何?
或者直接发包也行 ...
ABC是同一个函数里的,item后面的修饰器就是改NBT。把light_sword:1改成light_sword:2,light_sword:2改成light_sword:3,light_sword:3改成light_sword:1,
阡喏 发表于 2023-12-1 23:15
ABC是同一个函数里的,item后面的修饰器就是改NBT。把light_sword:1改成light_sword:2,light_sword:2改 ...
这个……建议你再写一个战利品表
用战利品表谓词而不是execute if去判断吧
你这个同时触发了,建议改成手动触发(目前最简单的做法就是丢出时触发,你丢掉这个物品的时候进行检测,删除掉落物并给你一个带有新的标签的物品)
常用思路是提前存储判断条件结果
这里简化了一点,提前存储判断条件的值,防止被同步修改
复制代码
这里简化了一点,提前存储判断条件的值,防止被同步修改
- scoreboard objectives add temp dummy
- execute store result score @s temp run data get entity @s SelectedItem.tag.light_sword
- execute if score @s temp matches 1 run item modify entity @s weapon.mainhand st:light_sword/long_sword
- execute if score @s temp matches 2 run item modify entity @s weapon.mainhand st:light_sword/giant_sword
- execute if score @s temp matches 3 run item modify entity @s weapon.mainhand st:light_sword/short_sword