How to edit tags, arrays and set types

To edit a tag, you must use the "="
For example: /nbt me Health = 15

If tag is not exists, it creates automatically
For example: /nbt item display.Name = "Item Name"

- null

- "display": compound
- - "Name": string "Item Name"

If you create a new numeric tag, you need to specify this type:
/nbt item myTag = 15 <- ERROR!
/nbt item myTag = 15 byte <- OK!
type is not required:

  • for strings. default type is string (but you can change it)
  • for hexadecimal values. default type is int
  • for colors. default type is int
  • if tag already exists
  • if you has yaml template for this tag

If you do not specify index in square brackets, a new element will be created:
/nbt item display.Lore[] = "New Lore"

- null

- "display": compound
- - "Lore": list of strings
- - * string "New Lore"

/nbt item display.Lore[] = "Other Lore"

After this:
- "display": compound
- - "Lore": list of strings
- - * string "New Lore"
- - * string "Other Lore"

If you want to create empty compound or list, type
/nbt object query = conpound or list
/nbt item newOneEmptyCompound = compound
/nbt item newOneEmptyList = list

empty Arrays can be created by commands:
/nbt object query = int[]
/nbt object query = byte[]
/nbt object query = [] int
/nbt object query = [] byte

Create arrays with values:
/nbt object query = [1,2,3] int
/nbt object query = [4,5,6] byte
you can set some values in hex mode: /nbt object query = [#A0,#F0F080,35] int

You can edit array int[] byte[] as if you edit list. But the array must exist!

- null
/nbt item myArray = [1,2,3,4,5] int
- "myArray": int[] 1,2,3,4,5
/nbt item myArray[0] = 100
- "myArray": int[] 100,2,3,4,5
/nbt item myArray[] = 200
- "myArray": int[] 100,2,3,4,5,200
/nbt item myArray[8] = 300
- "myArray": int[] 100,2,3,4,5,200,0,0,300
/nbt item myArray[5] remove
- "myArray": int[] 100,2,3,4,5,0,0,300


Posts Quoted:
Clear All Quotes