Learn to Program with Minecraft

Learn to Program with Minecraft

Transform Your World with the Power of Python
by Craig Richardson
December 2015, 336 pp.
Full Color

Learn to Program With Minecraft is 297 pages brimming with potential. It’s an excellent guide for Minecraft players wanting to expand their capabilities in the game and with programming. Highly recommended."

Learn to Program with Minecraft offers an incredibly user-friendly, intuitive, and innovative approach for learning the Python programming language.”
EE Times

You’ve bested creepers, traveled deep into caves, and maybe even gone to The End and back—but have you ever transformed a sword into a magic wand? Built a palace in the blink of an eye? Designed your own color-changing disco dance floor?

In Learn to Program with Minecraft®, you’ll do all this and more with the power of Python, a free language used by millions of professional and first-time programmers!

Begin with some short, simple Python lessons and then use your new skills to modify Minecraft to produce instant and totally awesome results. Learn how to customize Minecraft to make mini-games, duplicate entire buildings, and turn boring blocks into gold.

You’ll also write programs that:

  • Take you on an automated teleportation tour around your Minecraft world
  • Build massive monuments, pyramids, forests, and more in a snap!
  • Make secret passageways that open when you activate a hidden switch
  • Create a spooky ghost town that vanishes and reappears elsewhere
  • Show exactly where to dig for rare blocks
  • Cast a spell so that a cascade of flowers (or dynamite if you’re daring!) follows your every move
  • Make mischief with dastardly lava traps and watery curses that cause huge floods

Whether you’re a Minecraft megafan or a newbie, you’ll see Minecraft in a whole new light while learning the basics of programming. Sure, you could spend all day mining for precious resources or building your mansion by hand, but with the power of Python, those days are over!

Requires: Minecraft Java Edition; Windows 7 or later; OS X 10.10 or later; or a Raspberry Pi.
Click here for details about system requirements.

Uses Python 3

Author Bio 

Craig Richardson is a software developer and Python educator. He has worked for the Raspberry Pi Foundation, taught high school computing classes, and led many workshops on Python programming with Minecraft.

Table of contents 

Chapter 1: Setting Up for Your Adventure
Chapter 2: Teleporting with Variables
Chapter 3: Building Quickly and Traveling Far with Math
Chapter 4: Chatting with Strings
Chapter 5: Figuring Out What's True and False with Booleans
Chapter 6: Making Mini-Games with if Statements
Chapter 7: Dance Parties and Flower Parades with while Loops
Chapter 8: Functions Give You Superpowers
Chapter 9: Hitting Things with Lists and Dictionaries
Chapter 10: Minecraft Magic with for Loops
Chapter 11: Saving and Loading Buildings with Files and Modules
Chapter 12: Getting Classy with Object-Oriented Programming
Block ID Cheat Sheet

View the detailed Table of Contents (PDF)
View the Index (PDF)


Watch author Craig Richardson on This Week in Tech with Leo Laporte!

"With this book, programming can be accomplished by anyone who is able to use a computer."
Gaming INTEL

"As educators, you know that kids love playing Minecraft. This book makes it easy for you and your middle and high school students to learn how to program in Python through very engaging Minecraft projects."

"Of all the diverse No Starch Press programming guides, this one may turn out to be the most effective, as a teaching tool, for that special case where a person is already interested in Minecraft and wants to learn Python."
Science Blogs

"In this beginner friendly book...you will learn how to do cool things in Minecraft using the Python programming language. No prior programming experience is needed. Author Craig Richardson shows you how to install Python (it's free) on your Mac, PC, or Raspberry Pi. The book has step-by-step instructions to show you how to teleport your character, create palaces and other structures with a few lines of code, stack blocks, duplicate villages and geography, and a lot more."
Boing Boing

"Shows how to use the Python programming environment to take a teleportation trip around the game’s landscape, create forests and make secret passageways...the class might think they’re playing a popular game, but beneath the surface, [they] will be learning about object oriented programming, Boolean loops, 'if' statements and more."
Scholastic's Tech Tools blog

“Readers who work their way through the book will develop a strong working knowledge of Python basics, which can be employed to continue making modifications to Minecraft or be easily transferred to other applications. Not only would this book be great for motivated individuals, but teachers, tech coaches, librarians, and club leaders could use it as a basis for conducting their own classes and workshops.”
School Library Connection

"I really love books like this, because they feed upon the interests and enthusiasm which are already present...and builds upon it."
Meltwater's Raspberry Pi Hardware

"For a kid who likes Minecraft, the fact that everything is applied to it makes it a compelling way to learn...does a very good job breaking down the material, builds on concepts well, and offers plenty of opportunity for critical thinking through 'missions.'"
Children's Technology Review newsletter

"A fantastic book."
Import Python

"This book will be fantastic in helping students engage with the Python coding language."
The School Librarian

"It seems like the best target audience would be a high school or undergraduate class in which the students are quite likely to be familiar with Minecraft already and you wish to leverage that knowledge to teach them programming. In that case, this book is clearly a good fit."
Computing Reviews

"Applies software development to Minecraft worlds so learners can quickly build structures, transport themselves around the environment and create mini-games...The book is perfect for anyone who primarily wants to learn how to program and enjoys Minecraft."

"No Starch Press has great programming books for kids and teens, and Learn to Program with Minecraft is a solid addition to middle school and YA collections."
Mom Read It

GeekMom featured Learn to Program with Minecraft in their Gift Guide: For The Minecraft Fan!

Extra Stuff 

Check out the Learn to Program with Minecraft video!


In Chapter 7, in the section "Nested if Statements and while Loops," the line marked (1) in the second code listing should read: if userAnswer == "yes":

In Chapter 11, Listing 11-3, the line marked (2) should read: block = mc.getBlockWithData(x1 + column, y1 + row, z1 + depth).