How do I give a Netherite Sword strength 2 if it's named a specific way?



  • Here's the command I've tried:

    /execute at @p[nbt={SelectedItem:{id:"minecraft:netherite_sword"}}] run effect give @p minecraft:strength 1 2
    

    This works on all netherite swords.

    How do I get it to work with only a custom named netherite sword?



  • There's a lot of unnecessary data in Alexander's answer, but it would work on a brand new sword with zero damage and zero prior repairs. A condensed version of his command that works on all custom-named netherite swords would be:

    /execute as @a[nbt={SelectedItem:{id:"minecraft:netherite_sword",tag:{display:{Name:'{"text":"REPLACEME"}'}}}}] run effect give @s minecraft:strength 1 2
    

    Change REPLACEME to the name of the sword. Note that this gives strength 3, because it adds 2 levels of strength to the base level of 1.

    You can see the command structure here:

    execute as                            //execute the command as the target
    @a                                    //select all players
    [nbt={                                //check their NBT data
      SelectedItem:{                      //check their selected item:
        id:"minecraft:netherite_sword",   //check it is a netherite sword
        tag:{                             //check it has a tag
          display:{                       //check that it's a display tag
            Name:'{                       //check that it's a Name tag
                                          */note the ' before the {
                                          */if it's not present the command breaks
              "text":"REPLACEME"          //check that the exact text is REPLACEME
            }'
          }
        }
      }                                             //if all of the above is true
    }] run effect give @s minecraft:strength 1 2    //give the holder of the sword strength 3
    



Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2