How to add a Custom Block

Minecraft'due south beliefs packs and resource packs allow you to create custom content for the game. Custom blocks are a groovy manner for creators to starting time calculation interactive content for Players. Through this tutorial, you lot will build a new block that volition be called canvas cake that has dissimilar textures and tin can be placed in the globe by a Player.

Image of Alex holding the completed custom block

In this tutorial you lot volition learn the following:

  • How to use JSON to define a new block.
  • How to assign textures to a new block.
  • Some of the behaviors and components that blocks can access.
  • What .lang is and how it's used for in-game text.

Requirements

It'due south recommended that the following be completed earlier beginning this tutorial:

  • Getting Started with Add together-On Evolution
  • Introduction To Resource Packs
  • Introduction To Beliefs Packs

Y'all volition likewise need the post-obit:

  • Download the Vanilla resource pack
  • A Minecraft World with Vacation Creator Features enabled.

Important

Holiday Creator Features incorporate experimental gameplay features. Equally with all experiments, you lot may see additions, removals, and changes in functionality in Minecraft versions without meaning advanced alert.

To learn more than about Experimental Features, please visit Experimental Features in Minecraft: Boulder Edition.

Setting up the Resources JSON File

Block entity definitions are handled differently in the resources pack. Blocks are stored in a single JSON file that volition contain definitions for each custom cake.

  1. Open your com.mojang folder.
  2. Double-click on the folder development_resource_packs to open it.
  3. Open up the My_RESOURCE_Pack folder. If you do not take this folder, please refer to the tutorials in the Requirements section of this document.
  4. Inside the My_RESOURCE_Pack binder, create a text document and name it blocks.json.
  5. Double-click on blocks.json to open information technology in a text editor.

blocks.json

The blocks.json file has a similar set up to the manifest.json file and has requirements that need to be met in order for it to work correctly. The sheet block volition employ a custom texture for four of the sides, and a unlike texture for the top and bottom that y'all are going to bring over from the Vanilla Resources Pack.

  1. Re-create the post-obit text and paste it into your blocks.json file.

                      { "format_version": "1.sixteen.0",   "helloworld:canvasblock": {     "textures": {         "upwards": "log_top",         "downwardly": "log_top",         "side": "canvasblock"         },     "sound":"grass"     } }                                  
  2. Save the file.

Textures and Sub-textures

Every bit shown in the JSON code, the canvas block is using 2 textures. The superlative and lesser are using the existing log_top.png while the other sides are using a custom texture. Blocks can likewise be assigned a single texture to cover every side of a block with the same texture.

"textures": "canvasblock"

Textures can be broken downwards into sub-texture groups. upwardly, downwardly, and side are all sub-textures that allow a creator to define which confront gets a sure texture. side can as well be cleaved down into primal directions north, east, south , and westward.

terrain_texture.json

With the block defined in the blocks.json file, the side by side step is to associate the texture names with a texture file path. This is washed in a terrain_texture.json file.

  1. In File Explorer, navigate to the My_RESOURCE_Pack binder and open the textures binder.

  2. Inside the textures folder, create a text certificate and proper name it terrain_texture.json.

  3. Double-click on terrain_texture.json to open up it in a text editor.

  4. Copy and paste the following code into terrain_texture.json:

                      {   "resource_pack_name": "My_BEHAVIOR_Pack",   "texture_name": "atlas.terrain",   "padding": 8,   "num_mip_levels": 4,   "texture_data": {     "canvasblock": {       "textures": "textures/blocks/canvasblock"     },     "log_top":{       "textures": "textures/blocks/log_top"     }   } }                                  
  5. Salve the file.

The Canvas Texture

A PNG file that can be downloaded and used in place of a custom texture made in a photo editor

The canvas block texture will need to be created and placed in the Resources Pack.

Note

The paradigm higher up has been provided for the canvasblock.png but feel free to use a different texture.

If you are using the one provided:

  1. Download the file to your estimator.
  2. Place canvasblock.png in the My_RESOURCE_Pack/textures/blocks folder.

If you are creating a custom one:

  1. Check that the Width and Summit to are fix xvi each.
  2. Save the file as canvasblock.png in the My_RESOURCE_Pack/textures/blocks binder.

