How to Use /Tesfor for Map Making Purposes (Minecraft)
Understand that the /testfor command, although able to be used by a player, is meant to be used in command blocks., Type /testfor and hit enter., Make the most basic application., Use this to power a second command block, this one running many...
Step-by-Step Guide
-
Step 1: Understand that the /testfor command
If you don't know how to get a command block, all you need to do is type: "/give (Player) minecraft:command_block".
You cannot find this block in the creative inventory. -
Step 2: although able to be used by a player
It gives you the syntax of the command.
But as explained, it is meant to be used in a command block.
If this is in a Adventure Map, you don't know who you will be testing for.
So where you type player, you can use some fillers.
These include: @p(Targets the nearest player), @a(Targets all players), @r(Targets random player), or @e(This targets all entities.
This was added in the
1.8 update.) The last part of the syntax is a data tag.
This will be covered later. , This is to see if a player is online.
However, it is easier to just press your tab button on your keyboard (in Multiplayer).
However, you can have a comparator take an output from a command block, just like it can take from a chest.
To do this, place a comparator with the input against the command block.
It the command succeeds (finds the player), it will give a redstone signal. , One of the easiest is /tell, having it tell you something.
You can you use /tellraw for a more aesthetic look, but this requires a JSON text, and that is a completely different subject, one that requires it's own tutorial.
The first command block tests for a player, and the second one tells you that this player is online. , We will cover and explain two types, but the rest you will have to do some research to learn.
In the command syntax, you would type: "/testfor (Player) (Data Tag)".
Data tags are written in brackets({}).
One Data Tag is the Selected Slot tag.
To use this, type: "/testfor (Player) {SelectedSlot:(Slot #)}" The slots are listed starting at 0, so your first hotbar slot is actually slot
0.
Your second hotbar slot is slot 1, and so on. , The syntax for this one is tricky.
Type "/testfor (Player) {Inventory:}" This only works for hotbar slots. , For example, type: "/testfor (Player) {SelectedItemSlot:0,Inventory:}". -
Step 3: is meant to be used in command blocks.
-
Step 4: Type /testfor and hit enter.
-
Step 5: Make the most basic application.
-
Step 6: Use this to power a second command block
-
Step 7: this one running many commands.
-
Step 8: Use the data tag command.
-
Step 9: Use another data tag
-
Step 10: Inventory.
-
Step 11: Use multiple data tags at once
-
Step 12: just separate them with a coma.
Detailed Guide
If you don't know how to get a command block, all you need to do is type: "/give (Player) minecraft:command_block".
You cannot find this block in the creative inventory.
It gives you the syntax of the command.
But as explained, it is meant to be used in a command block.
If this is in a Adventure Map, you don't know who you will be testing for.
So where you type player, you can use some fillers.
These include: @p(Targets the nearest player), @a(Targets all players), @r(Targets random player), or @e(This targets all entities.
This was added in the
1.8 update.) The last part of the syntax is a data tag.
This will be covered later. , This is to see if a player is online.
However, it is easier to just press your tab button on your keyboard (in Multiplayer).
However, you can have a comparator take an output from a command block, just like it can take from a chest.
To do this, place a comparator with the input against the command block.
It the command succeeds (finds the player), it will give a redstone signal. , One of the easiest is /tell, having it tell you something.
You can you use /tellraw for a more aesthetic look, but this requires a JSON text, and that is a completely different subject, one that requires it's own tutorial.
The first command block tests for a player, and the second one tells you that this player is online. , We will cover and explain two types, but the rest you will have to do some research to learn.
In the command syntax, you would type: "/testfor (Player) (Data Tag)".
Data tags are written in brackets({}).
One Data Tag is the Selected Slot tag.
To use this, type: "/testfor (Player) {SelectedSlot:(Slot #)}" The slots are listed starting at 0, so your first hotbar slot is actually slot
0.
Your second hotbar slot is slot 1, and so on. , The syntax for this one is tricky.
Type "/testfor (Player) {Inventory:}" This only works for hotbar slots. , For example, type: "/testfor (Player) {SelectedItemSlot:0,Inventory:}".
About the Author
Kenneth Richardson
Kenneth Richardson is an experienced writer with over 13 years of expertise in telecommunications. Passionate about sharing practical knowledge, Kenneth creates easy-to-follow guides that help readers achieve their goals.
Rate This Guide
How helpful was this guide? Click to rate: