Programming with Minecraft

Ben Davies

Ben Davies is project manager for English at language learning app Babbel, developing innovative and effective English language learning courses for the Babbel app. Previously, Ben taught languages in Secondary schools in the UK, and English language courses to adults in Spain. The Babbel language learning app spans 14 different languages, with bite-sized lessons designed by language experts. 73% of surveyed customers feel that they’d be able to hold a conversation within five hours of using the app.

Follow @babbel

Website: www.babbel.com Email This email address is being protected from spambots. You need JavaScript enabled to view it.

Children love programming. A simple statement, but one that my experience as a Primary school teacher and a Computing subject leader has provided me with a glut of evidence to support. Visual programming applications are commonplace in the vast majority of Primary schools, but what about those pupils who are eager to take the step and cross the divide into the world of text based coding. This can be a huge step and, due to the pedantic syntax requirements of text-based code, can risk disengaging pupils. However, by using a Raspberry Pi and Minecraft, we can offer them an engaging introduction to text programming.

Minecraft Pi is a stripped down version of the popular game, similar to the pocket-editions that run on various tablets. It comes installed on the popular Raspbian operating system and can be connected to Python 2 allowing children to write code that produces actions in the game. This allows children, after writing a small amount of code, to produce something with striking visual impact (certainly more than Hello World).

Essentials

Before children start hacking, they must ensure they have done the following: opened a Minecraft world and started playing the game (tab key will release the cursor from Minecraft Pi); opened Python 2; opened a new file from the Python shell. Once they have written their program, children need to save it (ALT+S) before running (F5).

Sequencing

The first activity addresses the need for programs to be sequenced correctly in order for them to achieve specific goals and involves children writing knock-knock jokes with appropriate delays between the lines of text. The code displayed, which is case sensitive, connects Python to Minecraft, imports the required modules for the program into Python and then posts each string (line of printable text) to the message chat area. By using the time.sleep() command children can create a delay between each message to allow sufficient time to read it.

Precise Language

Moving on, children gain an appreciation of the requirement for precise and unambiguous instructions and the use of predetermined vocabulary and syntax. Children learn how to place a block of red wool below the character’s feet by writing the following code.

First children can modify the colour of the wool by changing the number after .id (1-15).  Then by using a list of block ids, they can experiment with changing the block. Once they have mastered this, they attempt to create a large cuboid of blocks by modifying the code further. As well as working out the parameters of the shape, they have to pay attention to the language as they are now instructing to setBlocks and not setBlock. I find it very useful to get children to check each other’s code and debug errors together. My class are used to my response to their statement of “it doesn't work” (regardless of what type of programming they are doing), of “it is doing exactly what you have told it to do.

Repetition

Introducing repeats can be a big jump, but by using a forever loop, something most primary-aged children will be comfortable with from Scratch, we can then discuss with them the need for programs to keep running if  the instructions are to be applied constantly during the game. The example below returns the player's current position (using x, y, z, coordinates) and then uses that position to change the block below the player's feet. By placing this code within a forever loop, this will happen continuously allowing children to create trails behind their character. Children can tinker with the code to change the position of the block relative to the character, use the setBlocks command to create columns behind them, change the delay before the loop repeats or change the block being placed (TNT.id, 1 - a version of TNT that can be activated by a sword - is a favourite of my class).

Selection

The concept of selection can be introduced by creating an event that will happen if the player stands on a certain block. In the example below, the program checks which block is beneath Steve's feet and, if that block is sand, then turn it into a diamond block. Again the children can tinker with the program to change the conditional statement and the subsequent event.

Programming with Minecraft Pi is not about learning how to code with Python, it is an engaging way of starting the transition from graphical programming to text-based programming. It requires children to use pre-determined vocabulary and syntax and to identify and correct errors in their code. However the use of the minecraft is a huge motivating factor and one that makes them want to check the accuracy of their work, test and explore their ideas and collaborate with others, skills that can be utilised in all areas for the curriculum.

Have you used such tactics to teach programming? Share your experiences below!

Register for free to continue reading
Registration is a free and easy way to support us.
When you register, you'll join a grassroots community where you can:
• Enjoy unlimited access to articles
• Get recommendations tailored to your interests
• Attend virtual events with our leading contributors
Register Now
Login

