Show Minecraft's behavior packs and resource packs allow you to create custom content for the game. Custom blocks are a great way for creators to start adding interactive content for Players. Through this tutorial, you will build a new block that will be called canvas block that has different textures and can be placed in the world by a Player.
In this tutorial you will learn the following:
It’s recommended that the following be completed before beginning this tutorial: You will also need the following:
Important Holiday Creator Features contain experimental gameplay features. As with all experiments, you may see additions, removals, and changes in functionality in Minecraft versions without significant advanced warning. To learn more about Experimental Features, please visit Experimental Features in Minecraft: Bedrock Edition. Setting up the Resource JSON FileBlock entity definitions are handled differently in the resource pack. Blocks are stored in a single JSON file that will contain definitions for each custom block.
blocks.jsonThe 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 canvas block will use a custom texture for four of the sides, and a different texture for the top and bottom that you are going to bring over from the Vanilla Resource Pack.
Textures and Sub-texturesAs shown in the JSON code, the canvas block is using two textures. The top and bottom are using the existing log_top.png while the other sides are using a custom texture. Blocks can also be assigned a single texture to cover every side of a block with the same texture. "textures": "canvasblock" Textures can be broken down into sub-texture groups. up, down, and side are all sub-textures that allow a creator to define which face gets a certain texture. side can also be broken down into cardinal directions north, east, south , and west. terrain_texture.jsonWith the block defined in the blocks.json file, the next step is to associate the texture names with a texture file path. This is done in a terrain_texture.json file.
The Canvas TextureThe canvas block texture will need to be created and placed in the Resource Pack.
Note The image above has been provided for the canvasblock.png but feel free to use a different texture. If you are using the one provided:
If you are creating a custom one:
Adding the log_top.pngThe log_top.png file will 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.
Setting up the Behavior JSON fileWith the work in the resource pack done, the behavior pack will need to be updated with the canvas block's components.
DescriptionIn the file, you will need to define what the block is, similar to the manifest.json file.
The identifier that was used in the resource pack is defined here. The block is also set to appear in the creative menu and is not set as an experimental piece of content.
Setting the block name with .langNow that both of the packs are set up and completed, the last thing is to add the name of the block using a .lang file.
.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 Add-On in a single location and for localizing creator content.
This code sets the name of the block to be Canvas Block in the game. Testing the blockWith the canvas block defined in both the behavior pack and resource pack, you can now test it in-game.
Important You will need to have a Minecraft world where cheats are enabled in order to add the block to your inventory. You will also need to have both My_RESOURCE_Pack and My_BEHAVIOR_Pack enabled in the world so you can get access to the canvas block.
What's Next?With your first custom block completed, it is recommended to view the Block JSON reference documentation to learn more about how blocks are defined within Minecraft. |