Minecraft MOD Add Block resources [1.10.2/1.12.2]

TOP > Tutorial list > Minecraft MOD Add Block resources [1.10.2/1.12.2]


posted 9 May 2018

This time is a tutorial for adding Block resources in Minecraft JE.

The source of ChinjufuMod is released on GitHub. If you are interested please visit there.

 

1. Files relationship in Block resource

In the block resource, the following 3 files are mainly involved.

・.json file that decides the state of the block in the world
・.json file used for drawing as a block
・.png file used for drawing as a block

Taking a Diorite brick(block_bricks_dio_c) of ChinjufuMod as an example, 3 files make a relationship like the image.

Files relationship in Block resource

A resource and a class that designs the block are linked using RegistryName or UnlocalizedName. And .json file called by linking is .json file in the blockstates package.

When adding blocks, you add resources including up to ItemBlock. For that reason, the json file used for ItemBlock is also shown in the image.

 

2. Blockstate’s .json file that decides the state of the block

When placed in the world, the block can have the following state information (metadata value).

・The direction which the player was facing when the player placed the block
・Crop growth stage
・Contact with other blocks
・Number of times the block was right-clicked

By using blockstate’s .json file, you can make a difference block by calling the model according to the metadata value.

However, if you use metadata values, you need to decide what metadata values to use in the class that designs the block.

 

2-1. Blockstate of a block without difference

In the case of blocks that do not have differences, like vanilla’s Dirt, Stone and Diorite brick of ChinjufuMod (block_bricks_dio_c), it becomes the following source.

blockstates/block_brick_dio_c.json

Diorite brick of ChinjufuMod (block_bricks_dio_c)

For “variants” asking whether there is a difference, since there is no difference, I answer “normal”. Then I call “chinjufumod: block_brick_dio_c” as “model”.

 

2-2. Blockstate with state information (metadata value)

Next is a tutorial on using metadata values.

 

2-2-1. Block with directional differences

If there are differences depending on the direction, like vanilla’s Furnace, Torch and Dining chair_birch of ChinjufuMod (block_diningchair_b), it becomes the following source.

blockstates/block_diningchair_b.json

Dining chair_birch of ChinjufuMod (block_diningchair_b)

For “variants” asking whether there is a difference, I answer that there are 4 differences including “facing = north”. Then, I call “chinjufumod: block_dchair_b” as “model”, and use the “y”: 180 etc. to rotate the model according to the direction.

 

2-2-2. Block with stages of change

If there are stages of change, like vanilla’s Wheat, Redstone repeater and Cabbage of ChinjufuMod (block_vege_cabbage), it becomes the following source.

blockstates/block_vege_cabbage.json

Cabbage of ChinjufuMod (block_vege_cabbage)

For “variants” asking whether there is a difference, I answer that there are 8 differences including “age=0”. Then, I call “chinjufumod: block_vege_cabbage_ 0” etc. as “model” answering to each difference.

 

2-2-3. Contact with other blocks

If there are differences by contact with a block, like vanilla’s Stairs, Fence and Cafe table_birch of ChinjufuMod (block_cafetable_b), it becomes the following source.

blockstates/block_cafetable_b.json

Cafe table_birch of ChinjufuMod (block_cafetable_b)

For “variants” asking whether there is a difference, I answer that there are 16 differences including “back = false, forward = true, left = false, right = true”. Then, I call “model” according to each difference.

In the source of block_cafetable_b, it has judgment for the back, forward, left and right of the block, and it will answer a difference block according to judgment.

The order of the metadata values is in alphabetical order as back, forward, left, right.

 

2-2-4. Block combining multiple metadata values

For a block that combine multiple metadata values, like vanilla’s Redstone repeater and Panel_log oak of ChinjufuMod (block_wp_log_oak), it becomes the following source.

blockstates/block_wp_log_oak.json

Panel_log oak of ChinjufuMod (block_wp_log_oak)

For “variants” asking whether there is a difference, I answer that there are 12 differences including “facing=north,log=1”. Then, I call “model” according to each difference.

The order of the metadata values is in alphabetical order as facing, log.

 

3. Block’s .json file which decides the shape of the block

Blocks in Minecraft are made by combining one or several rectangular parallelepipeds. In specifying coordinates, it is possible to use numbers including decimal places.

Basically, rectangular parallelepipeds are placed within the range of [0.0, 0.0, 0.0] to [16.0, 16.0, 16.0]. Within this range, it is possible to easily specify the texture to paste.

range of [0.0, 0.0, 0.0] to [16.0, 16.0, 16.0]

However, if you specify the coordinates of which range of the image to use for textures to paste, you can also draw larger blocks. Specifically, it can be used from [-16.0, -16.0, -16.0] to [32.0, 32.0, 32.0].

from [-16.0, -16.0, -16.0] to [32.0, 32.0, 32.0]

 

3-1. Paste the same texture on all faces Cube

In the case of a cube in which the same texture is pasted on all faces, like vanilla’s Dirt, Stone and Diorite brick of ChinjufuMod (block_bricks_dio_c), it becomes the following source.

chinjufumod:block/block_brick_dio_c.json

Diorite brick of ChinjufuMod (block_bricks_dio_c)

“parent”: “block / cube_all” calls a model of a cube to paste the same texture on all the faces in the vanilla. In addition, “all”: “chinjufumod: blocks / stonebrick_dio” is instructing to paste stonebrick_dio.png on all faces.

 

3-2. Block texture changed by face

When changing the texture to be pasted by face, like vanilla’s Oak Wood, Crafting Table and Pillar_granite of ChinjufuMod (block_brick_gra_pil_c), it becomes the following source.

chinjufumod:block/block_brick_gra_pil_c.json

 chinjufumod:block/base_stone_pillar.json

Pillar_granite of ChinjufuMod (block_brick_gra_pil_c)

In block_brick_gra_pil_c.json, it call “base_stone_pillar.json” in ChinjufuMod by “parent”: “chinjufumod: block / base_stone_pillar”. In addition, I call stonepillar_top_gra.png as a texture named “top” and stonepillar_gra.png as a texture named “side”.

On the other hand, base_stone_pillar.json calls “parent”: “block / block” and decides the shape of the cube connecting [0, 0, 0] and [16, 16, 16]. In addition, I instruct texture corresponding to “#top” on the top and bottom, and instruct texture corresponding to “#side” on the side.

By the way, “cullface” is a source for omitting textures on the side hidden by adjacency with other blocks.

 

3-3. Special shape block

In the case of a special shape, like vanilla’s Fence, Hopper and Admiral chair of ChinjufuMod (block_admiralchair), it becomes the following source.

chinjufumod:block/block_admiralchair.json

Admiral chair of ChinjufuMod (block_admiralchair)

Admiral chair does not apply its shape to other blocks. Therefore, the description of the shape and specification of the texture are put together in one .json file.

After calling “parent”: “block/block”, I combine the leg (connecting [0, 0, 0] and [2, 6, 2]) and backrest (connecting [0,6,14] and [16,16,16]) etc. to create the shape of the chair.

Also, in the Admiral chair, there are places where the height such as “back_top” exceeds 16. In these places, by adding coordinates to the texture to use such as “north”: {“uv”: [0.0, 3.0, 16.0, 16.0], “texture”: “#top”}, avoid texture errors .

 

Summary

Although it became a long article this time, personally, I think that this is the basic story on the block resource. For a more detailed story, a explanation may be added in the class side tutorial.

When thinking about writing block shape .json file, it may be better to use a model editor such as Blockbench. It is possible to create models while combining rectangular parallelepipeds, and you can also output model data as .json files.

“may be” is because I am not good at using the model editor and have few opportunities to use it. When thinking about a complicated shape, I open the grid image and think on the plane.

the grid image and think on the plane.

・Trace of circular CHABUDAI’s consideration

Trace of circular CHABUDAI's consideration

・Trace of a tea stand

Trace of a tea stand


このチュートリアルは参考になりましたか? シェアはこちらをご利用ください。
Was this tutorial helpful? Please use here for market share.

当サイトは年間6,480円のサーバー代がかかるため、投げ銭をしてもらえると助かります。
This site costs 6,480 yen per year for server fee. It will be helpful if you make a donation.

Bitcoinで投げ銭をする Bitcoin donations

¥
Personal Info

Terms

Donation Total: ¥100

MONAで投げ銭をする MONA donations
MONAで投げ銭をする MONA donations. tipmonaとは?

コメントを残す

メールアドレスが公開されることはありません。

コメント

お名前

ウェブサイトURL

このサイトはスパムを低減するために Akismet を使っています。コメントデータの処理方法の詳細はこちらをご覧ください