'Unbalanced Curly Brackets' Error with this command block code, what am I doing wrong? [duplicate]

I am trying to make a chest that is called 'I' that has another chest inside called 'II' that has another chest inside called 'III' that has another chest inside called 'IV' that has another chest called 'V' that has a piece of paper called 'An important message...' and it has a lore saying

自分自身を解放する方法があります。呪文はもう一度私たちの魂を得る。しかし、我々はそれを話さなければならない - 私たちは話すないとき - 音が出ないを。我々は、すべての耳が聞こえています。だから、失敗は避けられない。そして、私は今まで私の中の悪魔で、私の内部賭けに入る後悔。不滅か。魂のひったくり。ジェイク対ゲイリー·クルック。野望は過大評価され。

I keep getting 'Unbalanced Curly Brackets' every time I try use this command. I checked with Notepad++, I'm pretty sure the curly brackets are right? Here's the command below, but what am I doing wrong?

/setblock ~ ~ ~ chest 0 replace {Items:[{id:54,Count:1,Slot:13,tag:{display:{Name:"II"},Items:[{id:54,Count:1,Slot:13,tag:{display:{Name:"III"},Items:[{id:54,Count:1,Slot:13,tag:{display:{Name:"IV"},Items:[{id:54,Count:1,Slot:13,tag:{display:{Name:"V"},Items:[{id:339,Count:1,Slot:13,tag:{display:{Name:"An important message...",Lore:[自分自身を解放する方法があります。呪文はもう一度私たちの魂を得る。しかし、我々はそれを話さなければならない - 私たちは話すないとき - 音が出ないを。我々は、すべての耳が聞こえています。だから、失敗は避けられない。そして、私は今まで私の中の悪魔で、私の内部賭けに入る後悔。不滅か。魂のひったくり。ジェイク対ゲイリー·クルック。野望は過大評価され。]}}}]}}}]}}}}],display:{Name:"I"}}}

Solution 1:

You're definitely missing brackets.

Note: While this question already has an answer with the fixed code, I think that it's worth knowing how to fix it yourself, especially for the people coming across this question later. So, I'm going to teach you a technique for finding these missing brackets easily.


Background

Let's talk about Minecraft commands, and why brackets are needed:

Minecraft commands are a very simple programming language. This language uses brackets to help it separate and interpret the different areas of code. It uses braces (curly brackets) { } to mark out items/objects, and square brackets [ ] to make lists of those items/objects,

Every open bracket, whether it be square [ or brace {, needs a corresponding closing bracket (}, ]) in the correct order, otherwise Minecraft gets confused when it tries to interpret them. The order is in reverse, or mirrored, from the appearance of the corresponding bracket.

For example: [ [ { } ] ], or { { [ { } ] } }


The Process

Now, to put this knowledge to the test: How does one find missing brackets easily, in command lines that are hundreds of characters long?

Answer? Space it out to make it easier to read. We add spaces between words, becausethisishardtointerpretwhatI'msayingright? So why not do the same with your command code?

First things first, Download and open up Notepad++

  • It's free and really useful for this sort of thing. Trust me, I use it every day, you'll never go back to regular Windows Notepad, which doesn't have the features we need for this thing:
  • Notepad++ will highlight the currently selected bracket and it's matching close bracket as the cursor runs over them..
  • It also gives you dotted vertical lines running down from brackets to help line up the closing bracket.

Now, onto the process:

  1. In the Notepad++ window, paste your Minecraft Command line and start moving the cursor across using the keyboard arrows, character by character.
  2. Every time you reach an opening bracket or a comma, Press Enter to move it (and the remaining code) to a new line.
  3. Move one more space across (After the bracket), and add another new line and a Tab to shift the rest of the Minecraft Command across.
  4. As you reach closing brackets, move them onto their own line as well, and use Shift-Tab to move it back into line with the opening one (removing the extra tab).
    • As you're doing this, you'll notice that Notepad++ adds dotted lines which link opening and closing brackets together. Use this as a guide to line them up.
  5. Once you've spaced everything out, look for inconsistencies with the closing brackets. the closing brackets should all follow a straight line due to the tab-spacing, all the way down the page.
  6. Note and fix up any missing or out of order brackets you see.

An Example

Using the broken code in the question as an example, I'm going to show you how to solve the problem hands-on. So here's the original Minecraft command:

/setblock ~ ~ ~ chest 0 replace {Items:[{id:54,Count:1,Slot:13,tag:{display:{Name:"II"},Items:[{id:54,Count:1,Slot:13,tag:{display:{Name:"III"},Items:[{id:54,Count:1,Slot:13,tag:{display:{Name:"IV"},Items:[{id:54,Count:1,Slot:13,tag:{display:{Name:"V"},Items:[{id:339,Count:1,Slot:13,tag:{display:{Name:"An important message...",Lore:[自分自身を解放する方法があります。呪文はもう一度私たちの魂を得る。しかし、我々はそれを話さなければならない - 私たちは話すないとき - 音が出ないを。我々は、すべての耳が聞こえています。だから、失敗は避けられない。そして、私は今まで私の中の悪魔で、私の内部賭けに入る後悔。不滅か。魂のひったくり。ジェイク対ゲイリー·クルック。野望は過大評価され。]}}}]}}}]}}}}],display:{Name:"I"}}}

To save us some trouble, I've done Steps 2 to 4 (spacing & newlining) for you already, so you don't need to worry too much about it. Just copy the code broken down like this, and paste it in Notepad++:

/setblock ~ ~ ~ chest 0 replace 
{
    Items:
    [
        {
            id:54,
            Count:1,
            Slot:13,
            tag:
            {
                display:
                {
                    Name:"II"
                },
                Items:
                [
                    {
                        id:54,
                        Count:1,
                        Slot:13,
                        tag:
                            {
                                display:
                                {
                                    Name:"III"
                                },
                                Items:
                                [
                                    {
                                        id:54,
                                        Count:1,
                                        Slot:13,
                                        tag:
                                        {
                                            display:
                                            {
                                                Name:"IV"
                                            },
                                            Items:
                                            [
                                                {
                                                    id:54,
                                                    Count:1,
                                                    Slot:13,
                                                    tag:
                                                    {
                                                        display:
                                                        {
                                                            Name:"V"
                                                        },
                                                        Items:
                                                        [
                                                            {
                                                                id:339,
                                                                Count:1,
                                                                Slot:13,
                                                                tag:
                                                                {
                                                                    display:
                                                                    {
                                                                        Name:"An important message...",
                                                                        Lore:
                                                                        [
                                                                            自分自身を解放する方法があります。呪文はもう一度私たちの魂を得る。しかし、我々はそれを話さなければならない - 私たちは話すないとき - 音が出ないを。我々は、すべての耳が聞こえています。だから、失敗は避けられない。そして、私は今まで私の中の悪魔で、私の内部賭けに入る後悔。不滅か。魂のひったくり。ジェイク対ゲイリー·クルック。野望は過大評価され。
                                                                        ]
                                                                    }
                                                                }
                                                            }
                                                        ]
                                                    }
                                                }
                                        }
                                            ]
                                    }
                            }
                    }
            }
                                ],
                                display:
                                {
                                    Name:"I"
                                }
        }
}

Follow the dotted vertical lines down, and use the bracket highlighting to try and match and line up the brackets. Again, when writing code out like this with tab spaces and newlines, the closing brackets should all line up into a neat row. However, you will have noticed the discrepancies of stuff not quite lining up already. That's ok! Do the best you can to line them up properly, we're about to fix them:

1. First Square Bracket Missing:

Square bracket missing/out of place under the 'Items' heading

To fix this, insert a closing square bracket after the curly brace on the line above (use Shift-Tab to move it into line with the opening bracket above:

Closing square bracket inserted

You'll note that after inserting this, Notepad++ recognises that the lower square bracket is out of place. So go ahead and line up all the brackets again using tabs, and you'll quickly find:

2. Curly Bracket Missing:

You know the drill, insert a closing curly bracket to fix this one up as well:

Curly bracket out of place.

Once again, after inserting the missing bracket, Notepad++ recognises that some are out of place. Re-tab the remaining brackets until they line up with the highlighted line.

3. Square Bracket Missing

You may have noticed that the 'display:' object, which was way out of place, before, is starting to move back into line with the rest of them:

square bracket missing

Inserting a square bracket here, and it should look a lot more in-place after re-tabbing once more. You will also note that you now have an extra closing bracket that doesn't match up with anything. This is ok, just remove it entirely.

You've got the hang of it now. Continue on until everything is lined up and has a matching bracket.


Finalisation

You're done! You can even use Notepad++'s inbuilt replace function to remove the spaces and tabs. Access it using Ctrl+H. Use 'Extended' Mode, and use \n to remove newlines, and \t to remove tabs:

Replace Menu


This should be it! You can now copy out your command and it should work fine.*

* Well, in terms of brackets at least. This is assuming you've coded it to do what you want it to do as well!

Solution 2:

I think there are some errors regarding your brackets (as well curly as square ones)

Try this block:

/setblock ~ ~ ~ chest 0 replace {Items:[{id:54,Count:1,Slot:13,tag:{display:{Name:"II"},Items:[{id:54,Count:1,Slot:13,tag:{display:{Name:"III"},Items:[{id:54,Count:1,Slot:13,tag:{display:{Name:"IV"},Items:[{id:54,Count:1,Slot:13,tag:{display:{Name:"V"},Items:[{id:339,Count:1,Slot:13,tag:{display:{Name:"An important message...",Lore:[自分自身を解放する方法があります。呪文はもう一度私たちの魂を得る。しかし、我々はそれを話さなければならない - 私たちは話すないとき - 音が出ないを。我々は、すべての耳が聞こえています。だから、失敗は避けられない。そして、私は今まで私の中の悪魔で、私の内部賭けに入る後悔。不滅か。魂のひったくり。ジェイク対ゲイリー·クルック。野望は過大評価され。]}}}]}}]}}],display:{Name:"I"}}}]}}]}

Solution 3:

You can do this manually and just make the first chest and then pick block it, now it will become +NBT in purple writing. You can keep on doing that as much as you require.