Custom blocks

Update 32 added the feature to create your own unique blocks with up to 8k texture resolution and upload them to the Steam Workshop.

* Update 33 added the feature to create animated custom blocks.
* Update 38 added the feature to create blocks that glow and have a normal map.

**You can find the Steam workshop page for cyubeVR here!**

*(To add custom blocks from the workshop to the game, you have to be logged in to your Steam account. After logging in, if you hover over blocks with your mouse a green "+" button appears in the right corner. Just click the plus button and Steam will download the block.)*

**(If you prefer the original post on Steam, you can click here!)**

## **How to Create Custom Mod Blocks for cyubeVR**

You can download a template mod block **here**. Creating a new block is easier if you start off with that template.

To install the template mod block, unzip the folder and paste it into this folder:

```
[GameInstallDirectory]/cyubeVR/Mods/Blocks/

```

### **What You Need**

For creating a new block, you need a few things:

1. A name for the block

2. One or more textures for the block

3. A recipe for crafting the block

4. An image that shows the crafting recipe

First, create a new folder here:

```
[GameInstallDirectory]/cyubeVR/Mods/Blocks/

```

You can call the new folder anything you want. For this tutorial, let's assume you called the new folder "My First New Block".

### **The "Properties" File**

Now, go into the folder of the mod block template, copy the Properties.json file, and paste it into your block folder. The Properties.json file is what the game reads to know about the properties of any custom block.

So, the directory structure will now look like this:

```
[GameInstallDirectory]/cyubeVR/Mods/Blocks/My First New Block/Properties.json

```

Now, open your Properties.json file with any text editor. The Properties.json copied from the template block looks like this:

```
{
    "Name": "Template Custom Block",
    "UniqueID": 82323470,
    "Recipe": {
        "Array": [33, 33],
        "SizeX": 1,
        "SizeY": 2,
        "SizeZ": 1
    },
    "Yield": 5,
    "SimilarTo": 1,
    "Textures": {
        "Mode": 1,
        "WithNormals": false
    }
}

```

### **Give the Block a Name**

The first thing you want to change in there is the "Name". Give your block a nice name. The name does not need to be same as the name of the folder you created, but for avoiding confusion, it might be helpful. The name defined in the Properties.json is the name you will see in the game. For this example, let's call the block "My First New Block".

You can change the name at any time, so if you don't know what name you want to give it, that's no problem. You can come back at any time and edit the name in the Properties.json without breaking anything, even if you are already using the block in the game.

### **Setting a Recipe**

Let's ignore the "UniqueID" for now and directly go to the recipe: As manually defining a recipe would be annoying, there's a very quick and easy automated way to generate the recipe for you: Start the game and attach the correct type of blocks together that you want to trigger the recipe for your new block. So if you want your new block to be crafted with 4 pieces of processed wood, attach the 4 pieces of processed wood together in the correct formation you have in mind. Then, drop the structure somewhere and open the inventory briefcase. Go to the settings and scroll down to the bottom - there is a new button called "Generate Recipe". Click that button. Now you can close the game again.

Clicking that buttons made the game generate a .txt file with the recipe in there. You can find the txt file in this path:

```
[%localappdata%]/cyubeVR/Saved/Dev/Recipe.txt

```

If you open the file with any text editor, it will look something like this:

```
"Recipe": {
    "Array" : [33,33,33,33],
    "SizeX": 2,
    "SizeY": 2,
    "SizeZ": 1
},

```

You see the structure of this looks exactly like the recipe definition in the Properties.json - so you can just copy everything from the Recipe.txt and replace the existing recipe definition in the Properties.json with the new recipe. In this example case, the Properties.json should look like this now:

```
"Recipe": {
	"Array" : [33,33,33,33],
	"SizeX": 2,
	"SizeY": 2,
	"SizeZ": 1
},

```

### **Yield**

Let's adjust the "Yield" value now. The yield describes how many blocks you get from crafting the recipe - so if the yield is 5, crafting the recipe once will result in 5 blocks being added to your inventory. You can use any value between 1 and 32 here.

### **SimilarTo**

Next, the "SimilarTo" value. This is for setting which existing block is similar to your custom block regarding the tools you use to break the block - do you want your block to be destroyed using a pickaxe, using an axe, or using a shovel?

SimilarTo Properties
 2
 3

### **Textures**

In the properties.json file, there are two settings regarding the textures. The "WithNormals" value is for letting the game know if you only provide color textures, or also normals. Normals are currently not supported yet with custom blocks, so this setting isn't doing anything currently.

The "Mode" setting is for letting the game know how many different textures you want to provide for your block. Some blocks might show the same texture on all 6 sides, and some blocks might have different textures on every side. For performance and memory reasons, it would be a waste to let the game import 6 different textures if they are all actually the same, so you can let the game know exactly how many textures are required. All textures need to be provided in the "dds" format, which will be discussed a bit later. The available different modes are these:

1: You provide one single texture, called "all.dds". The texture will be displayed on all sides of the block.

