Programmers: Play with Minecraft's Inner Workings!
We're opening up some of the game's code!
Making games isn't easy. Sure, it's not rocket science, or brain surgery (those things are probably waaaaay easier), but it's still incredibly difficult to learn to code, program and sheer-blind-luck your way into making a videogame. If only you had access to more resources…
Well, the lovely folks on Stockholm's Minecraft Java team are giving you just that, by opening some of Minecraft's code as libraries so they can be used however you like! Want to use them to improve your Minecraft mods? Great idea! Want to use them for your own projects? Go for it, just don't forget to credit us! Want to use them to help improve pieces of the Minecraft Java engine? Thanks, we really appreciate it!
Hang on, what even is a game 'library'?
“Libraries are little parts of the game engine,” explains Java developer, Nathan Adams (also known as Dinnerbone). “We're making some of the self-contained libraries that Minecraft uses open source. Anyone can pick them up and use them in their own game.”
The plan is to open up different libraries gradually. These libraries are open source and MIT licensed, which means that “basically, anyone can go in there and they can contribute and they can help improve our game engine,” Nathan explains.
“Or, if they're making their own game, they don't have to rewrite these little parts. They can just use ours, which have been tried and tested because we're a very popular game, apparently!”
“I’m so proud of that name!” Nathan says. “Brigadier is the name of the command engine that Minecraft uses.” Brigadier is also the first library we've opened up!
“So in the game you can type something like /give Dinnerbone sticks and then that goes internally into Brigadier and breaks it down into pieces. Figures out what are you trying to do with this random piece of text.”
Minecraft tells Brigadier: “These are the things that players can do. Tell me once the player’s trying to do this.” So when a user types /give Dinnerbone sticks in chat, that goes through Brigadier. Brigadier splits it up, it error checks it, it tries to be as helpful as it can. You’ve also got this lovely pop-up window when you’re typing that can suggest what the next bit might be.”
Hopefully all this makes the process a lot more user friendly!
Nathan hopes that giving the Minecraft community access to Brigadier can make it “extremely user friendly one day.” After all, commands are still not commonly used by a lot of Minecraft players. “Some people don't really look at commands because they’re a bit intimidating and I totally understand why,” says Nathan. “This is supposed to help a lot with that.”
Brigadier takes the random strings of text you enter into Minecraft and turns into an actual function that the game will perform (so you've got Brigadier to thank for all those sticks). “A lot of people think this is a really easy function,” says Nathan. “But the reality is actually extremely complicated.
“We thought this would be an amazing first test of the system. It’s a great thing that people can just pick up and use in any kind of project. It doesn’t even have to be a game – I’ve seen some people trying to use it on telegram chat bots, so you can just message it and it’ll do what you’re asking it to do.” Neat!
Brigadier has only been available for just over a week, and already we've seen people trying to improve the code, and even make Nathan's handy readme doc a bit prettier and more user-friendly! Wait, you lot are writing stuff for Nathan for free? Are you trying to put me out of a job?
DATA FIXER UPPER
“The name is so stupid that we had to keep it,” explains Nathan, unapologetically. DataFixerUpper does exactly what it sounds like, and it's one of the most important parts of the Minecraft game engine. It's also the second library we're opening up!
“The problem that we have in Minecraft, that I’m pretty sure every game has, is that data changes over time,” says Nathan. “we add a thing into Minecraft and then we kind of have to change how we store level data, how we store all the save files and stuff to accommodate it.
“When we load up any world in Minecraft right now, you can have some data that has not been touched for six years, because that chunk was last played six years ago. So we need to know: 'OK, this level actually looks really old. Now we’ve got to turn that old data into what it should look like now – in a way that the game can currently read.'
“We have one little unit which uses DataFixerUpper that just says to Minecraft: 'this is how to turn anything into the data format that the game is going to use.' And so the game is now only saying 'This is how the data looks, so this is how I’m going to read it.'
"Basically, before Minecraft actually loads the chunks, it goes through DataFixerUpper and that turns it into what it should currently be now.”
Confused? That's fair – DataFixerUpper is a lot less user-friendly than Brigadier – but that's also one of the reasons why we're making it available to everyone!
The Java team will be opening up more libraries soon and we'll update this article when they do. One library under consideration is Blaze3D - a complete rewrite of the render engine that we're aiming to implement for 1.14. For now, why not use your programming expertise with our existing libraries? Don't forget to leave feedback on the GitHub page or reach out to Nathan on Twitter!
- Tom Stone