Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

[Forge 1.8] How to Render Blocks in Inventory?


HassanS6000
 Share

Recommended Posts

Hi! I'm modding in Forge 1.8 and I was wondering how I'm supposed to render blocks in the inventory. I've made it so they render when placed, but when I try to render in Inventory, it says that my block is an Item, and the method

Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(YourItem, metadata, new ModelResourceLocation("modid:items_registered_name", "inventory"));

 

is only for items.

 

So how do I render a block, which is obviously NOT an item?

Link to comment
Share on other sites

this is quite simple:

For each block, there is a corresponding item which you can get as following:

 

Item itemYourBlock = GameRegistry.findItem(mod.MODID, "yourBlock");

 

After this, you can simply render you block with the function you already have :)

 

~Brickfix

Link to comment
Share on other sites

Hi

 

This site has some info on Block Rendering

http://greyminecraftcoder.blogspot.com.au/p/list-of-topics.html  (See the four topics on Blocks and BLock rendering)

and the one on items

http://greyminecraftcoder.blogspot.com.au/2014/12/item-rendering-18.html

 

There is also an example project showing blocks and items here-

https://github.com/TheGreyGhost/MinecraftByExample

(see example 1) https://github.com/TheGreyGhost/MinecraftByExample/tree/master/src/main/java/minecraftbyexample/mbe01_block_simple

 

The short answers are- yes, you need a JSON file for the item.  No, your items doesn't need its own texture, your item can use the block texture.  And you also need to do

Item itemBlockSimple = GameRegistry.findItem("minecraftbyexample", "mbe01_block_simple");
ModelResourceLocation itemModelResourceLocation = new ModelResourceLocation("minecraftbyexample:mbe01_block_simple", "inventory");
final int DEFAULT_ITEM_SUBTYPE = 0;
Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(itemBlockSimple, DEFAULT_ITEM_SUBTYPE, itemModelResourceLocation);

 

-TGG

 

Link to comment
Share on other sites

this is quite simple:

For each block, there is a corresponding item which you can get as following:

 

Item itemYourBlock = GameRegistry.findItem(mod.MODID, "yourBlock");

 

After this, you can simply render you block with the function you already have :)

 

~Brickfix

What...? Use

Item.getItemFromBlock(Block)

to get the corresponding Item.

Don't PM me with questions. They will be ignored! Make a thread on the appropriate board for support.

 

1.12 -> 1.13 primer by williewillus.

 

1.7.10 and older versions of Minecraft are no longer supported due to it's age! Update to the latest version for support.

 

http://www.howoldisminecraft1710.today/

Link to comment
Share on other sites

 

Item itemBlockSimple = GameRegistry.findItem("minecraftbyexample", "mbe01_block_simple");
ModelResourceLocation itemModelResourceLocation = new ModelResourceLocation("minecraftbyexample:mbe01_block_simple", "inventory");

 

 

Make sure you changed those lines to match your texture name and mod ID.

 

 

Maker of the Craft++ mod.

Link to comment
Share on other sites

Hi

 

You should register your items and blocks in FMLPreInitializationEvent , not FMLInitializationEvent.

 

The getItemModelMesher() stuff needs to come in FMLInitializationEvent, after you have registered the blocks and items.

 

Also just something I noticed - instances of your classes should always start with a lower case, otherwise it looks like they are classes, which is pretty confusing for anyone who reads your code

For example

SpartanBoots = new HaloArmor(HaloArmor, bootID, 3).setUnlocalizedName("SpartanBoots");  // should be spartanBoots

 

This resource is really good for learning how to format your code to make it easy for others to understand

http://google-styleguide.googlecode.com/svn/trunk/javaguide.html

 

-TGG

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.