Minecraft Blogs / Tutorial

/testfor is complicated?Then check this out!

  • 3,072 views, 0 today
  • 2
  • 0
Mr0-Redmen's Avatar Mr0-Redmen
Level 34 : Artisan Engineer
/testfor is used a lot!
The coolest mapes use it!
So I'm going to show you how!
Blue-Testfor help.
Gold-NBT help
Red-NBT examples and tutorial.
Green-Random Text
1.What is /testfor?
/testfor is a command that use used to look for players and entities with specific NBTdata.
2.How to use it?
Easy, all you have to do is run this command
This looks for the closest player to the executer of the command.
This is a very very very very large area to talk about.
NBT is the additional info on an entity.Like what are they riding,if bats are flying or hanging upside down,if they are invurnable, if items are enchanted,have custom names/lores ...
NBT is listed in tags, all of these tags can be found here:
NBT Tags List
Here are some examples.
The most used one:
 1.He's holding a sword.
This will test if a player is holding a sword.The command is:
This command is very long, lets go through the nbt step by step.
This is the inventory tag, it basicly allow us to say what will the player have in his inventory.  1.2.What is id?                            The id of the item,this basicly says witch item we are looking for.I made a mistake, you can't use number ids, you have to use names example:                 minecraft:stone.                         1.3.Whats a slot?                       I mostly covered this in my /replaceitem tutorial(check it out for more info on slots).It basicly says in witch slot(the places were you put items) the item is going to be!

You can leave this blank if you just want it to be in his inventory.

How many items is there.

1.5.What is damage?
This takes us way way back when damage was only used to determine the durability of an item, now damage/data now its called data is used to determine many things about specific stuff, for instance what color is a wool.Since we are talking about a sword it will set its durability.

1.6.Whats SelectedItemSlot:0b? 

This out of the Inventory tag, this says what slot the player selected, since we said that he has a iron sword in his first slot typing this will also look if the player has selected the first slot, that is the sword.

If you want to learn more about different commands you could check out my profile.

Create an account or sign in to comment.