What's wrong with my Minecraft command? [1.18+]



  • 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
    


  • 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{          1

    How to check if a nbt is right?

    The idea begind these structures (Called https://en.wikipedia.org/wiki/JSON#Syntax ), 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:[], 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 https://minecraft.fandom.com/wiki/Player.dat_format#Item_structure . Here, Name must be inside display. Both Enchantments and display stay close to the root.

    {
    Enchantments:[],
    display:{Name:[]}
    }
    


Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2