Posted December 11, 20177 yr So I have an item registered in the game, and have a class ItemRenderRegister to register the item to a modelresource location via the following code: Spoiler public class ItemRenderRegister { public static void registerItemRenderer() { Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(ModItems.oldTome, 0, new ModelResourceLocation("ds:oldtome", "inventory")); } the method is called in the client proxy but I can't wrap my head around how to use the ModelResourceLocation. I'm getting no errors about a missing json file, the item just simply has not model or texture, which makes it very hard to debug. Edited December 12, 20177 yr by GooberGunter
December 11, 20177 yr I'm no expert, I have just posted my own problem, but I would suggest checking your directory eg: make sure there is an assets folder, make sure the .json is valid etc, take my advice with a grrain of salt though as i said I'm no expert
December 11, 20177 yr Author There is a Json and it’s in the right directory, ill double check when I get back, but I’m to too sure about it’s validity, maybe they changed the json files in 1.12.2 again.
December 11, 20177 yr Problematic Code #2 Edited December 12, 20177 yr by Matryoshika Also previously known as eAndPi. "Pi, is there a station coming up where we can board your train of thought?" -Kronnn Published Mods: Underworld Handy links: Vic_'s Forge events Own WIP Tutorials.
December 12, 20177 yr Author Fantastic. classic me not looking in the right places . Thanks Edited December 12, 20177 yr by GooberGunter
December 12, 20177 yr Author Quick Question, what should the model path look like modid:filename or modid:item//filename. Or modid:models\\item\\filename. Edited December 12, 20177 yr by GooberGunter
December 12, 20177 yr Author ModelLoader.setCustomModelResourceLocation(ModItems.oldTome, 0, new ModelResourceLocation("ds:models//item//old_tome.json", "inventory")); still not working Spoiler { "parent": "builtin/generated", "textures": { "layer0": "ds:items/old_tome" } } And I'm not any errors in the log about the texture location so I know that's right. It's just this part. And I also had a problem where I made two instances of the item, registering one and registering the render of the other, which I have fixed. Edited December 12, 20177 yr by GooberGunter
December 12, 20177 yr You should use items/blocks getRegistryName() as the first parameter. First parameter should not contain any extensions (".json") nor any file-separators ("/"). All of that is automagically done "behind the curtains" for you. Also previously known as eAndPi. "Pi, is there a station coming up where we can board your train of thought?" -Kronnn Published Mods: Underworld Handy links: Vic_'s Forge events Own WIP Tutorials.
December 12, 20177 yr Author That was suggested in the documentation but i didn't see it in the source code, but I fixed it now. I also added the first parameter, but it's still not showing up ModelLoader.setCustomModelResourceLocation(ModItems.oldTome, 0, new ModelResourceLocation(ModItems.oldTome.getRegistryName(), "ds:old_tome")); Am i supposed to register the render or is the model loader enough? Here is all the code involving the item: ModItems: Spoiler package com.GooberGunter.DivineSorcery.common.items; import java.rmi.registry.Registry; import com.GooberGunter.DivineSorcery.DSReferences; import com.GooberGunter.DivineSorcery.common.utils.Util; import net.minecraft.client.renderer.ItemRenderer; import net.minecraft.item.Item; import net.minecraftforge.event.RegistryEvent; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; public final class ModItems { public static Item oldTome = new ItemOldTome("old_tome"); @Mod.EventBusSubscriber public static class ItemRegister{ @SubscribeEvent public static void registerItem(RegistryEvent.Register<Item> e) { e.getRegistry().register(oldTome); Util.logger.info("ITEMS REGISTERED"); }//Items MUST MUST MUST MUST MUST BE REGISTERED IN STATIC FIELDS } } ItemRegisterRender: Spoiler package com.GooberGunter.DivineSorcery.client.render.items; import java.io.FileNotFoundException; import java.io.IOException; import com.GooberGunter.DivineSorcery.DSReferences; import com.GooberGunter.DivineSorcery.common.items.ModItems; import com.GooberGunter.DivineSorcery.common.utils.Util; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.block.model.ModelBakery; import net.minecraft.client.renderer.block.model.ModelResourceLocation; import net.minecraftforge.client.event.ModelRegistryEvent; import net.minecraftforge.client.model.ModelLoader; public class ItemRenderRegister { public static void registerItemRenderer() { ModelLoader.setCustomModelResourceLocation(ModItems.oldTome, 0, new ModelResourceLocation(ModItems.oldTome.getRegistryName(), "ds:old_tome")); Util.logger.info("Item Renders Registered"); } } Edited December 12, 20177 yr by GooberGunter
December 12, 20177 yr ... The second parameter is the variant of which you want to use... Unless otherwise specified in the BlockState file, there is only "inventory" for items, but blocks also have "normal" (placed)... The Item's RegistryName (which comes from getRegistryName()) should already equal "ds:old_tome", IF you used setRegistryName("old_tome") in the item's constructor... You don't need to worry about that... On a tangent however, modid's are recommended to never be shortened or otherwise altered from the original "name". I don't know what "ds" stands for, but for example, what if I made a mod called "Deep Storage" and also used "ds" as my modid? The longer a modid is, the probability of another mod having the same name exponentially becomes smaller. You also need to actually have this code RUN during the ModelRegistryEvent... You can do this very simply by annotating your client-proxy with @Mod.EventBusSubscriber and moving your registerItemRenderer method to said client-proxy. Your registerItemRenderer() also needs to become registerItemRenderer(ModelRegistryEvent event), so that the method can be picked up by the scanner, and called when the ModelRegistryEvent is fired, which then will run the code. Edited December 12, 20177 yr by Matryoshika Also previously known as eAndPi. "Pi, is there a station coming up where we can board your train of thought?" -Kronnn Published Mods: Underworld Handy links: Vic_'s Forge events Own WIP Tutorials.
December 12, 20177 yr Author Thanks a lot for the tips. Man, it seems like everything was replaced with annotations So to be clear, the render register no longer goes in the init? What are the initialization methods for? Now I'm getting a file not found exception, I've been waiting for one. I have a lead. Edit: classic blockstate, I fixed the chain and now I have the item model json, the blockstate json, and the texture. Everything works fine now Do recipes, world generators, and entities still initialize the same or are they events too? Edited December 12, 20177 yr by GooberGunter
December 12, 20177 yr 2 hours ago, GooberGunter said: Do recipes, world generators, and entities still initialize the same or are they events too? Recipes and entities are managed by registries, so register them in RegistryEvent.Register<IRecipe> and RegistryEvent.Register<EntityEntry> respectively. Use EntityEntryBuilder to create the EntityEntry. World Generators aren't managed by a registry and there's no dedicated event to register them, so do it in preInit/init/postInit. 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.