Hacker News new | comments | show | ask | jobs | submit login
Show HN: Teachcraft – Learn Python through Minecraft (teachcraft.net)
212 points by emeth 8 months ago | hide | past | web | favorite | 62 comments

Looks like a great guide to get started with coding with Minecraft. There have been some efforts over the years, but this looks really complete. One obstacle for schools to get started with this however, is buying all the Minecraft licenses.

To this end, I've been toying around a bit with an open source Minecraft clone called Minetest lately [1][2]. It's surprisingly complete, and could also have great uses in (programming) education.

It has a C++ core based on the Irrlicht 3D engine, but many of the game mechanics are implemented in Lua. Modifications like the examples in Teachcraft can also be built in Lua. For example, this [3] is a mod to spread flowers and mushrooms around the map.

The Lua language isn't used much currently in the education environment, which is mostly focused around Scratch, Python and sometimes Javascript. Then again, seeing different languages and noticing their similarities can be educational in itself.

Finally, I've been wondering how hard it would be to port something like Minetest to Emscripten. Irrlicht seems to be compatible already [4]. The non-JIT version of Lua is compatible as well [5]. Obstacles in Minetest that I can identify would be the heavy use of the filesystem, the use of UDP sockets and memory sharing between threads.

Would anyone know more about how hard porting something like this would be?

[1] https://github.com/minetest

[2] http://www.minetest.net

[3] https://github.com/minetest/minetest_game/blob/master/mods/f...

[4] http://irrlicht.sourceforge.net/forum/viewtopic.php?f=2&t=51...

[5] https://github.com/vvanders/wasm_lua

Regarding Emscripten, tried a while back to port "Craft" (lightweight Minecraft in C). Proved it could work but needs some work! :-D


See it working here: http://wb.buz.co/craft/main.html

In the end I ended up making this instead from scratch: http://webblocks.uk/

I might return to it though because my version isn't as functional!


Looks good. Craft is simple enough to easily port to Emscripten. Another port of Craft I found a while ago is NetCraft:


Hey thanks for finding my project! I haven't posted about it much, so its cool to see it being noticed.

For those curious, https://github.com/satoshinm/NetCraft is my first project with WebAssembly/emscripten. It was surprisingly easy to port from Michael Fogleman's Craft (https://github.com/fogleman/Craft/). I briefly tried porting a few other open source block-style engines without success, but Craft being written in plain C with only a few libraries is relatively straightforward.

The initial requirement is to refactor the main loop, from while(1) to emscripten_set_main_loop, a common step for most all emscripten ports. Then update the cmake build file to build with the Emscripten.cmake module, and you're almost done. Emscripten's GLFW3 wrapper covers nearly all of Craft's usage. I posted a fairly minimal pull request showing the basic changes needed: https://github.com/fogleman/Craft/pull/175

After that, the other major change is networking. Craft used a separate thread to listen for network data using blocking sockets and parse message boundaries. But on the web platform with WebSockets, networking is even easier, I use emscripten_set_socket_message_callback() to get called when a new, complete message arrives. Easy as pie.

The harder part is the remaining long tail of minor bugs. At this point, the web port of Craft was functional, but difficult to play, a death by a thousand cuts. Emscripten's GLFW implementation had a few bugs related to cursor focus and keyboard handling, but I developed test cases and submitted fixes (https://github.com/satoshinm/emglfwbugs), which were all merged into emscripten's incoming branch. Until they were merged I built against a patched emscripten.