2: You provide two different textures. The first label for this is "sides.dds." The texture given here will be displayed on the sides of the block. The other is "updown.dds" that will be displayed on the top and bottom of the block.

3: You provide three different textures. The first label is "sides.dds". The texture given will be displayed on the sides of the block. The next label, "up.dds", will be displayed on the top of the block, and the final, "down.dds", will be displayed on the bottom of the block.

4. You provide six different textures, one texture for every side. They are called "up.dds", "down.dds", "left.dds", "right.dds", "front.dds" and "back.dds"

After you know which mode you want to use for your block, you can start creating your textures! As mentioned above, all textures need to be provided in the .dds format. That's a special format used by graphic cards. GPUs can natively handle that format the best, so it makes it very easy to import it into the game.

You can easily convert JPG, PNG or TGA files into the DDS format. There are many free tools available on the internet for converting textures into the DDS format. An easy to use one can be found here:

**DDS Converter**

It has very few buttons, so it's quite hard to do anything incorrectly there. You pick a source folder (where your PNG/JPG/TGA image files are), you pick a target folder (where you want the images to go), and then you press the "Convert" button. The program will convert all images from the source folder into DDS files and place them in the target folder.

The only potential problem here is that you need to make sure the settings are set correctly. The "Output Format" on the left needs to be set to "DXT5", and in the list of checkbox options, "Mipmaps" needs to be checked.

All textures that are required for your block need to be put into the folder:

```
[GameInstallDirectory]/cyubeVR/Mods/Blocks/My First New Block/Textures

```

All textures have to be provided **twice** to the game, once with a size of exactly 2048x2048 pixels, and once with a size of exactly 512x512 pixels. The textures with a size of 512x512 have to be in the same folder where the textures with a size of 2048x2048 pixels are, and they need to have the same file name, apart from an additional "\_small" at the end - so if you have the "all.dds", then you also need the "all\_small.dds" file in the same folder.

Depending on the mode, either 2, 4, 6 or 12 texture files need to be put into the folder.

The 512x512 texture is used by the game for calculating the amount of snow that is visible on top of a texture. Depending on how bright your texture is, the amount of visible snow is more or less. If you see that your texture has too little snow applied on top while it snows, then you need to adjust the brightness of the 512x texture to be darker - if you see the texture has too much snow applied, you need to make the 512x texture brighter. This means the 512x version of the texture does not need to look the same as the 2048x version; if you need to make the 512x texture darker or brighter, it will only affect the snow. The player will only see the 2048x texture.

### **The Recipe Preview**

A list of custom mod blocks is displayed in the crafting recipe overview, below the normal recipes. You already probably know that if you click on a standard recipe, you see a rotating preview of how that recipe is crafted. Since creating such a rotating preview would be hard for custom mod block recipes, you just provide an image that is displayed instead when someone clicks on your custom mod block in the UI. This image should make it easy to understand how the recipe for that block is setup. The best solution for this is likely to put together the correct recipe in the game, hold it nicely in front of your head, and take a screenshot of that. Then crop the screenshot a bit to get an image with the size of 512x512 pixels, like this for example:

**Example image**

You don't have to do this though, you could also go into paint and draw a diagram that shows how to craft the block - it's fully up to you, the game just imports and displays an image you provide for that.

This recipe preview image also needs to be provided in the DDS format, and it needs to be in the same folder where the Properties.json is, with the name being "RecipePreview.dds". So, in the case of our example block, the path would look like this:

```
[GameInstallDirectory]/cyubeVR/Mods/Blocks/My First New Block/RecipePreview.dds

```

### **The UniqueID**

We're almost done now, just one last thing in missing - in the Properties.json, there is the value "UniqueID". It's important to understand what this does. The ID has to be unique among all existing mod blocks, so it is impossible to have two different mod blocks that have the same UniqueID installed. When you place custom mod blocks in the game, the game basically just stores the UniqueID of the block you placed - so if you would uninstall one block with the ID 1, and install a different block with the ID 1, the texture of the blocks you placed in the game would change to that new block. Since you usually don't want that, it's important that a UniqueID is **never** allowed to change after a custom mod block has been created. Pick an ID once, and then stick with it for that block.

The ID can be any number between 0 and 2147483648. The best way for you to pick an ID is to let one be generated randomly by some random number generator - since there are a lot of available numbers, even if thousands of people do this, it's extremely unlikely that two people will generate the same ID. Google can generate random numbers for you, so that's the easiest way. Just open google, type

```
random number between 1 and 2147483648‬

```

and hit enter. Google will give you a nice number. Then copy that number to the "UniqueID:" field in the Properties.json, and never change it again. You can change all other things about the block (like the name, the recipe, the texture mode etc), just never change the UniqueID.

**Done!**

That's all! The custom block is ready to be used. Fire up the game, and you should see you custom block be listed in the Crafting Recipe overview now. If you craft the correct recipe, the blocks should glow green same like when you craft a "normal" recipe of the game, and if you throw it into the bucket, the correct amount of custom blocks should be added to your inventory, from where you can normally use them for building same like any other blocks :)