Minecraft / Blogs

[C|T #3] Data tags

  • 9
  • 5
  • comment3
  • playlist_add
  • share
  • more_horiz
avatar Bertiecrafter
Level 36 : Artisan Engineer
36
So in case you didn't know, command blocks can do lots in vanilla minecraft, I made my server with them and you can find tons of "one command" videos. I am not going to explain you how to make one commands, but only how you can use Data Tags and JSON in your commands.

The following commands use Data Tags or JSON:
/blockdata, /entitydata, /give, /replaceitem, /scoreboard, /setblock, /summon,
/tellraw, /testfor, /testforblock and /title.
Because there are quite a lot commands that use Data Tags, it's important to learn how they work to get the most out of them.

I would strongly recommend reading [C|T #1] The basics, before reading this.
Also this one is more difficult than [C|T #2] The scoreboard, you might want to try and understand that one first.

Every time the syntax of a command (receivable by using /help <command without />) allows you to use Data Tags, you need to start with { and }, all your data tags go inside there.

Data Tags are separated by commas and every tag that you put inside those curly brackets, consists of a key (the name of a property) and a value (what the property is).

Syntax: {key:value,key:value,key:value}
(of course there can be more keys and values)


Types of keys

Byte, Short, Integer and Long: These keys require a whole number as value. Every kind has a different range, but don't worry about that too much, because the type will match the purpose of a key. E.g the count key of a dropped item doesn't need to be type "Long". Long goes to 9,223,372,036,854,775,807 (both positive and negative).

Float and Double: These kind of keys require decimal numbers.

Booleans: True or false, but in MC you define them with a "Byte" type (see above). 0 = false, 1 = true.

String: These ones require text as value, you surround them with " and if you want to use " in your text, you need to escape them with a \. Example: "Hi, my name is \"Bertiecrafter\", how are you?"

List and Integer Array: These keys require a list of values, not just one. You need to put your values between [ and ], separated by commas. The difference between the two things is that the values in a list could be anything, but in an integer array they need to be whole numbers. There is one rule for both kinds: All values in the list need to be from the same kind.

Compound: This is where it gets tricky, the value of this key is another list of keys and values, surrounded by {}!

Icons used on the wiki pages for every key

Byte = B
Short = S
Integer = I
Long = L
Float = F
Double = D
Booleans use the Byte type, so these are also indicated with a B
String = multiple lines under each other, like a written page
List = a bullet list with dots and lines
Integer Array = <>
Compound = Red, blue and green coloured shapes

Wiki pages where you can find the tags you need

All dynamic things in your mc world, including:
Mobs, Projectiles, Items and XPOrbs, Vehicles (Minecarts), Dynamic tiles (tnt, anvil, sand, gravel) and more!
Click here!

Detecting player tags (Can't be edited) and defining inventory items and skulls:
Click here!

Text for chat and titles (all keys must be between " here, this is also called STRICT JSON!):
Click here!

If the meaning of a value doesn't become clear from the key, there will most likely be a link to another wiki page. This happens with e.g: Enchantments and potion effects.

Examples

Using the link for chat and titles:
/tellraw @a {"text":"Hello there!","color":"blue","bold":1}
This will output "Hello there!" in bold and blue to everyone (@a).
/tellraw @r {"text":"Herobrine joined the game","color":"yellow"}
This will let a random player think that herobrine joined the game.

Using the link for player tags and inventory items and skulls:
/give @p fish 1 0 {ench:[{id:19,level:1000}]}
Ench = a list of compounds, describing one enchant with the id and level keys.
Ench contains only one compound tag here.
The command will give the nearest player (@p, yourself if you execute it from the chatbox) a fish with knockback (indicated by id 19) level 1000.
The 1 indicates only 1 fish, the 0 indicates type/subid 0.

Using the top most link with pretty much everything:
/summon sheep ~ ~ ~ {CustomName:"jeb_"}
This will spawn a rainbow sheep!
/summon magma_cube ~ ~ ~ {Size:15}
This will spawn a huge Magma Slime (Up to size 3 will spawn naturally)

A bit more difficult:
/summon bat ~ ~ ~ {Passengers:[{id:"sheep",CustomName:"jeb_"}]}
The Bat has one Passenger (Only one compound in the list), a sheep.
The sheep is called "jeb_" so it will be rainbow!
Result: Flying rainbow sheep!

Tutorial, step by step

We are going to make a zombie with diamond armor and an enchanted diamonds sword.
To start, we need to spawn something, if you didn't know how that works, you use the following command:
/summon

The syntax = /summon <entity> [x] [y] [z] [DataTag']
Of course we want to summon a zombie so we get:
/summon zombie

By default this will summon it right on the spot you are standing, but since we want to use Data Tags, we need to add the location too. To use the current location:
/summon zombie ~ ~ ~

On the first wiki page you can find the zombie data tags, if you unfold that section, you find the tags common to all mobs and if you unfold that, you find ArmorItems key. The icon tells us that it's a list:
/summon zombie ~ ~ ~ {ArmorItems:[ ]}

The information next to the key tells us that it's a list of items and the keys under the ArmorItems key says that the items are compounds (the coloured dots).
/summon zombie ~ ~ ~ {ArmorItems:[{ },{ },{ },{ }]}

The inventory items wiki page tells us that we use the key "id" to indicate what item we use, the icon tells us it's a string, let's fill in the names of the items at the same time. You can find them with F3 + H in MC and then just hover your mouse above the item you need:
/summon zombie ~ ~ ~ {ArmorItems:[{id:"diamond_boots"},{id:"diamond_leggings"},{id:"diamond_chestplate"},{id:"diamond_helmet"}]}

So now we need to add a tag for the sword outside the ArmorItems tag of course.
Back at the first wikipage with tags common to all mobs, it tells us to use the key HandItems (list of compounds). We only want to use the main hand, so we won't define the other tag:
/summon zombie ~ ~ ~ {ArmorItems:[{id:"diamond_boots"},{id:"diamond_leggings"},{id:"diamond_chestplate"},{id:"diamond_helmet"}],HandItems:[{ }]}

Still with me?
Now with the id tag we define that it's about a diamond sword:
/summon Zombie ~ ~ ~ {ArmorItems:[{id:"diamond_boots"},{id:"diamond_leggings"},{id:"diamond_chestplate"},{id:"diamond_helmet"}],HandItems:[{id:"diamond_sword"}]}

From here, the bold options in the text editor didn't want to work anymore, so bear with me!
Also, the square bracket to indicate the start of the ench key (list) keeps being deleted.
Sorry for the inconvenience, just keep looking at the end of the command!

Back on the inventory items page we find the enchantment tag... we need to put the ench key in the tag key, because we need to define an entire item. Unlike with /give, the item, count and subid/damage aren't given. The tag key is compound:
/summon Zombie ~ ~ ~ {ArmorItems:{id:"diamond_boots"},{id:"diamond_leggings"},{id:"diamond_chestplate"},{id:"diamond_helmet"}],HandItems:[{id:"diamond_sword",tag:{ }}]}

And the ench key is just a list of compounds again (indicated with the list icon and compoun icons under it)
/summon Zombie ~ ~ ~ {ArmorItems:[{id:"diamond_boots"},{id:"diamond_leggings"},{id:"diamond_chestplate"},{id:"diamond_helmet"}],HandItems:[{id:"diamond_sword",tag:{ench:{ }]}}]}

So now we define the sharpness id and level (those keys are also on the inventory items page under enchantments.
We use id 16 for sharpness (there is a link to a list of id's next to the ench key on the wiki page), level 5 (this is normally the max level):
/summon Zombie ~ ~ ~ {ArmorItems:[{id:"diamond_boots"},{id:"diamond_leggings"},{id:"diamond_chestplate"},{id:"diamond_helmet"}],HandItems:[{id:"diamond_sword",tag:{ench:{id:16,level:5}]}}]}

The command got so long, that we can't put it in our chatbox anymore. If we put it in a commandblock, the zombie will spawn with his feet in the command block, so one more small adjustment and we are done:

/summon Zombie ~ ~1 ~ {ArmorItems:[{id:"diamond_boots"},{id:"diamond_leggings"},{id:"diamond_chestplate"},{id:"diamond_helmet"}],HandItems:[{id:"diamond_sword",tag:{ench:{id:16,level:5}]}}]}


I hope this helped you with making epic creations with vanilla commands!


My Server: GIBI

Click the banner for more info!
Tags

2 Update Logs

Update #2 : 02/01/2017 10:24:44 amFeb 1st, 2017

Updated the tutorial to the most recent update.
Made this blog part of the CBT series.
LOAD MORE LOGS

Comments : 3

star Login or register to post a comment.

Show Comments

1 - 3 of 3

Thank you Mattia11, camo_scout, techboy04, shadow_ninja290, pettyGamingHD, catmelonhat, Jennpai, 0Sugar and Edward for the diamond! :P
  • 0Sugar
  • Level 22
  • Expert Toast
  • April 27, 2016, 1:55 am
Great help Bertie! You need to make some more tutorials
Thanks for the diamond and maybe I will in the future! :D

1 - 3 of 3

Show Comments

Planet Minecraft

Browse

Site

© 2010 - 2019
planetminecraft.com

Welcome