Latest stories

  • How to handle stress while teaching in a foreign country
    How to handle stress while teaching in a foreign country

    Teaching English in a foreign country is likely to be one of the most demanding experiences you'll ever have. It entails relocating to a new country, relocating to a new home, and beginning a new career, all of which are stressful in and of themselves, but now you're doing it all at once. And you'll have to converse in a strange language you may not understand.

  • Is Learning Fun for You, Teacher?
    Is Learning Fun for You, Teacher?

    Over the weekend, my family of five went to an Orlando theme park, and I decided we should really enjoy ourselves by purchasing an Unlimited Quick Queue pass. It was so worth the money! We rode every ride in the park at least twice, but one ride required us to ride down a rapidly flowing river, which quenched us with water. It was incredible that my two-year-old was laughing as well. We rode the Infinity Falls ride four times in one day—BEST DAY EVER for FAMILY FUN in the Sun! The entire experience was epic, full of energizing emotions and, most importantly, lots of smiles. What made this ride so cool was that the whole family could experience it together, the motions were on point, and the water was the icing on the cake. It had been a while since I had that type of fun, and I will never forget it.

  • Free recycling-themed resources for KS1 and KS2
    Free recycling-themed resources for KS1 and KS2

    The Action Pack is back for the start of the brand new school year, just in time for Recycle Week 2021 on 20 - 26 September, to empower pupils to make the world a better and more sustainable place. The free recycling-themed resources are designed for KS1 and KS2 and cover the topics of Art, English, PSHE, Science and Maths and have been created to easily fit into day-to-day lesson planning.

  • Inspire your pupils with Emma Raducanu
    Inspire your pupils with Emma Raducanu

    Following the exceptional performance from British breakthrough star Emma Raducanu, who captured her first Grand Slam at the US Open recently, Emmamania is already inspiring pupils aged 4 - 11 to get more involved in tennis - and LTA Youth, the flagship
    programme from The LTA, the governing body of tennis in Britain, has teachers across the country covered.

  • 5 ways to boost your school's eSafety
    5 ways to boost your school's eSafety

    eSafety is a term that constantly comes up in school communities, and with good reason. Students across the world are engaging with technology in ways that have never been seen before. This article addresses 5 beginning tips to help you boost your school’s eSafety. 

  • Tackling inequality in EdTech
    Tackling inequality in EdTech

    We have all been devastated by this pandemic that has swept the world in a matter of weeks. Schools have rapidly had to change the way they operate and be available for key workers' children. The inequalities that have long existed in communities and schools are now being amplified by the virus.

  • EdTech review & The Curriculum Lab
    EdTech review & The Curriculum Lab

    The world is catching up with a truth that we’ve championed at Learning Ladders for the last 5 years - that children’s learning outcomes are greatly improved by teachers, parents and learners working in partnership. 

  • Reducing primary to secondary transition stress
    Reducing primary to secondary transition stress

    As school leaders grapple with the near impossible mission to start bringing more students into schools from 1st June, there are hundreds of thousands of Year 6 pupils thinking anxiously about their move to secondary school.

  • Generation Z and online tutoring: natural bedfellows?
    Generation Z and online tutoring: natural bedfellows?

    The K-12 online tutoring market is booming around the world, with recent research estimating it to grow by 12% per year over the next five years, a USD $60bn increase. By breaking down geographic barriers and moving beyond the limits of local teaching expertise, online tutoring platforms are an especially valuable tool for those looking to supplement their studies in the developing world, and students globally are increasingly signing up to online tuition early on in their secondary education schooling. 

  • Employable young people or human robots?
    Employable young people or human robots?

    STEM skills have been a major focus in education for over a decade and more young people are taking science, technology, engineering, and maths subjects at university than ever before, according to statistics published by UCAS. The downside of this is that the UK is now facing a soft skills crisis and the modern world will also require children to develop strong social skills as the workplaces are transformed by technology. 

In order to make our website better for you, we use cookies!

Some firefox users may experience missing content, to fix this, click the shield in the top left and "disable tracking protection"