« Back to Main Page

First Session - Minecraft Mods w/ Python

From Bold Idea Knowledgebase


Setup

  • Set up laptops with student survey open: https://goo.gl/forms/k4C9sRJ6V6tFHDep2
  • Prepare materials needed for the unplugged activity
  • Have a someone take mentor and student attendance as people arrive.

Materials

  • Graph paper algorithm sheets (1 per student)
  • Graph paper design sheets (1 per student)
  • Colored pencils or crayons

Welcome [30 min]

Volunteer Focus

  • Create a welcoming and inclusive environment.
  • Build a positive relationship with ideaSpark students.

As students arrive

All mentors should be greeting students and introducing themselves. Make new students feel comfortable and welcome. Here are some good conversation starters:

  • Did you do anything fun or interesting over the break?
  • Have you played minecraft before? What do you like best about it?
  • Have you done any coding before?

Warm-up - Graph Paper Algorithms

Do the Graph Paper Algorithms unplugged activity. However, instead of having students make their own designs, have them use one of the pre-made 8x8 Minecraft character designs in the handouts folder.

Pair Programming [5-10 minutes]

Pair Programming is a vital part of the Bold Idea experience. You might find some students are initially resistant to this "working with a partner" model, however, it's important that we continue to re-enforce teamwork skills throughout the program.

Lead Mentor:

  1. Ask if any students in the room know what pair programming is. If there are any veteran students in the room, allow them to explain their understanding of it.
  2. Explain that pair programming is when two people share one computer to write a program together. Even professionals do it!
  3. Pair Programming has two roles:
    1. the driver who controls the mouse and keyboard and
    2. the navigator who follows the reference book to make suggestions, point out errors, and ask questions.
  4. Watch the Code.org Pair Programming video together as a team. If no projector or TV is available, explain the rules of pair programming to the students.
  5. Then, ask the students to share what each role does and some dos and don'ts. They'll get practice applying pair programming for the rest of the semester.

Go ahead and pair up students now, and make sure each mentor is working with a pair of students.

Minecraft 101 [10-15 min]

Have mentors spend time with students to get them familiar with how to play Minecraft. If students already know how to play, they can just play for fun.

For this, we'll just enter single-player mode.

  1. Open the Minecraft game on the desktop
  2. Click Single Player, then "New World"

Refer to the "How to Play Minecraft" reference sheet in the student folders.

Students should know how to:

  • How to control the player using WASD and Mouse
  • Mine a block using left-click
  • Place a block using right-click
  • Look at their inventory (E) and place items in their "hotbar"
  • Switch between items in the hotbar (1-9 or mouse wheel)
  • Watch life & food bars
  • Craft a basic item

Lead Mentor : Watch the time and make sure to get everyone's attention when you're ready to move on to the next section.

What is Python? [10-15 min]

Have students close their Minecraft games (this might be hard, but tell them we'll get back to it).

Lead Mentor:

Can anyone here tell me what an algorithm is?

You just created an algorithm to instruct a computer (or a person acting like one) to draw Minecraft characters.

Can anyone tell me what language they used to instruct the computer? (someone could say "symbols" or "arrows", etc)

Those symbols in your algorithm were the language you used to program the computer. Real computers can understand many different types of programming languages.

Python is one of those languages, however it is much more powerful than just a small set of symbols. You can write python code using text in a file. We call that a "script".

We can tell the computer to run that script. The computer then reads your file one line at a time and executes your code until it gets to the last line, and then it stops.

Let's give it a try!

Tell students to find the page in their folders called "Python Scripts and the Python Shell" . Have mentors work with students to complete the activities on both sides:

  • Creating a new script using IDLE
  • Writing code directly in the shell
  • Making mistakes

Ask students to raise their hand when they see a red error message in the shell.

Python console error.png

Lead Mentor:

Take a look at the last red line of the error message. Does anyone want to tell me what error they got?

Does anyone want to venture a guess as to what that error means, and how we should fix it?

The shell is also very useful for telling us when something goes wrong. Sometimes, you might run your code and things don't quite work as expected. When this happens, you should check your shell to see if there are any errors.

That last line of red that starts with "NameError" is really the most important information. The last line is the first thing you should look at when reading error messages.

Sometimes these errors can be hard to understand, even for us professional coders. But errors are your friend -- don't be afraid of them!

Does anyone know what you might do when you come across an error you don't know how to solve? Do you give up? Or is there something else you can try?

When we can't figure something out, we usually go find the answer ourselves.

Have students look in their folders for a page called "Python Scripts and the Shell". That has some useful tips on how to interpret error messages. There's another page called "Common Errors" that might help them later on.

How to write mods [20-30 min]

Briefly explain how servers work, and how to run a local minecraft server.

Lead Mentor :

To write mods in minecraft, we use python scripts. In order to do this, the python script has to connect to something called a "server" in order to run the commands.

Minecraft servers are basically minecraft worlds that any number of players can join. The python script has to "join" the server in order to run. The python script sends special commands to the server that can:

  • Change a player's position
  • Instantly create any block at any position
  • Trigger an algorithm using sword hits, arrow hits, or chat messages

Anything you do on the server world is permanent, until the world is re-generated. So if you build something, you can come back another day and your building will still be there.

Each of your computers has a server on it, but you have to start your server before you can do any modding.

Have students work with mentors to follow the "Running a Minecraft Script" page in their folders. This will show how to:

  • Start your minecraft server
  • Join your minecraft server from the game
  • Write a script that connects the server and posts a chat message

Lead Mentor : Once everyone has posted their chat message, move on to the next section.

Escape the Pit! [15-30 min]

Lead mentor:

During this course, you will create your own modded Minecraft Server that other players can join. But, before you can make a server mod, you need to level up your python skills! We have 9 missions to help you learn all the Python tricks you need to know in order to make an awesome server mod.

Have students turn to the first mission in their folders: "Escape the Pit". The lead mentor will begin by introduce the 3D Coordinate system, after which individual mentors will take over to help students through the mission. Lead Mentor:

We use x, y, and z to describe any position in the world. These are called axes -- we have the X axis , the Y axis , and the Z axis . In minecraft, the center of the world is where x, y, and z are all 0.

Take a look at the diagram:

  • If we want to go east , we increase x . If we want to go west , we decrease x .
  • If we want to go south , which do we change? Should we increase or decrease it?
  • If we want to go straight up , which do we change? Should we increase or decrease it?

If we want to describe a position that is 20 meters east of the center, we would say the x, y and z coordinates are 20, 0, 0

  • How would you describe a position that is 20 meters east and 50 meters south from the world center?
  • How would you describe a position that is 30 meters west and 10 meters straight up?

Tell students and mentors to begin the first mission.