Siphalor / nbt-crafting

A 1.15+ fabric Minecraft mod to enable nbt related recipe stuff
https://modrinth.com/mod/nbt-crafting
Apache License 2.0
49 stars 26 forks source link

[bug] Required to wrap attributes in escaped stringified json? #96

Closed Greg-J closed 2 years ago

Greg-J commented 2 years ago

Fabric 1.18.1

This may be intended, but I find it strange. If I attempt to use the following recipe, the recipe fails to load:

{
  "type": "minecraft:crafting_shapeless",
  "ingredients": [
    {
      "item": "minecraft:paper"
    },
    {
      "item": "minecraft:gunpowder"
    },
    {
      "item": "minecraft:gunpowder"
    },
    {
      "item": "minecraft:gunpowder"
    },
    {
      "item": "minecraft:gunpowder"
    },
    {
      "item": "minecraft:gunpowder"
    },
    {
      "item": "minecraft:gunpowder"
    },
    {
      "item": "minecraft:gunpowder"
    },
    {
      "item": "minecraft:gunpowder"
    }
  ],
  "result": {
    "item": "minecraft:firework_rocket",
    "count": 3,
    "data": {
      "Fireworks": {
        "Flight": 127
      },
      "display": {
        "Name": [
          {
            "text": "Strength X",
            "italic": false
            }
          ]
      }
    }
  }
}

However, the following recipe loads just fine:

{
  "type": "minecraft:crafting_shapeless",
  "ingredients": [
    {
      "item": "minecraft:paper"
    },
    {
      "item": "minecraft:gunpowder"
    },
    {
      "item": "minecraft:gunpowder"
    },
    {
      "item": "minecraft:gunpowder"
    },
    {
      "item": "minecraft:gunpowder"
    },
    {
      "item": "minecraft:gunpowder"
    },
    {
      "item": "minecraft:gunpowder"
    },
    {
      "item": "minecraft:gunpowder"
    },
    {
      "item": "minecraft:gunpowder"
    }
  ],
  "result": {
    "item": "minecraft:firework_rocket",
    "count": 3,
    "data": {
      "Fireworks": {
        "Flight": 127
      },
      "display": {
        "Name": "[{\"text\":\"Strength X\",\"italic\":false}]"
      }
    }
  }
}

This is confusing to me.

Siphalor commented 2 years ago

Well, you always need to stringify the JSON of text components, that's what the vanilla game wants. It would be out of scope for Nbt Crafting to change that directly.

Nbt Crafting does provide some sugar to that stringification though, to make it easier to work with (see the wiki):

{
  ...

  "result": {
    "item": "minecraft:firework_rocket",
    "count": 3,
    "data": {
      "Fireworks": {
        "Flight": 127
      },
      "display": {
        "Name": [
          {
            "text" :"Strength X",
            "italic": false
          },
          "nbtcrafting:stringify"
        ]
      }
    }
  }
}