1

I have an item in a datapack which has a supplemental function to give it straight to the player (for testing), and an entry in a loot table (which is how survival players get it). I recently noticed that these two items will not stack, under any circumstances, even though they should have the exact same nbt data. The /give command looks like this:

give @s minecraft:quartz{dmd_dark_quartz:1b,CustomModelData:256,display:{Name:"{\"text\":\"Dark Quartz\",\"color\":\"dark_purple\",\"italic\":\"false\"}"}} 1

While the loot table looks like this:

{
  "type": "minecraft:item",
  "conditions": [
    {
      "condition": "random_chance",
      "chance": 0.75
    }
  ],
  "functions": [
    {
      "function": "set_name",
      "name": {"text":"Dark Quartz","color":"dark_purple","italic":"false"}
    },
    {
      "function": "set_nbt",
      "tag": "{dmd_dark_quartz:1b,CustomModelData:256}"
    },
    {
       "function": "minecraft:explosion_decay"
    }
  ],
  "name": "minecraft:quartz"
}

When I hold the two items in my hand and use /data get entity @s SelectedItem, the only difference is that there are no quotes surrounding the false value for italics in the loot table version. Here's a picture for further clarification of what I mean:
data get screenshot
I underlined the false values that were different. Does anyone know if this is a bug or what causes this? I think it's probably a bug because all other values ("dark_purple", for example) have the quotes, but that singular one doesn't. Is it because it is a true/false value and doesn't need quotes? I would prefer if they stacked because then testing would be easier and I wouldn't have to test both versions for everything, but not including quotes in the /give command seems a bit sacrilegious.

Upon further testing, not including the quotes in the /give command gives an item that has the exact same nbt (so the /data get looks exactly the same) as the loot table version but still doesn't stack with either one.

Any answers on why this is happening?

6
  • I'll put a link to a datapack with the function and loot table in case anyone is interested tomorrow morning.
    – Nik3141
    Commented Aug 7, 2019 at 1:12
  • The JSON is just a string for the game, so the order of keys matters. (Did that already answer your question? Then I'll write a lame answer. ;) ) Commented Aug 7, 2019 at 7:54
  • @Fabian In both commands, the order is the same: text, color, italic. I'll try that in the third command however, because I don't remember if I put them in the same order (although I thought I did).
    – Nik3141
    Commented Aug 7, 2019 at 15:04
  • Your screenshot shows "italic text color" and "italic color text". Commented Aug 7, 2019 at 15:38
  • @Fabian That must be it, but I have no idea why that happens. The commands/loot table all go 'text color italic', so maybe Minecraft reorganizes NBT internally? When I get back I'll try changing the order in the command and seeing if the values have switched.
    – Nik3141
    Commented Aug 7, 2019 at 16:45

2 Answers 2

1

Try using set_nbt function only like:

  "function": "set_nbt",
  "tag": "{display:{Name:'{\"text\":\"Dark Quartz\",\"color\":\"dark_purple\",\"italic\":false}'},CustomModelData:1}"

I was testing it on wandering traders trades and it worked! Name, color and italic option are exatly the same arregment as from /give command.

0

false is not supposed to be in quotes.

You must log in to answer this question.

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