Editing
MinecraftCommands
(section)
Jump to navigation
Jump to search
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
=== testforblock === {{/infobox |testforblock |op |1.7.2|13w37a }} Tests whether a certain block is in a specific location. ;Syntax : <code>testforblock <''x''> <''y''> <''z''> <''TileName''> [''dataValue''] [''dataTag'']</code> ;Arguments : ''x y z'' :: Specifies the position of the block to test. ''x'' and ''z'' must be between [[World boundary|-30,000,000 and 30,000,000]] (inclusive, without the commas) and ''y'' must be between 0 and 255 (inclusive). May use [[#Tilde notation|tilde notation]] to specify a position relative to the command's execution. : ''TileName'' :: Specifies the block to test for. Must be a valid [[Data values#Block IDs|block id]] (for example, <code>minecraft:stone</code>). : ''dataValue'' (optional) :: Specifies the [[Data values#Block IDs|block data]] to test for. ''dataValue'' must be between -1 and 15 (inclusive). If not specified, or if <code>-1</code>, ''dataValue'' matches any block data value. : ''dataTag'' (optional) :: Specifies the block [[#Data tags|data tags]] to test for. Must be a compound [[NBT tag]] (for example, <code>{CustomName:Fred}</code>). If not specified, ''dataTag'' matches any block data tag. ;Result : Fails if the arguments are not specified correctly, if the block at the specified position does not match the specified block id or data, or if the specified data tag has different values than are defined in the block's data tag (''dataTag'' does not need to match the block's entire data tag, and data tags in the argument which are undefined in the block will ''not'' cause the command to fail). : On success, returns a success count of 1. ;Examples : To test if the block at (0,64,0) is any type of [[wool]]: :: <code>testforblock 0 64 0 minecraft:wool</code> :: <code>testforblock 0 64 0 minecraft:wool -1</code> : To test if the block at (0,64,0) is orange wool: :: <code>testforblock 0 64 0 minecraft:wool 1</code> : To test if the block below is a [[jukebox]] with the "mall" [[record]] inside: :: <code>testforblock ~ ~-1 ~ minecraft:jukebox -1 {Record:2261}</code> <!-- please retain double newline above for section differentiation -->
Summary:
Please note that all contributions to Hegemon Wiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Hegemon Wiki:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Navigation menu
Personal tools
Not logged in
Talk
Contributions
Log in
Namespaces
Page
Discussion
English
Views
Read
Edit
Edit source
View history
More
Search
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Tools
What links here
Related changes
Special pages
Page information