Posted May 29, 201510 yr This code works perfectly: private static void load_texture(ItemCA item) { Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(item, 0, new ModelResourceLocation(item.getUnlocalizedName().substring(5), "inventory")); LogHelper.info("Loading model in '"+item.getUnlocalizedName().substring(5)+"'"); } However when I overload this method to handle items with metadata they're rendered as cubes (json model file not loading) private static void load_texture(ItemCA item, int metastart, int metaend) { for(int i=metastart;i<=metaend;i++) { Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(item, i, new ModelResourceLocation(item.getUnlocalizedName(new ItemStack(item, 1, i)).substring(5), "inventory")); LogHelper.info("Loading model in '" + item.getUnlocalizedName(new ItemStack(item, 1, i)).substring(5) + "' for metadata "+i); } } Since the first one is working, assets is loading properly etc. The part of log with all the "Loading model..." [17:09:49] [Client thread/INFO] [Coal Age]: Loading model in 'coalage:coal_piece' [17:09:49] [Client thread/INFO] [Coal Age]: Loading model in 'coalage:colored_coal_white' for metadata 0 [17:09:49] [Client thread/INFO] [Coal Age]: Loading model in 'coalage:colored_coal_orange' for metadata 1 [17:09:49] [Client thread/INFO] [Coal Age]: Loading model in 'coalage:colored_coal_magenta' for metadata 2 [17:09:49] [Client thread/INFO] [Coal Age]: Loading model in 'coalage:colored_coal_lightblue' for metadata 3 [17:09:49] [Client thread/INFO] [Coal Age]: Loading model in 'coalage:colored_coal_yellow' for metadata 4 [17:09:49] [Client thread/INFO] [Coal Age]: Loading model in 'coalage:colored_coal_lime' for metadata 5 [17:09:49] [Client thread/INFO] [Coal Age]: Loading model in 'coalage:colored_coal_pink' for metadata 6 [17:09:49] [Client thread/INFO] [Coal Age]: Loading model in 'coalage:colored_coal_gray' for metadata 7 [17:09:49] [Client thread/INFO] [Coal Age]: Loading model in 'coalage:colored_coal_lightgray' for metadata 8 [17:09:49] [Client thread/INFO] [Coal Age]: Loading model in 'coalage:colored_coal_cyan' for metadata 9 [17:09:49] [Client thread/INFO] [Coal Age]: Loading model in 'coalage:colored_coal_purple' for metadata 10 [17:09:49] [Client thread/INFO] [Coal Age]: Loading model in 'coalage:colored_coal_blue' for metadata 11 [17:09:49] [Client thread/INFO] [Coal Age]: Loading model in 'coalage:colored_coal_brown' for metadata 12 [17:09:49] [Client thread/INFO] [Coal Age]: Loading model in 'coalage:colored_coal_green' for metadata 13 [17:09:49] [Client thread/INFO] [Coal Age]: Loading model in 'coalage:colored_coal_red' for metadata 14 [17:09:49] [Client thread/INFO] [Coal Age]: Loading model in 'coalage:colored_coal_black' for metadata 15 I'd think that if "coalage:coal_piece" is OK, then "coalage:colored_coal_black" hould work, but it doesn't. And getUnlocalizedName method is overloaded and works as I want it to. That's proved by the log
May 29, 201510 yr Hi This link might be useful http://greyminecraftcoder.blogspot.com.au/2015/03/troubleshooting-block-and-item-rendering.html here in particular http://greyminecraftcoder.blogspot.com.au/2015/05/common-mistakes-with-item-models.html I think your problem is that you need ModelBakery. -TGG
May 29, 201510 yr You also need to register all of your item variants to ModelBakery.addVariantName(yourItem, String[]{variant1, variant2, etc.}). Each variant should be the model name qualified by your mod id, e.g. 'yourmodid:your_item_variant_1'. http://i.imgur.com/NdrFdld.png[/img]
May 29, 201510 yr Author The ModelBakery.addVariants works great However to load the models I had to use this method: for(int i=metastart;i<=metaend;i++) { Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(item, i, new ModelResourceLocation(item.getUnlocalizedName(new ItemStack(item, 1, i)).substring(5), "inventory")); } Because the one I fount to be said correct: Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(item, new ItemMeshDefinition() { public ModelResourceLocation getModelLocation(ItemStack stack) { return new ModelResourceLocation(item.getUnlocalizedName(stack).substring(5), "inventory"); } }); was being called all the time and made a giant mess in the log
May 30, 201510 yr The ModelBakery.addVariants works great However to load the models I had to use this method: for(int i=metastart;i<=metaend;i++) { Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(item, i, new ModelResourceLocation(item.getUnlocalizedName(new ItemStack(item, 1, i)).substring(5), "inventory")); } Because the one I fount to be said correct: Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(item, new ItemMeshDefinition() { public ModelResourceLocation getModelLocation(ItemStack stack) { return new ModelResourceLocation(item.getUnlocalizedName(stack).substring(5), "inventory"); } }); was being called all the time and made a giant mess in the log yeah, that's how it is supposed to work, it's a technique called a 'function object'. Every time minecraft wants to know what ModelResourceLocation to use for your itemstack, it calls the getModelLocation() you have given it. So if you put a println in there, it will print every time it's called, which is a lot. The solution is not to put a println in there. Or, adding every single variant (like you have done) works too, since there aren't very many. -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.