The Minecraft Blocks in ScriptCraft

You probably opened this article, hoping I’d give you a list of all the blocks and block codes. But I’m not. I’m going to show you where to find them.

How the list of blocks is created

The blocks object in ScriptCraft is created by a script called blocks.js in the modules subfolder of your scriptcraft folder.

File manager detail with location of scripts.js

If you open that file, Walter Higgins has created a very well-commented script that creates the blocks object that you can use in the drone.

Well, what does the blocks object do?

Objects are mostly made up of some combination of things they do and/or values they hold. The things an object does are called its methods, and the values it holds are called its properties. The blocks object is basically a large collection of properties.

Let’s look at the beginning of Walter’s blocks object.

He’s defining a variable called blocks by starting with var blocks =, but by starting his variable value with a curly brace {, he’s telling JavaScript he wants to put an object in that variable. There are a number of ways to create an object. This one is called using “object literal notation.”

He then creates a whole bunch of variables that will exist in that object as its properties. Each one has the variable name, then a colon, then the variable value, then a comma before moving on to the next. Where the variable value is a number, there are no quotes. When the variable contains non-number symbols like that colon, it’s in quotes and used as a string.

Each one of those “properties” within the object can be accessed by using the object’s name, a period, and then the property’s name. For example, if you type in…

/js blocks.oak

…ScriptCraft will return the value 5.

You might have noticed that in the last line, sapling creates an object with properties of oak, spruce, birch, and jungle. Since sapling is a property of blocks, the way to get the value of a birch sapling would be to use blocks.sapling.birch.

So is this the list?

The code in blocks.js does do some calculation and enumeration to flesh out the full list. But you can use another ScriptCraft command to write that list to a file.

/js scsave(blocks, 'myblocks.json');

Run that from the server or in the game and you’ll create a file in your Minecraft server directory called myblocks.json filled with the full list in object literal notation. Open that in a text editor, and you’ve got a list of every block type the blocks object knows about.

Back to the Main Minecraft Modding Menu

2 Replies to “The Minecraft Blocks in ScriptCraft”

    • I think you’re confusing the server-based block object vs the “blocks” object in ScriptCraft, which is a meta-index of the block types. A list of widget names and their corresponding SKUs says nothing about the internal complexity of the individual widgets or their manufacturing process. 🙂

Leave a Reply

Your email address will not be published. Required fields are marked *