User:Umucraft/How to obtain technical blocks as an item - minecraft.fandom.com

Jump to navigation Jump to search
Treść tej podstrony pochodzi z artykułu „User:Umucraft/How to obtain technical blocks as an item” w domenie minecraft.fandom.com na licencji CC BY-NC-SA 3.0

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 net.minecraft.item.Item.

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

registerItemBlock(Blocks.PORTAL);

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

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

/give @p minecraft:portal

It should give you an item with numerical id #0090 and resource location minecraft:portal. 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 net.minecraft.client.renderer.RenderItem.

After write this to register portal ItemBlock in the renderer:

this.registerBlock(Blocks.PORTAL, "portal");

Define this model for item "portal" in <your mcp folder>\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 minecraft:portal. 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 <your mcp folder>\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.