7 ms·
Show HN: Learn Python with Minecraft
Looking for feedback on my project to teach python by writing code that interacts with a Minecraft World.
- b800h 4y agoI like this. Obviously, internally, the original Minecraft runs Java, but that's quite a difficult sell to an 8-year-old. This is potentially a nice way to get them into programming for the game - the only thing I worry about is maintaining compatibility with a product which Microsoft seem intent on wresting away from modders, perhaps only indirectly. Even making logins work is fraught with peril thanks to Microsoft's appalling IAM solution.
- n2d4 4y ago> Microsoft seem intent on wresting away from modders, perhaps only indirectly What is Microsoft doing in that regard? Last I was working on Minecraft mods they did a lot to support them, such as sharing the obfuscation map or making Brigadier open-source. Have there been other developments since then? The IAM logins seem more like a security decision to me (assumably Microsoft has requirements on how their products need to do authentication), not one to keep away modders.
- lfkdev 4y agoReally? My last info was that in Minecraft Bedrock, you even need to buy "coins" with real money to change simple things like Skin Packs. What a shame
- bjord 4y agoafaik they're still developing the java version as well, though
- drummojg 4y agoMost definitely! https://minecraft.fandom.com/wiki/Java_Edition_version_history https://minecraft.fandom.com/wiki/Java_Edition_version_histo...
- agentwiggles 4y agoThat's just not the case at all. You can certainly buy mods from the Minecraft store (or whatever it's called). But you can also write behavior packs and make skins and textures without paying for anything (besides the base game). My son and I spent some time making custom weapons and the like using a tool called Bridge (https://bridge-core.app/ https://bridge-core.app/). It's definitely not as powerful as modding once was in the Java version of the game, but you can do lots of pretty wild stuff with Bedrock if you're willing to jump through the hoops. One "mod" that recently caught my eye was this one: https://www.youtube.com/watch?v=IUWRK0Jy9d0 https://www.youtube.com/watch?v=IUWRK0Jy9d0 Yeah, you have to buy it with "Minecoins", but I can't get too upset that Microsoft has allowed devs to monetize their efforts on the platform. There's still plenty of free stuff available and nothing to prevent kids (or adults) from taking a crack at their own mods. My son was just recently playing with a site called Tynker, and without any help from me managed to get a custom item into the game, so if an 8 year old can do it, it's about as accessible as you could hope for.
- gilesknap 4y agoThis sounds quite interesting. I've really only spent much time with Java and although it has a great modding scene it is unofficial and nothing ever works with updated versions (My Python approach is immune to this issue as it uses official RCON interface). I have always been put off by how commercial Bedrock seems as soon as you open it. But at the same time it sounds like interesting and official modding is available there.
- noirscape 4y agoMostly passively by trying to push stuff like Realms more instead of letting the community run their own servers (which could also be modded). Bedrock Edition is also iirc insanely locked down in terms of modding and it's the version Microsoft pushes the sales of the most. There's some amount of it possible, but forget about any of the ludicrous automation/engineering mods like you had back in Java edition.
- DefineOutside 4y agoMicrosoft also published DataFixerUpper and added some packets specifically for servers such as the "Ping" packet and the "Bundle" packet and the 1.19.4 display entities. Ping being to synchronously measure latency of the client - unused by vanilla Bundle being to force packets to be processed together - very useful for sending clients display animations all at once And then all the display entities to display text and itemstacks in the air, with custom interpolation and stretching - so advanced animations can easily be made. The most hostile thing is Microsoft pushing the locked down Bedrock edition.
- gilesknap 4y agoSo we should be good for a while. The RCON interface this uses is always forward compatible with new Java editions. Bedrock also uses RCON but there are subtle differences with the commands available. If Microsoft ever does drop Java Edition I'd likely rework this to support Bedrock. I'm hoping this won't happen - they are keeping Java up to date with Bedrock presently but the new editor mode for Bedrock is a worrying development (maybe).
- nextlevelwizard 4y agoIf you would have asked me which language would be taught with Minecraft I would have answered Lua. I don't know why. But I was instantly wondering why Python instead of the obvious answer which is Lua.
- Jaxan 4y agoThe computercraft mod allowed one to program lua robots inside minecraft
- amarant 4y agoCurious timing! I signed my niece up for a programming course for children yesterday where they are going to learn python with Minecraft! Now I wonder if they'll use your project, or if there's another similar project they'll be using? Regardless, the idea is great! I wish you luck!
- gilesknap 4y agoIt won't be MCIWB :-) Nobody had heard of it until last week! :-) They may be using Minecraft Education Edition which as come up a few times in the above conversations.
- askvictor 4y agoWhat's the advantage over MakeCode for Minecraft (other than that requiring Minecraft education edition)?
- gilesknap 4y agoBelieve it or not I did not know about this. I'm aware of Education Edition but the projects in MakeCode look more sophisticated than I expected. I'm going to take a look into it and come back to you on this question!
- gilesknap 4y agoI've looked into MC EE and MakeCode. Here is my summary of findings https://gilesknap.github.io/mciwb/main/user/explanations/mcee.html https://gilesknap.github.io/mciwb/main/user/explanations/mce...
- askvictor 4y agoNice. When I was teaching with MCEE, the code server was painfully slow. I think MS employees don't test this kind of thing on real hardware that real students use.
- mastazi 4y agoIf you are interested in this sort of tools, look into Baritone and Schematica https://github.com/cabaletta/baritone https://github.com/cabaletta/baritone https://github.com/Lunatrius/Schematica https://github.com/Lunatrius/Schematica
- lifebeyondfife 4y agoWhen I worked at Skyscanner, we'd volunteer at events where high school kids would be shown tech stuff. We'd setup Raspberry Pis with Minecraft on them and show them some basics of running Python scripts to alter the world (with the conclusion being programmatically create loads of dynamite blocks and explode them). Then at the end of the session, give every kid their own Raspberry Pi. It was interesting reaching the occasional child who assumed this kind of thing wasn't for them.
- 867-5309 4y agowas this by injecting from the pi to a capable Minecraft server? because exploding loads of TNT on a pi itself would run at a painful framerate, I presume edit: actually mc renders locally so unless it was running at a really low resolution, I suppose it must have been painful
- humanizersequel 4y agoThere is an official release of minecraft optimized for the Pi: https://www.minecraft.net/en-us/edition/pi https://www.minecraft.net/en-us/edition/pi
- 867-5309 4y agono info on which Pis are supported, or if network/XBox Live is enabled
- fencepost 4y agoIt mentions running on Wheezy, which from a bit of digging looks like the 2013-2015 version of Raspbian, based on the 3.x kernel. Wheezy is only listed for the 1/1+ and 2. https://minecraft.fandom.com/wiki/Pi_Edition https://minecraft.fandom.com/wiki/Pi_Edition lists it as being slightly stripped down from Alpha 0.6.1 of Pocket Edition. Also a quote from 2016: "The original team has stopped supporting it and starting with 0.9 MCPE became a lot more ambitious technically, which also means that it became a lot harder to strip down to run on a Raspberry Pi. Actually, we finished removing all Pi related code to reduce complexity in 2015." If your interest is simply in running MC on a Pi you're probably best off looking into Java Edition, though I have no idea how capable the hardware actually is graphics-wise. If you're more interested in MC on cheap hardware, you're probably better off with a cheap Windows machine and the Microsoft Store/Bedrock edition written in C++ for performance.
- suglus 4y agoInteresting repo
- infinitezest 4y agoIf you don't mind using Lua instead, I can recommended minetest as a free alternative. I've had a lot of fun messing around in it. It has a lot of great games and mods as well. https://www.minetest.net/ https://www.minetest.net/
- born-jre 4y agoFor FPS lovers, recommend this server: https://github.com/piqueserver/piqueserver https://github.com/piqueserver/piqueserver client: https://github.com/yvt/openspades https://github.com/yvt/openspades
- deknos 4y agolua! great! There's also blockly (which is a free version of scratch, the visual programming language), but i wanna have a real language! thanks!
- b_mc2 4y agoMinetest is definitely fun, and I've had good luck using Miney to build in it with Python https://miney.readthedocs.io/en/dev/index.html https://miney.readthedocs.io/en/dev/index.html
- tempaway45754 4y agoMinecraft Education edition already does this. Press C, code window appears, you can use Python, Javascript or a visual Scratch-like language, controlling an agent in the minecraft world to go and do things https://education.minecraft.net/en-us/resources/computer-science-subject-kit/python-101 https://education.minecraft.net/en-us/resources/computer-sci...
- RamenJunkie_ 4y agoLast time I looked into it, which I do fairly often because Education Edition has some interesting features not in other versions, you need to be an educator to even get a license for Education Edition.
- gilesknap 4y agoWell that's a shame because I am pretty sere education edition supports RCON so I could adapt MCIWB to use it. I happen to know that EE commands include the elusive 'GetBlock' that let's you query the contents of the world. I had to jump through some embarrassing hoops to provide this function for MCIWB.
- rollcat 4y agoIt seems EE is more about programming agents that interact with the world (like in survival mode), whereas this tool interacts with creative mode to edit the world (think generative terrain, copy-pasting bits of your build, etc). I'd say they complement each other, but unfortunately Minecraft JE and EE are two entirely different programs[1]. [1]: https://news.ycombinator.com/item?id=35150691#35152941 https://news.ycombinator.com/item?id=35150691#35152941
- gilesknap 4y agoI've taken a detailed look at MC EE vs MCIWB and taken some notes here: https://gilesknap.github.io/mciwb/main/user/explanations/mcee.html https://gilesknap.github.io/mciwb/main/user/explanations/mce...
- worldmerge 4y agoThis is so sick!
- Graziano_M 4y agoIf you like clojure (which can interact with the jvm directly) there's also witchcraft: https://github.com/lambdaisland/witchcraft https://github.com/lambdaisland/witchcraft
- darknavi 4y agoMinecraft (Bedrock) API Dev here, we also started publishing TypeScript types for our JavaScript API! The API is still really new and sparse but we are getting there.
- gilesknap 4y agoSo this sounds like fun. What kind of interface - operator commands? or something more low level? The operator commands that MCIWB uses are really poor for querying the state of the world - hopefully this API would give us that?
- geomark 4y agoIs what you are doing similar to "Adventures In Minecraft"? [0]. My kid and I went through that and is was great. Last adventure involves hooking up a micro:bit to control in-game elements. [0] https://www.wiley.com/en-us/Adventures+in+Minecraft,+2nd+Edition-p-9781119439585 https://www.wiley.com/en-us/Adventures+in+Minecraft,+2nd+Edi...
- gilesknap 4y agoIt looks like this book will be using the education edition of minecraft. It does have a limited python programming interface. My approach uses a remote interface called RCON to send Minecraft operator commands to the world. It can do everything you could do with Command Blocks or Operator commands and more because of the Python constructs like loops and branching. The other benefit is that you get to use the latest developer tools such as VSCode and the latest version of Python as you are working outside of the Minecraft game to write your code.
- billyjobob 4y agoNope, it uses regular Minecraft with https://pypi.org/project/mcpi/ https://pypi.org/project/mcpi/ and https://dev.bukkit.org/projects/raspberryjuice https://dev.bukkit.org/projects/raspberryjuice so full Python.
- gilesknap 4y agoThanks for the link. I did not know about raspberry juice. It does provide a similar capability to MCIWB. It recreates the Education edition python interface which does let you set and get blocks and see when a player hits something. Its a solution for people who learn education edition and then want to run the same code at home on a BUkkit server. (Bukkit is a Java server mod )
- geomark 4y agoWe did it and we've never had education edition.
- VikingCoder 4y agoI honestly cannot understand how Microsoft is running Minecraft. How do they not seem to realize the value in making it easy for people to hack it like this? Look at the installation page... https://gilesknap.github.io/mciwb/main/user/tutorials/01-setup.html https://gilesknap.github.io/mciwb/main/user/tutorials/01-set... Why? Can't we please have a way to trivially do this?
- gilesknap 4y agoTo be fair. My instruction page is setting up Minecraft, Docker to run a minecraft server in, Python and VSCode. So I have quite a few prerequisites for my Python tutorials and this makes the first page intimidating. However, installing and running MC java edition has got more fiddly since Microsoft took over. There was a horrible transition phase where accounts were being migrated from Mojang. It's kind of OK now. But I'm sad that Microsoft is pushing hard on Bedrock Edition and look like they may try to ditch Java. This project could be adapted to Bedrock without much trouble but there is a whole class of things {NBT related} that you don't seem to be able to do via the remote interface in Bedrock.
- caseyf 4y agowhoa it'd be cool to use this to build an experience within minecraft where a world builds up around the player as they move around it.
- gilesknap 4y agoYes, you could absolutely do that. I've even used it to create moving structures that players can get inside and be carried around in.
- erichocean 4y agoI'm doing this with teenagers, but using Clojure.
- marmot777 4y agoMy son will be interested in this for sure.