User:Umucraft/How to obtain technical blocks as an item

This is a tutorial that shows how to register and obtain technical blocks as an item (Java Edition exclusive) This tutorial is based on 1.12.2. The versions 1.13 and onwards uses a completely different system to define items.

At first, you have to set up your environment. You can download MCP from this link: http://www.modcoderpack.com/

After you downloaded, run decompile.bat for decompliation and deobfuscation of Minecraft. Wait it to finish.

Now, decompiled code is outputted in "src" folder. Find.

After you found the class, open with a text editor and write this to register nether portal block (to the registerItems section):

!! Important: Do not forget to run recompile.bat to apply your changes !!

Run startclient.bat to start the modified client and try this command:

It should give you an item with numerical id  and resource location. It has initially missing texture. Try to place. It should place a nether portal block tilted to X axis.

Let's solve missing texture problem. Firstly, find.

After write this to register portal ItemBlock in the renderer:

Define this model for item "portal" in \bin\minecraft\assets\minecraft\models\item (if the directory does not exist, create it manually):

{   "parent": "item/generated", "textures": { "layer0": "blocks/portal" } }

Try again to obtain. Now it should have the texture and animation of nether portal block.

If you want to use this mod outside the MCP environment, run reobfuscate.bat in order to recompile and reobfuscate the modded classes. Then go to the \reobf\minecraft and select all classes and compress they in a .zip folder. Now the mod is ready!

For the model(s), create a resource pack which contains user-defined model(s) for manually-registered technical block ItemBlocks (or block items).

You can register other technical blocks with this method. For example, if you intend to register stationary water ItemBlock, the differences are the block registry key, resource location and texture. In this case, registry key is Blocks.WATER, resource location is minecraft:item/water for assets and minecraft:water for obtaining, texture is minecraft:blocks/water_still.

If you have any kind of problem (such as bugs, crashes etc.) with this tutorial, you can write in my user talk page.