阡喏
脑子卡了,想不到解决办法
  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

  2. 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

  3. 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,1变2    执行B,2变3    执行C,3变1
顺序执行导致陷入循环,该加什么判断条件

lytDARK
  1. #A.mcfunction
  2. 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

  3. #B.mcfunction
  4. 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

  5. #C.mcfunction
  6. 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,

lytDARK
阡喏 发表于 2023-12-1 23:15
ABC是同一个函数里的,item后面的修饰器就是改NBT。把light_sword:1改成light_sword:2,light_sword:2改 ...

这个……建议你再写一个战利品表
用战利品表谓词而不是execute if去判断吧

罪惡樂章
你这个同时触发了,建议改成手动触发(目前最简单的做法就是丢出时触发,你丢掉这个物品的时候进行检测,删除掉落物并给你一个带有新的标签的物品)

MoonCakeMC
常用思路是提前存储判断条件结果
这里简化了一点,提前存储判断条件的值,防止被同步修改
  1. scoreboard objectives add temp dummy

  2. execute store result score @s temp run data get entity @s SelectedItem.tag.light_sword

  3. execute if score @s temp matches 1 run item modify entity @s weapon.mainhand st:light_sword/long_sword

  4. execute if score @s temp matches 2 run item modify entity @s weapon.mainhand st:light_sword/giant_sword

  5. execute if score @s temp matches 3 run item modify entity @s weapon.mainhand st:light_sword/short_sword
复制代码

第一页 上一页 下一页 最后一页