Calculation the log_top.png

The log_top.png file volition also need to be added to the texture folder in the behavior pack because the terrain_texture.json file will look for both textures in the My_RESOURCE_Pack folder.

  1. Navigate to the Vanilla_Resource_Pack\textures\blocks folder and copy log_top.png.
  2. Navigate to My_RESOURCE_Pack/textures/blocks and paste a copy of log_top.png.

Setting up the Beliefs JSON file

With the piece of work in the resource pack done, the behavior pack volition need to be updated with the canvas cake's components.

  1. In File Explorer, navigate to the folder My_BEHAVIOR_Pack, located in the development_behavior_packs folder.
  2. Inside the My_BEHAVIOR_Pack folder, create a folder and name information technology blocks.
  3. Double-click on blocks to open the binder.
  4. Inside the blocks folder, create a text document and proper noun it canvasblock.json.
  5. Double-click on canvasblock.json to open information technology in a text editor.

Description

In the file, yous will need to define what the block is, similar to the manifest.json file.

  1. Re-create and paste the post-obit code into your canvasblock.json file:
              {     "format_version": "one.sixteen.0",     "minecraft:block": {         "description": {             "identifier": "helloworld:canvasblock",             "is_experimental": false,             "register_to_creative_menu": true         },         "components": {             "minecraft:destroy_time": 1,             "minecraft:explosion_resistance": 5,             "minecraft:friction": 0.half-dozen,             "minecraft:flammable": {                 "flame_odds": 0,                 "burn_odds": 0             },             "minecraft:map_color": "#FFFFFF",             "minecraft:block_light_absorption": 0,             "minecraft:block_light_emission": 0.250         }     } }                          
  1. Save the file.

The identifier that was used in the resource pack is defined here. The block is also set up to appear in the creative menu and is not set equally an experimental piece of content.

  • destroy_time is how many actor hits does it take to destroy this block.
  • explosion_resistance is how resistent the block is to explosions. Higher values hateful the block is less likely to intermission.
  • friction is used to drive player and entity speeds while stepping on this cake. Wood and dirt are gear up to a friction of 0.6 while ice is set to 0.1.
  • flammable is used to comprise properties on how the block handles fire events.
    • flame_odds is how likely the block is to catch fire.
    • burn_odds is how likely the block is to be destroyed when on burn.
  • map_color is the colour, in hex format, that is used past the map in order to symbolize the block.
  • block_light_absorption is how much light the block absorbs. Value uses a range of 0 to 1 equally an input.
  • block_light_emission is how much light the block produces. Value uses a range of 0 to 1 every bit an input.

Setting the block name with .lang

Now that both of the packs are set up and completed, the terminal affair is to add together the name of the block using a .lang file.

  1. In File Explorer, navigate to the folder My_RESOURCE_Pack.
  2. Within the My_RESOURCE_Pack folder, create a folder and proper name it texts.
  3. Double-click on texts to open up the folder.
  4. Inside the texts binder, create a new text document and name it en_US.lang.
  5. Double-click on en_US.lang to open it in a text editor.

.lang

.lang is a file type that Minecraft uses to provide in-game text for different languages for concepts within Add-Ons. .lang files are used as a convenient way to organize all custom text within an Improver in a single location and for localizing creator content.

  1. Copy and paste the following into en_US.lang: tile.helloworld:canvasblock.name=Canvas Block
  2. Relieve and close the file.

This code sets the name of the block to exist Sheet Cake in the game.

Testing the cake

With the canvas block defined in both the behavior pack and resource pack, y'all can at present test information technology in-game.

Important

You will demand to have a Minecraft world where cheats are enabled in order to add the block to your inventory.

You will also demand to have both My_RESOURCE_Pack and My_BEHAVIOR_Pack enabled in the world so you can get access to the canvas cake.

  1. Open up the chat dialogue box (press T or Enter on Windows 10 Os).
  2. Type the following command: /give @p helloworld:canvasblock

What'due south Adjacent?

With your outset custom cake completed, it is recommended to view the Cake JSON reference documentation to learn more than well-nigh how blocks are defined within Minecraft.