-1

This is my Minecraft command and I want to give the deity sword a name but my command doesn't work. Can you fix it?

/give @p netherite_sword{Enchantments:[{id:sharpness,lvl:5},{id:knockback,lvl:2},{id:fire_aspect,lvl:2},{id:looting,lvl:2},{id:sweeping,lvl:3},{id:unbreaking,lvl:3},{id:mending,lvl:1}]}{display:{Name:'[{"text":"Wool's Deity Sword"}]'}} 1
3
  • 3
    What is the error you get?
    – Timmy Jim
    Jun 1 at 15:21
  • 1
    I do imagine that Minecraft code runs the same as normal code. So first thing I see is that you have brackets that are open that are not then closed. Basically, for every [ and { they should be closed with } and ] in the reverse order.
    – Fredy31
    Jun 1 at 18:06
  • 2
    Possible duplicate of How can I fix "unbalanced brackets" in my data tag?
    – pppery
    Jun 2 at 0:31

1 Answer 1

0
Corrected version
/give @p netherite_sword{Enchantments:[{id:sharpness,lvl:5},{id:knockback,lvl:2},{id:fire_aspect,lvl:2},{id:looting,lvl:2},{id:sweeping,lvl:3},{id:unbreaking,lvl:3},{id:mending,lvl:1}],display:{Name:'[{"text":"Wool's Deity Sword"}]'}} 1

Like it has already been commented, always say what error you are getting, as your problem might not even be an error problem, but a "wrong" answer instead (for example, it gives you the item but no custom name).

Looking from the command, it looks like it has been parsed wrongfuly, meaning the amount of and/or order of {'s and ['s are wrong, let us expand the command and take a look:

///

By expaning, like @Fredy31 has mentioned in the comments, open this line of command in any text editor and:

  • Every time you find an opening { or [ you create a new line with enter and ident it with blank spaces with tab. Every time you have to tab, make sure to tab further than the last one.

  • If you find ,'s, simply create a new line with same ident space as the last line.

  • Every time you find a closing } or ], also create a new line but, this time, reduce the identation by one.

////

/give @p netherite_sword{          <-- Initial { as of every nbt.
    Enchantments:[                 <-- 1 [ and 1 {
        {id:sharpness,lvl:5},
        {id:knockback,lvl:2},
        {id:fire_aspect,lvl:2},
        {id:looting,lvl:2},
        {id:sweeping,lvl:3},
        {id:unbreaking,lvl:3},
        {id:mending,lvl:1}
    ]                              <-- 0 [ and 1 {
}                                  <-- 0 [ and 0 {
## Here, the game expects the next command token, that is, amount of the /give command.
## Notice how, instead, another { is opened.
{
    display:{
        Name:'[
            {"text":"Wool's Deity Sword"}
        ]'
    }
}

1

How to check if a nbt is right?

The idea begind these structures (Called json), is:

  • { } Are dictionaries, meaning they expect a group of key:value where value can be another a data (integer, string...), dictionary or a list. Each item (key:values) is separated by ,'s. They start with a { and end with }

  • [ ] are lists. They recive only a value separated by ,'s. Value, again, can be any data, dictionaries or other lists.

So what does exactly the game expect? Let's ignore what is inside Enchantments and display:

/give @p netherite_sword{
    Enchantments:[], <-- 'key' is Enchantments and values is '[]'
    display:{}       <-- 'key' is display and value is '{}'
}

1

Now, filling what is inside display and Enchantments:

/give @p netherite_sword{
    Enchantments:[
        {id:sharpness,lvl:5},
        {id:knockback,lvl:2},
        {id:fire_aspect,lvl:2},
        {id:looting,lvl:2},
        {id:sweeping,lvl:3},
        {id:unbreaking,lvl:3},
        {id:mending,lvl:1}
    ],
    display:{
        Name:'[
            {"text":"Wool's Deity Sword"}
        ]'
    }
}

1

Ps.: Even if your json is well structured, you stil have to respect the nbt tree format. Here, Name must be inside display. Both Enchantments and display stay close to the root.

{
Enchantments:[],
display:{Name:[]}
}
4
  • 2
    So, quick tip to find your missing brackets: Indentation; Get yourself Notepad++ or VSCode (I think it does work also in notepad) and every time you open with a [ or { do a line return, and tabulate until its further. Every time you close, one, line return and tabulate less. It makes code like this way more readable than trying to read it on one line.
    – Fredy31
    Jun 1 at 18:09
  • Yes! And I wish people would have shown me this back when I knew nothing about Json/nbt xD
    – BunnyMerz
    Jun 1 at 18:13
  • Yeah, I remember when I started in HTML and was trying to read and figure out the code by doing 'view source' and it was basically impossible to read. But things like VSCode with code coloring and indentation helps a ton
    – Fredy31
    Jun 1 at 18:17
  • On many code editor each time you do a line return the bracket close itself
    – pinckerman
    Jun 1 at 18:23

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