3

Command Help: Putting Scores into NBT Data

TofuChild27's Avatar TofuChild2712/8/20 7:20 pm
3 emeralds 4.4k 5
12/9/2020 10:23 am
Bertiecrafter's Avatar Bertiecrafter
Hello!

I have been trying to work out a way to put the number of a scoreboard inside a NBT tag (e.g., Test:The Scoreboard Valueb). I have not been able to figure it out for the life of me.

Any help would be appreciated!
Posted by TofuChild27's Avatar
TofuChild27
Level 1 : New Miner
0

Create an account or sign in to comment.

5

1
12/09/2020 10:19 amhistory
Level 70 : Legendary Engineer
Bertiecrafter
Bertiecrafter's Avatar
You can use this:
/execute store result <entity|block|storage> (...) <type> <scale> run scoreboard players get <player> <objective>
Have a look at my tutorial blog for more information about combining scoreboard and NBT powers, or view the full /execute spec here. =)

EDIT: Ah, I missed the context you explained in a comment... Maybe you should copy that to the description haha
1
12/09/2020 4:31 am
Level 61 : High Grandmaster Modder
Kodisa
Kodisa's Avatar
I think you have to make many command blocks and define scores. Something like this (Commands for 1.16):
scoreboard players set @a Item 0

scoreboard players set @a[nbt={SelectedItem:{id:"minecraft:iron_sword",tag:{Damage:1}}}] Item 1
scoreboard players set @a[nbt={SelectedItem:{id:"minecraft:iron_sword",tag:{Damage:2}}}] Item 2
scoreboard players set @a[nbt={SelectedItem:{id:"minecraft:iron_sword",tag:{Damage:3}}}] Item 3
You can use for example Inventory instead of SelectedItem. Then youre able to define a slot where this Item should be in too.

With the scores you can use replaceitem:
replaceitem @a[scores={Item=1}] weapon.offhand ITEM1
replaceitem @a[scores={Item=2}] weapon.offhand ITEM2
replaceitem @a[scores={Item=3}] weapon.offhand ITEM3

So just define how you get the scores 1, 2, 3, ... and then its easy. Hope I could help you.
Kodisa
1
12/09/2020 10:08 am
Level 1 : New Miner
TofuChild27
TofuChild27's Avatar
Thank you!
I sort of already figured out I'm going to have to bite some bullet to get it to work. I was just hoping there was something I was missing. Thanks again!
1
12/08/2020 7:53 pm
Level 1 : New Miner
TofuChild27
TofuChild27's Avatar
I am trying to figure out a way to replace an item in the offhand with the same item but with a different NBT tag number because I know you can not modify player data.
1
12/09/2020 10:23 am
Level 70 : Legendary Engineer
Bertiecrafter
Bertiecrafter's Avatar
Note that modifying an item in offhand is still considered modifying the player and that's impossible. You can use /replaceitem to clear the offhand and then use my comment above to insert your scoreboard value into an item on the ground (that you made with /summon) the player will then automatically pick it up and have to manually move it back to their offhand.

If you want to replace the value straight away, you have to make separate commands like Kodisa said.
Planet Minecraft

Website

© 2010 - 2024
www.planetminecraft.com

Welcome