Program a Minecraft Mod


ANDREW POGGIONE

Andrew is a high honors graduate of the elite Philips Exeter Academy. During his pre-college years, Andrew was a Future Cities winner and Minecraft guru. In past summers, Andrew has instructed engineering and team building to middle schoolers, as well as 3D Printing, Programming, and Minecraft at Spark Skill. He is an economics major at the Occidental University.

The video game Minecraft features a vast block style world where users can collect resources, craft tools, and collaborate with friends. Since its creation in 2009, Minecraft has become a global phenomenon, selling more than 100 million copies and becoming the third best-selling video game of all time. Enthusiastic coders have created modifications (known in the Minecraft community as “mods”) to expand the features of the game. Mods introduce new resources, tools, and game physics to the regular “vanilla” Minecraft. Originally, mod creation was reserved for experienced coders, but new software now allows novice coders to create Minecraft mods too!

At Spark Skill summer camp, we use the website Tynker to create Minecraft mods. Tynker utilizes visual block style coding similar to the free programming language Scratch developed at MIT. Learning to code can be overwhelming. By using a block style coding platform, beginning coders don’t have to worry about memorizing syntax. All the blocks necessary to build an excellent mod are all readily available, and coders can focus on learning the logic -- not the syntax -- of programming.

Today I’ll show you just how easy creating a cool Minecraft mod can be. In the spirit of the winter season, I’ll show you how to make your Minecraft characters masters of snow and ice. This mod will create an explosion of snow around you whenever your Minecraft character takes off in flight. Additionally, you will be able to use snowballs to create igloos underneath your character.

Before you get started, you’ll need to set up a Tynker account with some parental assistance. Tynker accounts come with unlimited coding time, a few free tutorials, and one hour of free time on your own personal Minecraft server. A subscription will give you unlimited access to coding, tutorials, and server time. If you don’t already have a Minecraft account, you will need to establish that as well. You can do this by visiting Minecraft's Website. This account also gives you access to standard, vanilla Minecraft.

After completing the account setup process, you’ll want to log into your new account. To get started from the homepage, click on the Minecraft tab on the left. Then click on the My Projects menu item on the top. Select Create and then click on the Create Mod square. And finally select the blank template. All of these steps are highlighted below with red arrows.

Select Minecraft from Tynker's Dashboard Select My Projects Choose to Create a New Projec t Click Create Mod

After completing these steps, you should see a blank workspace. First, familiarize yourself with the space. On the left there are several control coding blocks. Every code block in Tynker falls under one of twelve categories. Feel free to check out some of the other categories to see what kind of coding blocks are available. Blocks can be searched by category or by the search bar near the top. Also note at the bottom right corner there is a zoom in or zoom out button. This can be useful for focusing your workspace or for getting a good look at all your code from afar.

Tynker Minecraft Coding Initial Project View

Now that you have a basic understanding of the workspace, let’s start working on a mod. The first goal of this mod is to create a snowy explosion and add fifty snowballs to your character’s inventory when you are about to fly. The next goal is to make igloos on the ground when your character’s snowballs hit the ground, transforming the landscape into a winter wonderland.

Let’s start with your first objective. You want a specific action to happen when your character enters flight mode. Therefore, start with the control block “when player enters flight mode at location.” You will have to scroll down a little bit under the control category. Every string of code in Tynker begins with a control block, because every string of code needs context. Control blocks tell the computer under which situations your code should be enacted.

Now that you have your first control block, you want to outline what should happen when a player enters flight mode on my server. First, you want an explosion of snow around the player before taking flight. Drag out the “spawn 0 particles of type flame at add location block here” code from the world category. You need to make some changes to this code block to make it fit into your mod’s theme. Change the 0 to 50, flame to snow_shovel, and drag out the purple location block from your control block, releasing it in “add location block here.”

Next, drag out the “give 1 of iron_sword to add_player_block_here” block (which can be found under the player category or via the search bar). Place this block underneath your control block: the two blocks will now automatically be linked together. You now need to make some modifications to your new block as you are not looking to give your character an iron sword. Instead, replace the one iron sword with 50 snowballs. You also need to specify the player you want to give the 50 snowballs to. In your workspace, the word "player" in the block, “when player enters flight mode at location,” is a purple block of its own. You can drag that player block onto the “add player_block_here,” completing your second block. Now if your player flies into the air, 50 snowballs will automatically appear in the player’s inventory. Your first string of code is complete and should like this:

