Posted May 17, 20169 yr Started modding after a break and a bit confused. As I understand, the preferred way to load block models is through blockstate. Though, it's not clear what's the one for items. Which seem to not load any model data automagically based on their registry names. I found following variants: 1. Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register from BedrockMiner's tutorials 2. Use ModelBakery.registerItemVariants 3. Use ModelLoader.registerItemVariants (which looks like #2) Can anyone point to some mini-guide? Google shows too much info, and Forge docs are rather slim Thanks Sidenote: It'd be nice to have some common entrypoint for all Forge stuff, like root Forge class with methods/fields like gameRegistry , modelLoader etc.
May 17, 20169 yr I've written an explanation of the model loading process here. The summary at the end briefly explains how to load models and how to map them to blocks/items. This was written for 1.9, but it's fairly similar in 1.8.x. Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.
May 17, 20169 yr Author As I understand, it's possible to apply item model without any code, by just placing properly named JSON where model loader expects it? I've been trying to use this way, along with model loader way. Though I'm still getting missing texture, along with my item looking like block. So I'm definitely doing something wrong.
May 18, 20169 yr As I understand, it's possible to apply item model without any code, by just placing properly named JSON where model loader expects it? No. Minecraft will automatically load the model with the Item 's registry name if you don't call ModelBakery.registerItemVariants for it, but it won't use that model unless you tell it to. You must call ModelLoader.setCustomModelResourceLocation or ModelLoader.setCustomMeshDefinition to tell Minecraft which model to use for an Item . I've been trying to use this way, along with model loader way. Though I'm still getting missing texture, along with my item looking like block. So I'm definitely doing something wrong. There should be errors in the log telling you what went wrong. If you don't understand them, upload the FML log (logs/fml-client-latest.log) to Gist and link it here. Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.
May 18, 20169 yr Author No. Minecraft will automatically load the model with the Item 's registry name if you don't call ModelBakery.registerItemVariants for it, but it won't use that model unless you tell it to. You must call ModelLoader.setCustomModelResourceLocation or ModelLoader.setCustomMeshDefinition to tell Minecraft which model to use for an Item . I think that's the problem I'm facing. I was somehow thinking that MC will utilize model which it loaded automatically. A bit surprising, but nothing too hard. Thank you for your time.
May 18, 20169 yr Author Okie, so that wasn't that smooth for me. To be clear, I'm using Forge 1.8.9-11.15.1.1722 (latest stable AFAIR) Frankly speaking, the only way of attaching model to item which worked for me was Item item = WorldRift.instance.itemRiftWand; Minecraft.getMinecraft().getRenderItem().getItemModelMesher() .register(item, 0, new ModelResourceLocation(item.getRegistryName(), "inventory")); invoked in client proxy's init event specialization. Now, some details. 1. Resources structure + assets + worldrift + blockstates - rift.json // my block, not related + models + block - rift.json // my block's model, also not related + item - riftwand.json // my item model + lang - en_US.lang // just lang file + textures + block - rift.png // block texture, not related to my case + item - riftwand.png // item texture 2. models/item/riftwand.json { "parent":"builtin/generated", "textures": { "layer0": "worldrift:item/riftwand" }, "display": { "thirdperson": { "rotation": [ -90, 0, 0 ], "translation": [ 0, 1, -3 ], "scale": [ 0.55, 0.55, 0.55 ] }, "firstperson": { "rotation": [ 0, -135, 25 ], "translation": [ 0, 4, 2 ], "scale": [ 1.7, 1.7, 1.7 ] } } } Now, to my findings 1. Adding blockstates/riftwand.json without any Java-side code doesn't do any good. File text I used, just for reference { "variants": { "normal": { "model": "worldrift:rift" }, "inventory": { "model": "worldrift:rift" } } } 2. Attempt to load via Item wand = WorldRift.instance.itemRiftWand; ModelResourceLocation loc = new ModelResourceLocation(wand.getRegistryName(), "inventory"); ModelLoader.registerItemVariants(wand, loc); ModelLoader.setCustomModelResourceLocation(wand, 0, loc); also gives no result. I tried putting model name manually, using empty variant, putting this into both pre-init and init etc. If you ask what were the errors - I encountered either no errors at all or FileNotFound for blockstates/riftwand.json when loader apparently falled back to blockstates as thelast resort. Several mods I checked on Github also use getItemMesher approach. So I'm a bit lost at the end, with recommended ways failing.
May 18, 20169 yr ModelLoader.setCustomModelResourceLocation will call ModelBakery.registerItemVariants for you, so you don't have to call it yourself in this case. You also don't need to call it to load Item 's default model (the one with the Item 's registry name). Is your Item 's registry name worldrift:riftwand (with that exact capitalisation)? Could you please do the following to help me narrow down your issue? Remove all model registration code for the wand Call the following code from your client proxy in preInit Run Minecraft Upload the FML log to Gist and post it here Item wand = WorldRift.instance.itemRiftWand; ModelLoader.setCustomModelResourceLocation(wand, 0, new ModelResourceLocation(wand.getRegistryName(), "inventory")); Edit: Fixed the formatting. Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.
May 18, 20169 yr Author Okay, so now I feel myself dumb. First, my item's registry ID is really worldrift:riftwand , exactly this casing. The changes you suggested fixed the issue, so with only those two lines item is rendered Ok. Anyway, here's the Gist with log you asked: https://gist.github.com/target-san/3a4c8b118257a36fcbb5018741cd6d11
May 18, 20169 yr I'm glad you managed to get it working. Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.
May 18, 20169 yr Author Update. Seems that ModelLoader way doesn't work during init phase. Sorry, I kinda misguided you in opening post.
May 18, 20169 yr Seems that ModelLoader way doesn't work during init phase. That's correct. ModelLoader methods must be called in preInit. Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.
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.