Minecraft – Why doesn’t this Minecraft “/give” command work

minecraft-commandsminecraft-java-edition

/give x_xstolasx_x diamond_sword 1 0 {display:{Name:"Hellbringer"},Lore:["Guilty."],ench:{[id:"20",lvl:"2"],[id:"16",lvl:"10"],[id:"19",lvl:"2"]}}

This is the command I typed in to the command block. In the "Previous Output" section, it is saying

[19:32:06] Data tag parsing failed: Unbalanced curly brackets {}: {display:Name:"Hellbringer"},Lore:["Guilty."]},ench:{[id:"20",lvl:"2"],[id:"16",lvl:"10"],[id:"19",lvl:"2"]}

Please help me, I need this sword for something I am doing.

Best Answer

A compound tag surrounds its data in curly brackets, while a list tag surrounds its data in square brackets. All tags except for those directly within a list must have a name.

The ench tag is a list, yet you have declared it as a compound because it's opened using curly brackets:

ench:{[],[],[]}

And within those curly brackets you have unnamed lists, which breaks syntax. The ench tag is instead a list of compounds:

ench:[{},{},{}]

You have also declared the id and lvl tags as strings by using quotation marks, when they are supposed to be numerical (specifically a short; a number between -32,768 and 32,767).

The game will not auto-correct any tag-types within item data, so by declaring it as an integer (number between -2,147,483,648 and 2,147,483,647) it will remain an integer and not the standard short. The game will still recognize that it's a numerical value even in that case. To declare a short, you append a numerical value with an "s". To declare an integer, you simply use a numerical value.

The Lore list must be placed within the display compound.

Fixed command, using the correct tag-types for enchantments:

/give x_xstolasx_x diamond_sword 1 0 {display:{Name:"Hellbringer",Lore:["Guilty."]},ench:[{id:20s,lvl:2s},{id:16s,lvl:10s},{id:19s,lvl:2s}]}

Alternative, using integers to show that the game will accept it:

/give x_xstolasx_x diamond_sword 1 0 {display:{Name:"Hellbringer",Lore:["Guilty."]},ench:[{id:20,lvl:2},{id:16,lvl:10},{id:19,lvl:2}]}

It is recommended to declare correct tag-types for the sake of consistency, since enchantments applied through normal means will be shorts.

Related Topic