If anyone wants to get their hands dirty with emscripten, I highly recommend it. You can write the game in C, but the APIs are bridged to JavaScript, and it was fun to extend it and add new API for HTML5 platform features. I implemented the glfw joystick API (https://github.com/kripken/emscripten/pull/5175) on top of the HTML5 Gamepad API, and drop callbacks on top of the HTML5 File Drop API (https://github.com/kripken/emscripten/pull/5206), and started but have yet to finish the glfw monitor API on top of the HTML5 Screen API (which reminds me I ought to finish https://github.com/kripken/emscripten/pull/5205...). This means existing games written using GLFW (a popular multi-platform library for OpenGL, see http://www.glfw.org) with these features should port to the web using emscripten automatically.

After the web port, I continued to enhance https://github.com/satoshinm/NetCraft merging open pull requests from https://github.com/fogleman/Craft and developing new features and fixes. Blocks no longer break instantly, but instead are mined by holding down the mouse button, drawing a growing block break indicator until it breaks, and so on. Up until last month, recently taking a break (to investigate a few other, semi-related projects). However, it is still very playable in the current state.

A live demo can be found at https://satoshinm.github.io/NetCraft/, but the more interesting possibility in my opinion is multiplayer. Craft's original Python server backend can be connected to over the web (/server servername), using a websocket proxy, but I also wrote a Bukkit plugin to bridge a small chunk of the Minecraft world: https://github.com/satoshinm/WebSandboxMC. Last month I ran a server on a VPS (for 1 month), backed by a variant of the open source Glowstone server (https://github.com/GlowstoneMC/Glowstone), with this custom plugin and it peaked at a couple dozen users, running decently smooth. I also experimented with hosting on Heroku, it is less stable and deletes when the dyno shuts down, but works (for a smaller number of users): http://netcraft.herokuapp.com

I don't know if Craft is the answer, but I definitely agree, a web-based block style game is extremely appealing. The next major missing piece I see is extensibility, allowing outside developers to conveniently and cleanly create and distribute new content. Minetest is way further in this regard, I have not looked into it, but at least the filesystem and networking should be feasible to port to emscripten (emscripten has its own virtual filesystems), and shared memory may benefit from the upcoming SharedArrayBuffer technology: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe...

Wow, nice find! :-D

Re Minetest this works with Python if you install the raspberryjammod from GitHub

Also recently managed to get it running with @edu_blocks https://twitter.com/damianmooney/status/881158457671524353

So in general you can do anything with Minetest that you can with the raspberryPi version of minecraft.

Just for info here is the mod for Python and Minetest https://github.com/arpruss/raspberryjammod-minetest/tree/mas...

Sorry to go a bit off-topic, but how did school districts in the 80s justify buying licenses for Oregon Trail and other games of the era? The cost of OT must have been equivalent if not much more (inflation-adjusted) than even the consumer price for Minecraft. Admittedly, school funding has changed since then and it may be especially hard in today's assessment-focused ("teaching to the test", as some might say) paradigm to argue that Minecraft is a qualifying expenditure. But Apple gave away computers to get an inroad in education. Free Minecraft for schools might be a reasonable giveaway for Microsoft.

They did not buy licenses.

That game (and others) was developed by the Minnesota Educational Computing Consortium (MECC), an organization founded by Minnesota legislature. They developed educational software and distributed it on computers across the state of Minnesota.

Later, due to the huge success of the game, they sold the game (bundled with others) across the US.

tl;dr: made possible by government funding

https://medium.com/@stevepepple/why-did-all-children-of-a-ce... https://en.wikipedia.org/wiki/MECC

One big reason: educational games have fallen out of favour within school systems. Many teachers were simply using them as incentives, rather than using them as guided educational tools. Without the guidance, these games had minimal value for learning. Of course, the value of the educational content also varied a lot. Even the good ones depended a lot on rote memorization, which cyclically goes into and out of favour among educators.

In this case, the other issue is that Minecraft is pure entertainment software. It may have educational value, but the origin of the game makes it a hard sell. (Civilization and SimCity faced similar problems.)

An open source project of mine, pycraft, has recently gotten some renewed attention. We learned that we were doing rendering very inefficiently, using "static" when we should have done stream. Our big project right now is making it easier for contributors to contribute.


> We learned that we were doing rendering very inefficiently, using "static" when we should have done stream.

Can you expand on this? Did you use 'static' for VBOs that were only used for one or two frames?

I can not. Graphics aren't my thing. All I can say was that there was quantifiable improvement.

But that's the beauty of open source. If you'd like to investigate it yourself it's the first issue. Getting someone competent involved in the graphics subsystem is another priority ;p

What's more, almost all content in Minetest is implemented as a mod with this Lua API. So, you can really do essentially anything you want. Changing a crafting recipe or what a block drops when mined, is a matter of five minutes. Don't know the scope of Teachcraft, but I doubt it's as big.

And also in my opinion really important, is that Minetest is a real thing. What you're writing isn't some elusive Scratch project that you're gonna find several years later collecting dust on your hard drive, nor is it some Python thingamabob that you've glued onto Minecraft. Your mod is something that you can use as long as you're using Minetest (which itself is something that you will always be able to use, as it's out there for free) and your mod is something that you can post on the Minetest forum to share with others. That, at least to me, makes a huge motivational difference.

