1

/testforblock help

Lou_Dude929's Avatar Lou_Dude9297/25/14 7:00 pm
1 emeralds 433 1
7/26/2014 11:55 am
TheRedSkorpion's Avatar TheRedSkorpion
For a project I'm doing I need to be able to detect a block update for a redstone repeater. Is there any way to use /testforblock to find if it's delay is changed using only one command block?
Posted by Lou_Dude929's Avatar
Lou_Dude929
Level 8 : Apprentice Miner
2

Create an account or sign in to comment.

1

1
07/26/2014 11:55 am
Level 20 : Expert Engineer
TheRedSkorpion
TheRedSkorpion's Avatar
Sure it's possible the suntax for the command is
testforblock <x> <y> <z> <TileName> [dataValue] [dataTag]
found on the command wiki
The TileName is "minecraft:powered_repeater" or "minecraft:unpowered_repeater".
The dataValue depends of the orientation of the repeater you want to test (north, south, east or west) and the number of tick (1, 2, 3 or 4). You can find the data values for the repeater on this wiki.
You can also leave the dataTag empty.

To know what is the data value that you really need, you must be able to read the wiki. This is the table I copied from the wiki:

Low (1st & 2nd) bits:
0x0: Facing north
0x1: Facing east
0x2: Facing south
0x3: Facing west
High (3rd & 4th) bits:
0x0: 1 tick delay
0x1: 2 tick delay
0x2: 3 tick delay
0x3: 4 tick delay

Basicaly you need to convert these 0x0, 0x1 ... into one number that will be your data value. I figured it out by myself so it might not be the best explaination.

- first you check the number of tick you want (1, 2, 3 or 4)
- take the number associated with it and multiply it by 4 (so 0*4 for 1 tick, 1*4 for 2 ticks, 2*4 for 3 ticks and 3*4 for 4 ticks)
- check the orientation you want.
- take the number corresponding (0 for north, 1 for east, 2 for south, 3 for west) and add it to your previous result.

Sounds complicated, I know. Let's make an example: you want to test for a repeater facing south on 1 tick, you do: 0 * 4 + 2 = 2
Then, you just replace dataValue with 8 and you're done.

If you need any help with my explaination, just PM me
Planet Minecraft

Website

© 2010 - 2024
www.planetminecraft.com

Welcome