Posted January 22, 201510 yr 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?
January 22, 201510 yr 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
January 23, 201510 yr 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?
January 23, 201510 yr 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
January 23, 201510 yr Author Still not working? My code is on GitHub: https://github.com/hsyyid/HaloMod/tree/master/forge-1.8-11.14.0.1290-1.8-src/src/main Is something wrong?
January 23, 201510 yr 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
January 23, 201510 yr 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/
January 23, 201510 yr 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.
January 24, 201510 yr 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.
January 24, 201510 yr 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
January 24, 201510 yr @TGG I changed it to follow what you said, AND IT WORKED! THX SO MUCH No worries, you're welcome
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.