Minecraft Pi_ Introduction to Python

Minecraft Pi had some built-in constants (variables that can't change) for blocks but we need to import them so press Enter on the third line and add the following on the code:

from mcpi import block

Now, we can call a block using the constant instead of a number. The constant is longer but a bit easier to remember. For instance, stone is block.STONE.id. You can substitute the name of any block type in ALL CAPS with _ for spaces. There is a list of the names of all of the block types on this page a little ways down.

Remembering numbers or typing out block IDs can be frustrating. Can you create a variable that stands in for either the number or block ID? Once you think you have it, make a blank line after our import and add your variable. Try using the variable as an argument instead of the number or block ID to see if you created it correctly.

Return to top