A couple years back, I sat my then-11-yr-old son down with Minetest to use Lua to “change the game”. He wanted super powers. The look on his face when he succeeed in creating a flash command to run super fast, and a hulkjump command to have enormous jumps was one of the happiest looks I’ve ever seen. He felt powerful just creating such simple little mods.

It was also great when he realized he didn’t need a superman command to fly because the combo of hulkjumping while flash was active made flying unnecessary.

This was on HN a while back, using Minetest for education:


My 5yo son has been playing Minetest for a number of months now and loves it. He has asked for certain features---e.g. having fire truck be able to shoot water to put out fires rather than having to get out and use buckets of water---and I intend to walk him through adding that feature and others as he gets older. He's asked for things in the game that there are no mods for---I intend to show him how to create them using Blender, which I also think he'll have fun doing (granted, I'll have to remember how to use Blender!).

You may be able to do this in Minecraft, but I want him to see that _any_ aspect of the game can be modified and studied and shared, even outside its scripting language. I want him to see that it's encouraged, and normal. I don't want him to ever think that at some point, he'll be told "no, you can't do that", or "no, you can't see the source code---you can't study that".

Education isn't a short-term goal: it evolves over time. Free Software is well suited for education[0] not only for its practical benefits of study, but for its social benefits that are in line with the inquisition encouraged by other fields.

At this past year's LibrePlanet lightning talks, a speaker involved in gaming in free software provided his opinions on getting people involved with free gaming. Donald Robertson of the FSF provided his opinions on the matter and stated that people he spoke to wanted something more: they wanted to be involved in the community that they're already involved in with proprietary games. They don't want to explore new communities---so they'll mod games they're already involved in, proprietary or not. And this seems to be the source of a lot of resistance I get when talking about kids playing Minetest instead of Minecraft here on HN.

The webpage posted in this thread states, "Learn to program Python within a multiplayer world we all know and love, Minecraft!" And when getting children interested in certain topics, catering to interests is a powerful tool. But I still encourage trying to give Minetest a try: there are many similarities that children might be interested in. Ultimately, it's a judgment call, and if Minecraft is the only way to get your child interested in programming and they're already playing the game, less is lost. But if you're introducing your child _to_ Minecraft for the sake of modding and teaching programming, please consider Minetest instead.

[0]: https://www.gnu.org/education/edu-schools.html

>>My 5yo son has been playing Minetest for a number of months now and loves it.

Thanks! This is the type of actionable anecdata that I can use. I wasn't sure if it was too early to introduce my children to Mine[craft|test] at such an early age, but glad to hear that it's encouraging discourse and inquiry.

We started an online coding school for kids using a Minecraft like world called BlockSchool, your son might be interested in it, check it out!

We started our own browser-based project that teaches kids how to code in a Minecraft like world. Check it out, it's called BlockSchool. We're using WebGL and WebRTC with dataa channels, along with modern ES6 JS + Golang for our stack.

> One obstacle for schools to get started with this however, is buying all the Minecraft licenses.

That depends. It can be, if your class sizes.

However, last two schools I worked with simply bought a lab-worth of Raspberry Pis, and used that limited version of Minecraft.

> buying all the Minecraft licenses

All the schools I know of have an iPad per child these days. I doubt it's an issue [Edit: Ok roger that, not all schools. Consider me told]

There's also this https://education.minecraft.net/

Dude, the majority of people in the United States don't live near a Whole Foods, let alone the rest of the world.

If you think most schools have an Ipad per child, you live in a bubble.

Quite possibly. I didn't think at all outside of my "jesus these schools are giving kids ipads now? When I were a lad the school had 2 PCs for the entire building" bubble.

For reference I was also talking from within a UK only bubble too.

In fairness to you, I suspect the government schools (we call them public in the US, but I recall that "public school" means something entirely different in the UK) in your country are much better funded. I may be incorrect.

In the US, public schools are funded primarily by local governments, and are therefore extremely unequal in their funding, even within a relatively small geographic area.

I graduated high school from an impoverished rural county in 1999. The school I attended had a smattering of Windows 95 machines, enough so that about a 1/3 of the classrooms had a computer in it. There were only 2 machines in the entire school with internet access, and they were in the library. This was for a student body of roughly 600.

When I went to university, students from other (wealthier) parts of my home state of Virginia had been in schools where each student had a computer, and all had access to programming courses starting in middle school. Not surprisingly, students from these schools were disproportionately represented in my uni, and my "Intro to Computer Science" course was mostly filled with kids who had been programming for years. It made it very difficult to learn when more than 80% of the students have a huge advantage going in, and give the professors a false perception of how effective the teaching is. I sure hope the UK isn't like that.

I'm in a relatively well off US public school district. All kids have Ipads, but the parents must provide them or pay to rent them. If you qualify for the free lunch program they waive the rental fee.

> All the schools I know of have an iPad per child these days.

This might shock you, but that's not exactly common. Also, an iPad has a lot more potential uses than a Minecraft license.

Not all schools are as rich as all the schools you know... How can you even...

Nice! A while ago, I also worked on a Python <-> Minecraft interaction which is not based on mcpi (and RaspberryJuice), but instead spawns a full Jython based Python interpreter session server-side allowing you to directly use the full Bukkit API [1]. This allows to use various commands mcpi doesn't support, such as creating lightning, explosions, and dynamically writing events using Python, either by using a client (sending Python code over the wire) or from the chat console in Minecraft.

The way how mcpi works is by creating a network bridge between the RaspberryJuice plugin and Python. Commands in Python are send to the Minecraft plugin over the wire and handled there (using the Bukkit API), with output send back to the Python client. This is safer in the sense that you don't have the full Python environment running on the server and that (in theory) you can use both Python 2 and 3 (Jython support for Python 3 is not there yet). The drawback is that you can only utilize commands that are manually implemented and that the full Bukkit API is not directly exposed.

At one point, I also had a plan to expand this into a tutorial series but didn't really follow up on this due to a lack of time. I'd really like to do this some day, though.

[1]: https://github.com/Macuyiko/minecraft-python and video: https://www.youtube.com/watch?v=j4JfwS5hNlw

Wow! I believe this is exactly what I've been looking for.

One of my goals is to get my son, who is really into Minecraft, also interested in programming.

The github project seems to be receiving updates too.

If I end up making some reasonable progress on this, I might just contact you later on, if that's ok with you!

Sure! At one point, some group of volunteers also created a spin off project with the aim of putting more focus on creating a whole web interface around the concept, but I think it's inactive now. I try to maintain this repo from time to time and to keep it as bare-bones as possible.

At one point, I plan to experiment with ZipPy (https://github.com/securesystemslab/zippy) to see if that would be a viable option to get Python 3 support underway.

I was thinking about this just yesterday, and wondering if python could be taught in game like ComputerCraft uses Lua, except for python.

Maybe certain object/data types could have a physical presence like a database could be a shelf, and hooking them up physically would create a real database will multiple tables that could be interacted with in the game. I was thinking about this more in the sense of actually helping me model applications instead of teaching, as it would just be more fun to work with. Does anyone else have interest?

Another way of thinking about this could be like a library with bookshelves in game that you can actually walk though, and program an in game robot to get certain books when you want certain things (querying), and it could help visualize how a database and application were set up and working together.

I've had the same idea for a while, it'd be amazing if someone made this sub-game in minetest!

I remember working with a few people who had families several years back.There was a bring your kid to work day. Around mid day I saw all the kids playing minecraft on their laptops. They were probably about 8 - 12 I think. As I talked to them, they got really excited. Wanting to show off their private worlds. They had created custom modules in java, were running servers, and all these other things. This was like the lego blocks for their generation. In addition it bought a lot of STEM knowledge to boot.

Seeing stuff like this is really cool. Adding more to the community and growing opportunity.

This is really nice, however I wish someone makes an in-game version of this, so you don't even have to get a development environment running - just install the mod (which kids are already familiar with), jump in game and develop there.

I was thinking about this as well, maybe something like ComputerCraft which uses Lua but build on top of it, try and make it more visual though.

This looks great! I run after-school coding lessons for Australian kids aged 8-12, teaching them to code Minecraft mods using scratch-like code blocks (if you're interested, its https://codemakers.com.au).

I've been looking for a solution for teaching the more advanced students who want to start using a 'real' language. I was initially looking at using Scriptcraft, but TeachCraft looks like another great option!

Neat - I'm in the process of making a similar system which will spit out Spigot plugins, with the aim of letting kids create some simple ones themselves and hopefully planting the seed for getting them interested in programming. As part of this I included a 'split screen' view showing the generated Java in addition to the normal block work area, though this is read-only.

It's been more of a challenge than I thought it would be to design the blocks such that the end set isn't near enough a 1:1 mapping to Java - showing it to a non-technical friend of mine made it clear that my intuition was way off. Would be interested to hear how you approached this (if you don't mind).

Also interesting that I didn't find your website when I was initially researching, though I did come across https://www.learntomod.com/ (and even that was hard to find). I suspect my base search term of "minecraft blockly" isn't the most common one used by the target market to find something for their kids though.

This looks awesome. Minecraft is a fantastic way to teach programming, and not just to kids! There is something magical about seeing code you write doing something visual that you can interact with.

Here's a shameless link to a thing I created a while back when I was running workshops. Minecraft-like world that runs in pure browser aimed at teaching JavaScript:


Any parents here have any success inspiring their child to code who was averse to it? I've tried scratch, tynker, roblox, etc without much luck.

I guess I gave the impression that I'm shoving it down his throat. I'm taking the approach where I'm trying to inspire by showing him different kid friendly coding tools, not forcing anything and being totally okay if he doesn't want to do it. I was just curious if anyone had any success at inspiring a child to be excited by coding who wasn't into it at first. I know there are a lot of parents out there who try to force activities on their child, and I'm not one of them.

Maybe you are expecting just too much out of your child, if you tried so many options and they still don't like it, perhaps it is not something for them. Not everyone must like coding, let your kids shape their future based on their own passion instead of forcing yours upon them.

Don't force them to learn to code?

Have you taken a look at BlockSchool yet? Our students love it because it is similar to Minecraft!

Kids around here mostly use Minecraft PE on tablets. I know previously this didn't work with shared servers but maybe it does now - I'm not really up to date.

Would these Python customized servers work with tablet Minecraft now?

Would love to try this out as my kids love Minecraft (when played at friend's houses) but:

"Step 1 - Install Minecraft"

I can't get Minecraft to work on my Windows laptop. Minecraft crashes after a few seconds with a Java error:

"Java (tm) Platform Binary SE has stopped working"

Tried searching for a cause and tried everything I could find. Perhaps someone here has some suggestions?

EDIT: Re downvotes: that will teach me to post a half finished piece while I went to check on actual Java error! Not complaining - my fault entirely for posting half-assed reply which sounded aggressive.

Minor meta note: this site has almost no HTML metadata, which is probably not great for SEO but also makes it less visible when sharing on social media:




minecraft education is $5/year, with 'opportunities for volume licensing' which sounds affordable, but then it feels really misguided for microsoft not to give it away for free. Getting future developers to have some contact with the microsoft ecosystem is worth more than $5 i would think.

Unfortunately you need Minecraft for Mac/PC: Java Edition to use mods, so modding won't work on the education edition.

This is even worse than i thought then.

Well, I haven't played Minecraft since around 2013, but this tutorial so entertaining that I will probably install it again as soon as I get back from work today. This reminds me of the great game called Colobot, where players could program their robots to gather resources, fight the enemies etc using Java-like language. It would be nice to have a simple API to script NPC in Minecraft too.

This is great.

FYI, Minecraft Pi has this facility too. My daughter loves playing with it.


This is really great. All the existing "program in minecraft" solutions were pretty hacky IMO; lots of cruft to work around, which is really bad for my target audience of middle school students.

Nice! I was just looking for something similar to this for my minions. Looks like it assumes programming knowledge (beyond say Scratch) already, no?

Check out our latest project BlockSchool, we teach programming to kids using a Scratch like programming language in a Minecraft world. Happy to give you a demo!

I think that is great...I wish there would be more like that out there so kids and adults can learn playing a programming language

How about a guide on proper usage of fork, knife and spoon by teaching how to juggle with them?

Front page has example code of a busyloop with a time.sleep.

Not a stellar example of coding.

What is wrong with that? Will it eat up RAM or crash the box if it was left to run for too long?

The instructions say to install Python 2.7. Does this not support 3.x?

Its not like the people who will learn off this still be writing 2.x code in 2020... right? :) /s

Getting 3.x to work with mcpi is actually super easy; the library works nearly out of the box, and the code is basically the same as far as I can tell.

Applications are open for YC Summer 2018

Guidelines | FAQ | Support | API | Security | Lists | Bookmarklet | Legal | Apply to YC | Contact