Here are some commands for you to try in MCJE 1.16. Run the following commands in the chat:

  1. Set up a scoreboard objective. (or use an existing test objective if you hate piling them up, like me)

    /scoreboard objectives add test dummy
  2. Set your own score. Set it to a number you'll remember. Make it low, like 5.

    /scoreboard players set @s test 5
  3. Give yourself a diamond sword with enchantments. Give it a level of a different number than you picked in step 2. I pick 9.

    /give @s diamond_sword{Enchantments:[{id:"minecraft:sharpness",lvl:9s}]}
  4. Try to set the diamond sword's enchantment level to the number in the scoreboard. This is the command I used:

    /data modify entity @s Inventory[{id:"minecraft:diamond_sword"}].tag.Enchantments[{id:"minecraft:sharpness"}].lvl short 1 run scoreboard players get @s test

What this command should do is get your test score and store it in the Sharpness level of the diamond sword. But it doesn't. The level remains 9.

Here is another example with shorter commands. Do steps 1 and 2 like normal, but here's where we'll change things up:

  1. Give yourself a piece of dirt. (any item will do)

    /give @s dirt
  2. Modify the count of that dirt stack by setting it to the scoreboard value.

    /execute store result entity @s Inventory[{id:"minecraft:dirt"}].Count byte 1 run scoreboard players get @s test

Does the count of items modify? For me, it doesn't.

I tested this out using a command chain. Peeking into the command block for command #4, I can see the correct scoreboard value returned: ExpertCoder14 has 5 test, but the scoreboard value still isn't updated.

I checked all the fields, and they were all correct:

  • NBT path: I used /data get with the same NBT path and got back the old value. This means I am using the correct path to target the value to update.
  • Scale: I checked the Minecraft Wiki page on /execute store. The scale is a number that the command result will be multiplied by before storing. I set it to 1.0. This should be correct.

I also ran some additional trials:

  • I used the if subcommand to test for a number of entities instead of /scoreboard players get. Here was a command:

    /execute store result entity @s Inventory[{id:"minecraft:dirt"}].Count byte 1 if entity @e

    Sample output:

    Test passed, count: 14

But the NBT value doesn't change!

Am I doing something wrong? Is this behaviour normal? Is there a bug report that I missed? What is going on?

  • The wiki says that the data command fails if you try to edit a player's data
    – 0mlml
    Commented Sep 11, 2020 at 13:11
  • @Macks What counts as player data?
    – One 2 Many
    Commented Sep 11, 2020 at 14:02
  • @ExpertCoder14 Any data that would show up with /data get entity @s
    – ginkgo
    Commented Sep 12, 2020 at 16:35

1 Answer 1


You can't modify player nbt. You have to move the item to a container modify the conatiner's item. Then loot the item back into the player's inventory. The following link shows you how to edit items in a player's hand. Here. I hope this helped.

  • Could you expand this answer to include all the information that I’ll need without directing me to external sites? It’s a rule here, because if you direct me to an external page, you are basically deferring the answering to someone else.
    – One 2 Many
    Commented Oct 26, 2020 at 0:46
  • ok ill edit the answer Commented Oct 27, 2020 at 14:09
  • @ExpertCoder14 I updated the answer go check it out. Its on the duplicate. Commented Oct 27, 2020 at 15:12

You must log in to answer this question.

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