misode / misode.github.io

Data Pack Generators and Tools for Minecraft 1.15, 1.16, 1.17, 1.18, 1.19, 1.20, 1.21
https://misode.github.io/
MIT License
491 stars 68 forks source link

SNBT output type can generate invalid SNBT arrays (containing more than 1 data type) #552

Open DorkOrc opened 1 week ago

DorkOrc commented 1 week ago

For example, this item modifer outputs:

{
  function: "minecraft:set_name",
  name: [
    {
      text: "Hello"
    },
    " World"
  ]
}

Which is invalid SNBT because arrays can only contain elements of the same type, but this contains a compound and a string.

In this specific case, the plain string, " World", should be changed to the compound {text:" World"} as that's how the game naturally would handle it.

This seems like something that would need case-by-case solving. You could always just have a little warning sign if it does happen somewhere that isn't solved saying "Warning this isn't actually valid SNBT!".

DorkOrc commented 1 week ago

Other examples include places where you can have lists of text components, or other objects and plain text lines. Examples: