Minecraft MOD Add Custom Blocks for 1.12.2

TOP > Tutorial list > Minecraft MOD Add Custom Blocks for 1.12.2


updated 2 May 2018 – posted 24 April 2018

This time is MOD production tutorial for Minecraft JE version 1.12.2.

About the method of adding blocks, I will explain while watching the source of Chinjufu MOD.

There are points to note about the source posted in the link in the article. In order to avoid confusion of explanation, I deleted unnecessary sources.

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

 

1. Case of adding a block

First of all, let’s take a tutorial about adding a custom block. I use ‘Empty box’ of Chinjufu MOD as an example.

 

1-1. Image of classes relationship

In ChinjufuMod[1.12.2], the classes for adding blocks are divided for each role. Each classes make relationship like the image like by using reference.

Unlike items, blocks have characteristics such as material and sound effects. Therefore, it always have a class (= design drawing of block).

Image of classes relationship 1.12.2

Well, in 1.10.2, I created a relationship to put together everything in ChinjufuMod.java which instances of MOD. However, in 1.12.2, blocks are registered by using RegisterEvent. For that reason, I am changing to a form like the image above.

Also, the 1.12.2 recipes move to resources. RecipeHandler.java and CraftingChinjufuMod.java, which you do not use much, are dotted lines.

There is a point to notice here. The Minecraft block has two aspects, Block and ItemBlock. So, you need to register for each.。

Aspect as Block As a block to be placed in the world for building etc.
Register using ‘RegistryEvent.Register<Block>’
Aspect as ItemBlock As an item to use for drop and inventory
Register using ‘RegistryEvent.Register<Item>’

 

1-2. 11 sheets is a results of division for each role

The roles of each class are as follows.

ChinjufuMod.java Create an instance of Mod
Reference.java Management of frequently referenced values
ProxyInterface.java Promises methods to handle in CommonProxy
CommonProxy.java Processing on server
ClientProxy.java Processing on client
RegistrationHandler.java
※The link is described in 1-3
Register Blocks and ItemBlocks
ChinjufuModBlocks.java Manage registration of Blocks and ItemBlocks.
BlockEmptyBox.java Design of individual block
ChinjufuModItems.java Used for registration of ItemBlocks
RecipeHandler.java Manage recipes ※1.12.2, you don’t use much
CraftingChinjufuMod.java Design of individual recipe ※1.12.2, you don’t use much

First time Minecraft MOD producer may think that “Do you use 11 sheets?”. Also, if you want to do so, it is also possible to combine it into one sheet.

However, if you think about adding some blocks, it is easier to divide the class for each role.

 

1-3. Actual classes relationship and link to each source

In ChinjufuMod, to make it easier to manage the source, I am writing like the image.

The source is on the links of the image map. Recommend maximize the window.

Add a custom block 1.12.2

Reference.java ChinjufuMod.java ProxyInterface CommonProxy.java ClientProxy.java, RegistrationHandler RecipeHandler.java CraftingChinjufuMod.java ChinjufuModBlocks.java, RegistrationHandler ChinjufuModItems.java, RegistrationHandler BlockEmptyBox.java

To add an explanation, I am doing these things. About the inner class, I think that it is easier to understand if you look at the source that posted on the link.

・Partitioned RegistrationHandler.java handling RegisterEvent.
・The part that registers blocks is the inner class of ChinjufuModBlocks.java.
・The part that registers block rendering is the inner class of ClientProxy.java.
・Register ItemBlock with inner class of ChinjufuModItems.java.

In ItemBlock registration, I use ‘RegistryEvent.Register<Item>’. For that reason, I register ItemBlock using RegistrationHandler.java which is an inner class of ChinjufuModItems.java (=manage items registration).

 

2. Case of adding some blocks

Next, there is a tutorial when there are multiple blocks to be added.

From the state added ‘Empty box’ of Chinjufu MOD, I will continue to add the ‘Steel Block’ of Chinjufu MOD.

 

2-1. Classes relationship and link to each source

When you add some blocks, the relationship of the classes looks like the image in ChinjufuMod[1.12.2].

The source is on the links of the image map. Recommend maximize the window.

Case of adding some blocks 1.12.2

Reference.java ChinjufuMod.java ProxyInterface CommonProxy.java ClientProxy.java, RegistrationHandler RecipeHandler.java CraftingChinjufuMod.java ChinjufuModBlocks.java, RegistrationHandler ChinjufuModItems.java, RegistrationHandler BlockEmptyBox.java BlockSteelBlock.java

If you divide the class for each role in advance, only the 2 classes that changed red when new blocks are added. You do not have to touch others.

On the other hand, If you do not use references, you will need to write duplicate code in each classes.

 

Summary

If you do a test after the tutorial so far, it should be like a image.

Test of add custom blocks 1.12.2

In 1.12.2 recipes move to resources. However, if you allocate it to the creative tab of vanilla, you can easily check whether you can register the block.


このチュートリアルは参考になりましたか? シェアはこちらをご利用ください。
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 を使っています。コメントデータの処理方法の詳細はこちらをご覧ください