14-18 yrs old
Learn how to customize Minecraft world with amazing structures and new gaming experiences, developing Python programming skills.
March 2, 2018
Raspberry Pi Digital Making Curriculum
Elements from the following strands of the Raspberry Pi Digital Making Curriculum
Use basic programming constructs to create simple programs
Use basic programming constructs to create simple programs
Minecraft: Pi Edition is a version of Minecraft that’s designed to work on the Raspberry Pi - a cheap credit-card sized computer designed to help you to learn programming. The Pi edition has the added feature that you can program it using either Python or Java and is intended as an educational tool for novice programmers.
How to write commands and scripts in Python code to build things in the game automatically.
How to use the Python programming environment IDLE to connect to Minecraft Pi
How to use variables to store IDs for different types of blocks
Getting Started with Minecraft Pi
Minecraft is a popular sandbox open-world building game. A free version of Minecraft is available for the Raspberry Pi; it also comes with a programming interface. This means you students can write commands and scripts in Python code to build things in the game automatically and it’s a great way to learn Python!
Open Python 3 from the application menu and move the windows so they’re side-by-side.
You can either type commands directly into the Python window or create a file so you can save your code and run it again another time.
If you want create a file, go to File > New window and File > Save. You’ll probably want to save this in your home folder or a new project folder.
Start by importing the Minecraft library, creating a connection to the game and testing it by posting the message “Hello world” to the screen:
from mcpi.minecraft import Minecraft
mc = Minecraft.create()
If you’re entering commands directly into the Python window, just hit Enter after each line. If it’s a file, save with Ctrl + S and run with F5. When your code runs, you should see your message on screen in the game.
Find your location
To find your location, type:
pos = mc.player.getPos()
pos now contains your location; access each part of the set of coordinates with pos.x, pos.y and pos.z.
Alternatively, a nice way to get the coordinates into separate variables is to use Python’s unpacking technique:
x, y, z = mc.player.getPos()
Now x, y, and z contain each part of your position coordinates. x and z are the walking directions (forward/back and left/right) and y is up/down.
Note that getPos() returns the location of the player at the time, and if you move position you have to call the function again or use the stored location.
As well as finding out your current location you can specify a particular location to teleport to.
mc.player.setPos(x, y+100, z)
This will transport your player to 100 spaces in the air. This will mean you’ll teleport to the middle of the sky and fall straight back down to where you started.
Try teleporting to somewhere else!
You can place a single block at a given set of coordinates with mc.setBlock():
mc.setBlock(x+1, y, z, 1)
Now a stone block should appear beside where you’re standing. If it’s not immediately in front of you it may be beside or behind you. Return to the Minecraft window and use the mouse to spin around on the spot until you see a grey block directly in front of you.
The arguments passed to set block are x, y, z and id. The (x, y, z) refers to the position in the world (we specified one block away from where the player is standing with x + 1) and the id refers to the type of block we’d like to place. 1 is stone.
Other blocks you can try:
Now with the block in sight, try changing it to something else:
mc.setBlock(x+1, y, z, 2)
In this resource students will explore the virtual world of Minecraft Pi, the special edition of Minecraft made for Raspberry Pi.
They will learn how to control the player, manually build with blocks and use the Python interface to manipulate the world around you.
They will employ the Python programming environment IDLE to connect to Minecraft Pi.
They will employ variables to store IDs for different types of blocks
Science in Minecraft
How does science in MC and the real world differ?
Intro to CS with MakeCode
Introduction to CS with MakeCode for Minecraft
Dynamic Ecosystems Project
Mastering ecosystems concepts, ideas, principles
Build a Farm with Code & Math
Build a farm with code by solving Math clues.
Explore chemical reactions and temperature.
Farming Industrial Revolution
Experience life pre & post industrial farming rev
Moon Craft 2.0 Lunar Learning
Students learn about the Moon & NASA's LOP-G
Minecraft Meets Art
Minecraftia Masters 2020
Design a world-class golf course then play!
Depicting best sustainable farming method
Adventure Theme Park
Adventure Theme Park with Roller Coaster
Angler Arithmetic – Cool Math!
Fishing Competition Teaches Math in Engaging Way
Electricity – Demand Load Calc
Design & estimate electrical load calculation.
Types of Chemical Reactions
Demonstration of different types of reactions
Art and Magic Museum
Magic art museum where paintings come alive.
Aquanaut Aquarius – Habitat II
A Skype Field Trip Companion Experience (Or Not)
Part of Whole Art (fraction)
Create pic using fractional parts
Using code and note blocks to create rhythm loops
Visit Quijote´s World to learn spanish litherature
History – Battle of Vimy Ridge
Choose from several adventures on real Vimy Ridge
Gender Equality Community
Gender Equality as the foundation of human rights.
Minecraft en Puerto Rico
Desarrollo y construcción de entornos de tu país.
THE SAVIOURS OF TAJ MAHAL
Save 7th Wonder of the World from pollution #SDG13
HourOfCode u znaku Minecrafta
Sat kodiranja u Gimnaziji Vukovar
Chemistry lessons in Spanish
Learn about Chemistry in Minecraft in Spanish
如果你想了解在中国发行的Minecraft我的世界教育版，请访问我们的中国官方网站. 你也可以留在 education.minecraft.net了解世界其他地方如何使用Minecraft: Education Edition.