Four Kitchens

ScriptCraft: Using JavaScript within Minecraft

3 Min. ReadDevelopment

This flew across my inbox/twitter/something a couple days back, and I spent all last evening having fun with it. It’s called ScriptCraft, a JavaScript API for building within Minecraft.

If you’re not familiar with Minecraft, it’s a world made of 1-meter cubes. You just dig around for minerals and build cities to protect your supplies. Then you get bored and start modding Minecraft.

How it works

ScriptCraft supplies an object called a Drone. Think of it like a turtle that can move in 3D space. Just like jQuery, the Drone always returns this, allowing you to chain commands together on the one-line console available in Minecraft. You can change the Drone’s position, create blocks of any material, create primitives, complex objects like trees, “bookmark” coordinates, and even copy/paste huge volumes of blocks. Built upon the Drone are other JS plugins, and the author has thrown in some good ones to get you started using the API, among them a couple buildings, a block-letters, and other goodies.

Say you want to avoid griefers and would like a truly impenetrable fortress. I would like an underground lair made of bedrock, for example. This is basically impossible in vanilla Minecraft, but using ScriptCraft you can do it in one comand:

/js down(11).box(7,20,1,20).up().box0(7,20,9,20).up(9).box(7,20,1,20).up().box(2,20,1,20)

…it’s not pretty, but this generates a hollow shell which you can use as scaffolding for your new fortress.

Creating a JS plugin in ScriptCraft

That command looks crazy all on one line, but here I broke it out into fortress.js:

load(__folder + "drone.js");
 * Creates a fortress of bedrock and one layer of dirt on top.
Drone.extend('fortress', function(material, sides, height) {
  // Drop the Drone down to the bottom of the structure
  // Lay down a solid layer for the floor, sides, 1, sides);
  // Move up one level
  // Create all four walls. box0() creates hollow boxes
  this.box0(material, sides, (height-3), sides);
  // Move up above the walls
  // Another solid layer for the ceiling, sides, 1, sides);
  // Move up one more time
  // Finally, a layer of dirt to remain inconspicuous ;), sides, 1, sides);

  // retu\r\n \this to allow further chaining
  retu\r\n \this;

You can chain the commands here too, but I chose not to in order to document each command clearly. When you’re happy with your creation, you’ll want to put the JS file inside ./js-plugins on your Minecraft server. Once you’re finished uploading it, you have to load the file within the game and get access to use the command:

/js load('js-plugins/path/to/fortress.js')

You’re ready to create some rooms in your fortress. Keep the material ID list handy while you assemble your commands. Materials with colons in them need to be strings.

// made of bedrock, 20 each side, 12 blocks tall
/js fortress(7,20,12)

// made of diamond blocks, 25 each side, 8 blocks tall
/js fortress(57, 25, 8)

Use Bukkit in JS

If all of that weren’t enough, the entire Bukkit API is available via JavaScript once ScriptCraft is loaded. That means anyone with JavaScript experience can now write whole Minecraft mods using ScriptCraft.

We haven’t installed it quite yet, but ScriptCraft will be up on very soon. Stop by and give it a shot!


ScriptCraft was created by Walter Higgins. He’s active on his Github project.