Simple Code Block

Lastly, you want to code in an action for when your snowball hits the ground. Every snowball should create an igloo on the ground. Again, begin with a control block. This time you will be using the block “when projectile from entity lands at location.” However, you only want an igloo to be produced if the projectile thrown is a snowball.

You will need to use an if-then statement: if the projectile is a snowball, then create an igloo. If-then statements are a type of conditional, a key tool that appears in all programming languages. Block style coding introduces many of the essential computer programming concepts so that when you eventually move on to text-based coding, the transition is seamless.

In Tynker you can find if-then statements under the flow category. They appear as, “if false then.” Drag that code block out. Next find the block “add entity block here is snowball?” in the player category. You don’t need to change the snowball, but you now need to drag the purple projectile block into the “add entity block here” space. Lastly, drag your block that now reads “projectile is snowball?” into the false space after the if. Your code should look like the picture below.

If-Then Statement Code

Now you need to create your igloo. You will be using my favorite feature of Tynker: the drone tool. The drone tool can be used to create magnificent structures in Minecraft. Structures that would normally take a lot of time to construct in the standard version of the game can be created instantly. Find the drone block category. First, use the “move drone to add location here” block. You want the igloo to be created where the snowball lands, so drag the purple location block into the “add location here” section. Drag that into your if-then statement.

Next Step of If-Then Statement

Now that the drone tool is in place, you need to instruct it to build an igloo. You’ll start by making the shell of an igloo. Find the code block, “build filled top hemisphere at drone using grass with radius 6.” Drag this block under the “move drone to location.” You need to make some adjustments to this block. Change the block so that it reads “build hollow top hemisphere at drone using packed_ice with radius 7.” The drone tool will now build the top half of a sphere made of packed/frosted ice with radius 7. Finally, add a door to the igloo. The drone tool builds the igloo shell from the front left corner. You need to move the drone over six blocks to the right so that it is in place to build your door. Use the block “move drone up by 1 block.” Edit the block so that it reads “move drone right by 6 blocks.” Finally drag out the block build filled box at drone using grass with width 1, height 1, and depth 1. You then want to modify the block so that it reads “build filled box at drone using air with width 3, height 2, and depth 1.” Your code should look like the screenshot below.

Final Minecraft Modding Code

Congratulations on coding your first mod! To try your mod out you will need to save and deploy your mod. You also will need to set up your own Minecraft server with Tynker. Again, you will need parental assistance and your Minecraft account username and password.

Tynker Minecraft Server Login

After setting up your server, you can test out your new mod. You’ll have to first open Minecraft. When you enter the game, select the multiplayer button. This will take you to your server list. Select add server. 

Tynker Minecraft Server Login

You will arrive at a new screen. Enter your Minecraft server name and the server address: mc.tynker.com. After completing this step, select done.

Tynker Minecraft Server Login

After a few seconds, your Minecraft server should appear. Click on your server, and hit the button, "join server."

Join the Minecraft Server

You will then enter the Tynker arena. From there, you can hit the backslash key and type join, or you can run into the purple portal at the end of the walkway.

Welcome to the Server

Walk Towards the Server Portal

Enter the Server Portal

You’ll then be taken to your personal minecraft server. Double tap the spacebar to enter flight mode. There should be a small explosion of snow around you. To see it more clearly, hit the F5 key if you’re on a PC or the fn and F5 keys at the same time if you’re using a mac.

Ready Your Snowballs to Test the Mod

Hold the spacebar to fly higher; hold the shift button to sink in the air. You should notice that when you double tap the spacebar, 50 snowballs appear in your inventory. Now try throwing your snowballs by aiming and right clicking. Wherever the snowball lands, an igloo should appear.

Zoomed-Out View

An Igloo Will Appear Upon Success

Your first mod is now complete and tested! Try tweaking this mod, doing a Tynker tutorial, creating your own mod, or enrolling in Spark Skill's Code With Minecraft summer technology camp to learn more. This tutorial only scratches the surface of the coding with Tynker. In more advanced lessons, students can learn all about more advanced computer programming concepts (i.e. repeat loops, functions, and variables). Minecraft Modding is an excellent way to introduce students to coding. Working in the Minecraft framework enables students to quickly produce tangible and exciting results with their code.