Minecraft Pi_ Introduction to Python

Python uses libraries of commands to make it possible to interact with a variety of programs. We will use a line of code to import the Minecraft library so Python knows how to respond to our commands. Type the following line in the Python window:

from mcpi.minecraft import Minecraft Next, we want to add two lines of code: mc = Minecraft.create() mc.postToChat("Hello  world")

In order to test our code, we need to save our file each time we want to run it using Ctrl + S (name the file minecraft) and then run the code by pressing F5.

What happened when you ran your code?

Return to top