Examples.java
Knoxel.java. Be sure to call:
BlockWriter.writeDrawingToFile(grid, "mydrawing.json");To produce a JSON Drawing file called "mydrawing.json" (you can pick whatever name you want, you don't need to name it "mydrawing").
Many students have made contributions to Knoxcraft over the years! They are:
John Damits, Knox College '17, funded by the Mellon Foundation and the Richter Memorial Trust |
Matt Moe, Knox College '17, funded by the Richter Memorial Trust |
Lucas Kasser, Brown University '19 |
Emily Hastings, Knox College '16, funded by the ASSET program, and the Richter Memorial Trust |
Michael Gerten, Knox College '16, funded by Knox's Baker-Velde award, and the Richter Memorial Trust |
Jaime Spacco, Haverford College '98 |
Knoxcraft is made possible by the following projects:
Knoxel was inspired by, or is similar to, the following projects:
Yes! The code for Knoxel is here: https://github.com/jspacco/knoxel
Submit an issue and I will see what I can do!
Java does not yet work through the web browser, so you have to run the Java code offline, which creates a JSON Drawing file that you can upload directly to the Game tab.
Check out the Java code here:
Knoxel drawings are 3D volumes made up of 3D arrays of width, depth, and height. The coordinates are in that order, blocks[width][depth][height]. In Voxel-based worlds like Minecraft, the X-coordinate (i.e. blocks[x]) is the width; while the Z-coordinate (i.e. blocks[x][z]) is depth, and is the 2nd coordinate in our 3D array; then the Y-coordinate (i.e. blocks[x][z][y]) is the height, and is the 3rd coordinate in our 3D array.
Here is a diagram that illustrates these concepts in more detail:
Sure! The code is here
Hack away at it!
Browser support requires a Javascript library that can transpile the source language into Javascript. Skulpt does this for Python, which is how we have Python support. I haven't found any libraries that are written in Javascript, and that can transpile Java to Javascript. I recently found a parser that produces CST (which I guess is like an AST but more concrete and less abstract, hence the "C" in CST), but I haven't had time to really dig into it. I think transpiling a subset of Java that is enough to make this work is feasible, but not in the time I ha alotted for this project.
It's not that difficult to support other langauges the same way we currently support Java, by writing simple functions that produce JSON files that can be uploaded. Submit an issue if this is important to you and I will see what I can do.
Adding browser support is trickier, because it relies on a transpiler written in JavaScript that can transpile the source language into Javascript. If one exists for the language, it should be possible!
We have a really messy Spongepowered mod from a few years ago that does not really work. The issue is that students trigger their code by running a command-line command, but a lot of those commands tried to create thousands of blocks, which lagged. Minecraft expects commmand-line commands to finish very quickly, and when they don't, the server assumes something is wrong and shuts down. We tried to create basically a giant work-stealing architecture to make this work, but it was kind of a mess.
Anyway I think what we actually need are bots with infinite inventories that run around and lay out the blocks. We could not get that to work a few summers, and I have not had time to work on it since.
Knoxel is specifically designed to help CS students practice 3D arrays. You have to write code to create things!
If you want to play Minecraft, go play Minecraft! It's a legitimately great game that has brought enormous joy to the world.