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...

12 Steps 2 min read Medium

Step-by-Step Guide

  1. 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.
  2. 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:}".
  3. Step 3: is meant to be used in command blocks.

  4. Step 4: Type /testfor and hit enter.

  5. Step 5: Make the most basic application.

  6. Step 6: Use this to power a second command block

  7. Step 7: this one running many commands.

  8. Step 8: Use the data tag command.

  9. Step 9: Use another data tag

  10. Step 10: Inventory.

  11. Step 11: Use multiple data tags at once

  12. 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

K

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.

45 articles
View all articles

Rate This Guide

--
Loading...
5
0
4
0
3
0
2
0
1
0

How helpful was this guide? Click to rate: