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?


2 Answers 2


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

You could try getting the data of the sword using the command:

/data get entity @s SelectedItem

and pasting it like that:

execute as @e[nbt={SelectedItem:{id: "minecraft:netherite_sword", Count: 1b, tag: {RepairCost: 0, Damage: 0,  
display: {Name: '{"text":"<name_of_the_sword>"}'}}}}]  
run effect give @s minecraft:strength 1 2

At least that's how I would do it.

  • i put the name in the name slot and it didnt work Jul 27 at 22:43

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .