NAME ID REFERENCE

In this book, you used the name IDs of Minecraft blocks to write your programs. This reference lists the block name IDs so you can reference them when modifying the programs you wrote in this book or when writing new programs on your own. Before looking at the list of IDs, let’s review how to find a block’s name ID.

FINDING A BLOCK’S NAME ID

You need to know a block’s name ID when you’re working with specific types of blocks in your programs. When your turtle is facing a block, as shown in Figure 1, use the turtle.inspect() function to determine what type of block is in front of the turtle.

Figure 1: A turtle facing a grass block before callingturtle.inspect()

You can find all the information associated with a block by calling turtle.inspect() and examining the table value the function returns. The 'name' key in the returned table contains the name ID of the block in front of the turtle. For example, if the turtle is in front of a grass block and you call turtle.inspect() in the Lua shell, the returned table should look like the following:

The grass block’s name ID is "minecraft:grass". In most cases, the name ID will be enough to identify the blocks you want to use in your programs. But in some cases, you might need to also use other keys in the table that turtle.inspect() returns.

DISTINGUISHING BETWEEN BLOCKS THAT SHARE NAME IDS

Some blocks share name IDs, and you can only uniquely identify them from other keys in the table. For example, oak wood planks and spruce wood planks have the same name ID of "minecraft:planks", but their metadata keys have different values. If you call turtle.inspect() when the turtle is in front of oak wood planks, the function returns the following table:

Although the name ID of both blocks is "minecraft:planks", you can use the different metadata values (0 for oak and 1 for spruce) to distinguish between the two block types in your programs. These plank blocks also have a state key containing a table with a variant key that holds more information about the block.

LIST OF BLOCK NAME IDS

Table 1 lists the name IDs for most of the blocks your turtle might interact with. However, Table 1 doesn’t distinguish between blocks that share name IDs. For example, the table lists the name ID of wood planks but doesn’t list the keys that distinguish between oak wood planks and spruce wood planks. In situations where you want to distinguish between blocks that share name IDs, you’ll need to use turtle.inspect() to find out which values in the tables are different for the blocks.