In [18]:
import sys
#sys.path.append('/Users/esumitra/workspaces/mc/mcpipy')
In [20]:
# Start typing below
# once you are done typing, press (Ctrl+Enter) to run the code
import mcpi.minecraft as minecraft
import time
mc = minecraft.Minecraft.create()
mc.postToChat("Hello kids")
time.sleep(5)
If everthing went well, you saw a chat message in Minecraft. You have now written your first program for Minecraft. Jump up and down three times yelling
I rock!
Now let's see what the lines in your program do.
import mcpi.minecraft as minecraft
import time
There are many other libraries we can use in minecraft, some interesting ones being mcpi.blocks which has programs to build with blocks and mcpi.entity which has a list of things like bats, witherskull that you can use in your programs.
A library has many functions to do things. There is a function to display a message, a function to play music files and so on.
mc = minecraft.Minecraft.create()
The minecraft object has many functions. When a function is tied to an object is is also called a method. We need the postToChat to display a message, so we type mc.postToChat(...)
.
Now try to complete the tasks below in this adventure.
Good luck!
In [ ]:
# Program for Adventure 1 - Task 1
In [22]:
# Program for Adventure 1 - Task 2