Hacker News new | ask | show | jobs
by Confiks 3251 days ago
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

10 comments

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

https://github.com/cjdell/Craft/commit/c0162acb36ed8f538c6bf...

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!

I

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

https://github.com/satoshinm/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.

https://github.com/traverseda/pycraft

> 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:

http://www.ocsmag.com/2016/04/04/mining-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...