const width = 2; const depth = 3; const height = 4; let blocks = knoxel.makeGrid(width, depth, height); for (let w=0; w<width; w++){ for (let d=0; d<depth; d++){ for (let h=0; h<height; h++){ blocks[w][d][h] = knoxel.dirt; } } } knoxel.drawBlocks(blocks);
width = 2 depth = 3 height = 4 #blocks = [[[null for k in xrange(height)] for j in xrange(depth)] for i in xrange(width)] blocks = makeGrid(width, depth, height) for i in xrange(width): for j in xrange(depth): for k in xrange(height): blocks[i][j][k] = bt.cobblestone drawBlocks(blocks)
width = 2 depth = 3 height = 4 blocks = make_grid(width, depth, height) # # Note that Opal cannot handle nested for loops, only nested each loops # https://github.com/opal/opal/issues/2033 # It looks like this was fixed elsewhere but not here # may need to file a bug report # (0...width).each do |i| (0...depth).each do |j| (0...height).each do |k| blocks[i][j][k] = blocktype.grass end end end draw_blocks(blocks)

Two ways to use Java!

How to use Java with BlueJ

  1. Download and unzip/extract this zipfile..
  2. Open the folder with BlueJ
  3. Look at the example programs in
    Examples.java
  4. Write your code in the file
    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").
  5. Upload the JSON file directly to the "Game" tab using the button labeled "Upload Drawing from JSON"

How to use Java with your favorite IDE other than BlueJ

  1. Download and unzip/extract the BlueJ zipfile..
  2. Copy the .java files into a new project in your IDE. We use the default package to be more novice-friendly.
  3. Pick up with step #3 from the instructions above.
Knoxel aspires to bring the joy of Minecraft to CS-0 and CS-1 courses.

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:

I found a problem! Can I submit issues?

Yes! The code for Knoxel is here: https://github.com/jspacco/knoxel

Submit an issue and I will see what I can do!

How do I write my code in Java?

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:

Download the code and run it with your favorite IDE. To keep things accessible to novices, the code does not use packages.

How do coordinates in Knoxel work?

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:

Can I make contributions to Knoxel?

Sure! The code is here

Hack away at it!

When will Java be supported in the Browser?

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.

Can we get support for my favorite language?

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!

Where is your Minecraft server mod?

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.

Why can't I mine or place blocks like in regular Minecraft?

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.