1

I've been experimenting with attribute modifiers on items. What's interesting is that each attribute modifier requires a UUID. So I've provided one myself by simply punching in random numbers on my keyboard number pad.

I know that in NBT, the UUID is stored in an Integer Array, which is formatted like this:

[I;1,2,3,4,5,6]

And here are two of my completed commands (this is as minimal as it gets):

give @p diamond_sword{AttributeModifiers:[{AttributeName:"generic.attack_damage",Name:"generic.attack_damage",Amount:1,Operation:0,UUID:[I;385638563,384738473,018492747,395785936]}]} 1
give @p diamond_sword{AttributeModifiers:[{AttributeName:"generic.attack_damage",Name:"generic.attack_damage",Amount:1,Operation:0,UUID:[I;828748274,736284721,276385632,174612674]}]} 1

If you don't want to get that complicated, I've stripped it down to the bare minimums, with these commands using user-defined tags (they don't do anything but make it look cleaner:)

give @p dirt{MyIntArray:[I;123,345,567,789]}
give @p dirt{MyIntArray:[I;123,456,789,012]}

In both of the above examples, one of them causes an error. The other does not. But all I did was enter different numbers. What could be the problem?

1

This is some very interesting behaviour that I found out while answering this question. I'd like to share my findings in this post. Let it be a guide for using NBT.


Consider a simple CanDestroy statement. When you think of it, it looks like this:

/give @s minecraft:diamond_pickaxe{CanDestroy:["minecraft:dirt"]}

But some posts don't have the quotes around the value. Try out their commands, for example: /give @s dirt{CanDestroy:[dirt]}. Does it work?

Surprisingly, yes.

Apparently, you don't need need to type the surrounding quotes if your string only consists of the following characters (whitespace not included):

+-.0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz

The one exception is if the entry is treated as a number, which would count for entries like 12b,512s, and 82664. But if the number is formatted incorrectly and would fit into the above category of quoteless strings, it will, even if you don't want it to. The following number lookalikes will becomie strings:

  • Numbers with leading zeros: (012b, 04582s)
    To solve, remove leading zeros from your numbers: (12b, 4582s)
  • Numbers outside the range of your data type: (255b, 2177548418058)
    To solve, ensure the correct data type is specified: (2552177548418058l)
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.