Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

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?

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

  • Author

Tried it, didn't work. Do I have to create another JSON File for an Item version of the block? and also create a texture for one?

 

 

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

 

Hi

What are your symptoms?

 

i.e. what does the item look like in your inventory, and what error message(s) do you get in the console?

 

-TGG

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/

  • Author

Tried your method larsgerrits, didn't work either.  :-\

 

No error messages, I'm just getting the error texture but when placed the texture works. Just not in inventory.

 

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.

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

 

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
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.