Custom block behavior definition

is pretty straight-forward in it's whole. [Located in bhv/blocks/blockname.json] Note that custom blocks will not show up in creative inventory as of 1.16.0.
Note: you can find the custom blocks documentation on https://bedrock.dev/r/Blocks.

  • "identifier" under "description" is already familiar to us;

"components":

  • "minecraft:loot" defines a loot table path which will define what the block will drop. We'll look into loot tables in the next chapter.

  • "minecraft:destroy_time" defines how long the player will need to punch the block until it breaks. Currently it isn't possible to set different destroy times for different tools;

  • "minecraft:explosion_resistance": the higher the value, the lower the chance that the block will be destroyed by an explosion;

  • "minecraft:friction" defines how much friction the block has. For example, Soul and has a high value for friction and thus it slows players down. Ice has a lower friction value, and thus it has the effect of being slippery.

  • "minecraft:flammable":"flame_odds": how likely the block is to catch fire;"burn_odds": how likely the block is to be destroyed by fire;

  • "minecraft:map_color" has the hex code of color that will be displayed on a minecraft Map to symbolize this block. #FFFFFF means white. You can get hex codes for other colors here.

  • "minecraft:block_light_emission" defines the light level the block will output.

Let's create some more blocks in bhv/blocks. I created these for four for the tutorials' sake:

  • Filename: blocky.json; Identifier: tut:blocky;

  • Filename: sapp_log.json; Identifier: tut:sapp_log;

  • Filename: compass_block.json; Identifier: tut:compass_block;

  • Filename: flashing.json; Identifier: tut:flashing;

You can play around with changing the component values for each of these. Now let's move over to the resource definition.

Custom block resource definition;

Unlike items(res/items/itemname.json), custom blocks rare defined in a single file: res/blocks.json.

As you can see, every block's identifier is applied with textures and step sounds. All of these blocks have a different type of textures, let's look through them.

  • "tut:blocky" has "textures" set to the texture shortname "blocky". We'll define it in a file similiar to res/textures/item_texture.json, res/textures/terrain_texture.json later.

  • "tut:sapp_log"'s "textures" are broken up in 3 parts: "up"(for the upper face of the block), "down"(for the bottom face of the block), and "side"(for the remaining four faces). Each one of these has a texture shortname applied.

  • "tut:compass_block"'s "textures" are broken up in even more sub-textures. Instead of "side"s, we have a different texture shortname set for the "north" side, the "south" side, the "west" side and the "east" side.

  • And, lastly, "tut_flashing" simply has "flashing" defined in the same way as "tut_blocky",

These "gorgeous" textures are the ones I'm going to use for my example blocks. The first three are located in res/textures/blocks/ and the last 6 are located in /res/textures/blocks/compass_block - they show North, South, etc.

Left to right: blocky.png, sapp_log_side.png, side_block_top.png, sb_up.png, sb_down.png, sb_north.png, sb_south.png, sb_west.png, sb_east.png

All textures need to be defines a shortname, (and we'll do it the same way as we defined item texture shortnames in res/textures/item_texture.json), but this time in res/textures/terrain_texture.json

The only difference from item_textures.json is that "atlas.items" is now changed to "atlas.terrain".

  • "padding" and "num_mip_leavels" mean the quality of how the texture is displayed, especially noticeable on higher resolution textures.. If it's too low, the performance will be better, but the textures will appear glitchy from further distances.

Next, all our texture shortnames have been defined. These shortnames were already used in res/blocks.json, as you might remember. If you load the game now, you'll be able to see the 3 new custom blocks you just added, with all the texture functionality :)

But, we still have to define the tut:flashing's texture(third from the left), which is currently undefined. That's why it appears as purple-and-black tiled texture right now.

Flipbook texture for blocks definition;

As you might have already guessed, flipbook texture shortnames are defined in a different place then res/textures/terrain_texture.json. Let's create another file, res/textures/flipbook_textures.json.

  • "flipbbok_texture" is the path to your texture file, which is named "flashing_flipbook" in this scenario.

  • "atlas_tile" is basically the shortname definition. As you know, we already applied "flashing" texture shortname to the tut:flashing block in res/blocks.json.

  • "ticks_per_frame" defines how quickly the different textures will fade into the block, in other words the speed of the animation.

A flipbook texture file is done like this:

  • The image width is 16;

  • Image height is 16*3, as we have three different block textures to fade. If you wanted a flipbook with 12 different textures, the height would be 16*12. Done! All of our blocks work perfectly.

And, finally, let's define our block's names in /res/texts/en_US.lang like we did with items, somewhatlike this:

tile.tut:blocky.name=Blocky Block

tile.tut:sapp_log.name=Sapphire Wood

tile.tut:compass_block.name=A compass in block-form

tile.tut:flashing.name=Block of Flashing Matter


Your progress so far:

What you've done:

  • Learned about custom block behavior components;

  • Created a custom block with simple textures;

  • Created a custom block with side- and face-relying textures;

  • Created a custom block with flipbook textures;

What are you to do next:

  • Create custom Loot Tables for your blocks and entities;

  • Create custom crafting recipes;

  • Create custom Spawn Rules for entities;