Elix_x Posted May 4, 2016 Posted May 4, 2016 Good day everybody. I stumbled upon a problem today: why must we register models in pre init? Due to how my code works, i cannot register them in pre init. And if i register them in init, they don't work. I have a structure of dynamicaly generated items, depending on configuration and installed mods (including ones that use API to add different types of tool). Any mod can provide tool provider in pre-init and materials are loaded from jsons. Then in init, item for each tool for each material is generated and registered. (Up to this point, everything works). But when i try to register models in init, they don't work. If i move all item registries, and models in pre init, they work... But then nobody can use API, because it is setup and used entirely in pre init. So, why registering item models in init does not work? And what should i do? Note: while i can move materials from item instance to NBT, i cannot move tool types to NBT, as each tool may have different possible usage, thus different classes are needed. Thanks for help! If you have any questions - just ask! Quote Check out my mods: BTAM Armor sets Avoid Exploding Creepers Tools compressor Anti Id Conflict Key bindings overhaul Colourfull blocks Invisi Zones
UberAffe Posted May 4, 2016 Posted May 4, 2016 I have something similar to this mostly working but the process is somewhat convoluted. You can look at my code here. You can see most of it in common/draftcore/..., helpers/..., api/ I can try to come up with a path for you to follow to help you understand what is going on. Edit: this is more or less the path you can follow for looking through the code: *helpers/CommonProxy #preInit, #registerLuxin, #registerCores, #registerParts, #registerItems They lead to my registries in the API for other mods to use, a good practice is to use your own api's to accomplish create things. If something can't be done with your api then expand it so it can be done. *helpers/ClientProxy #init, you can see me registering my models here *client/itemrenderers/DraftableModelLoader you will want to use something like this *client/itemrenderers/DraftableModel yours should be similar to this *client/itemrenderers/DraftableBakedModel #Quads yours you should be able to almost copy from the default one *client/itemrenderers/DraftableOverrideList #handleItemState is where you can parse nbt info Quote Current Project: Armerger Planned mods: Light Drafter | Ore Swords Looking for help getting a mod off the ground? Coding | Textures
Elix_x Posted May 4, 2016 Author Posted May 4, 2016 I have something similar to this mostly working but the process is somewhat convoluted. You can look at my code here. You can see most of it in common/draftcore/..., helpers/..., api/ I can try to come up with a path for you to follow to help you understand what is going on. Edit: this is more or less the path you can follow for looking through the code: *helpers/CommonProxy #preInit, #registerLuxin, #registerCores, #registerParts, #registerItems They lead to my registries in the API for other mods to use, a good practice is to use your own api's to accomplish create things. If something can't be done with your api then expand it so it can be done. *helpers/ClientProxy #init, you can see me registering my models here *client/itemrenderers/DraftableModelLoader you will want to use something like this *client/itemrenderers/DraftableModel yours should be similar to this *client/itemrenderers/DraftableBakedModel #Quads yours you should be able to almost copy from the default one *client/itemrenderers/DraftableOverrideList #handleItemState is where you can parse nbt info Thanks, i'll take a look at that. One thing though: my models are in jsons (because vanilla is enough). Quote Check out my mods: BTAM Armor sets Avoid Exploding Creepers Tools compressor Anti Id Conflict Key bindings overhaul Colourfull blocks Invisi Zones
UberAffe Posted May 4, 2016 Posted May 4, 2016 If you models are already in json my process might be too granular for your needs, I am generating the quads from code. Quote Current Project: Armerger Planned mods: Light Drafter | Ore Swords Looking for help getting a mod off the ground? Coding | Textures
Elix_x Posted May 5, 2016 Author Posted May 5, 2016 I will just say that adding Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(item, 0, def); fixed everything (before i was using only ModelLoader.setCustomModelResourceLocation(item, 0, def); ). Now models work in init correctly. Thanks anyways! Quote Check out my mods: BTAM Armor sets Avoid Exploding Creepers Tools compressor Anti Id Conflict Key bindings overhaul Colourfull blocks Invisi Zones
Notunknown Posted May 5, 2016 Posted May 5, 2016 You should not need Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(item, 0, def) . What is your code for ModelLoader.setCustomModelResourceLocation(item, 0, def) ? Quote
Elix_x Posted May 5, 2016 Author Posted May 5, 2016 You should not need Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(item, 0, def) . What is your code for ModelLoader.setCustomModelResourceLocation(item, 0, def) ? public void init(FMLInitializationEvent event){ MinecraftForge.EVENT_BUS.register(new LastRenderWorldEvent()); for(ColoringToolProvider provider : ColoringToolsManager.getProviders()){ ModelResourceLocation def = provider.getDefaultModel(); if(def != null){ for(Item item : (Collection<Item>) ColoringToolsManager.getAllItems(provider)){ ModelLoader.setCustomModelResourceLocation(item, 0, def); Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(item, 0, def); Minecraft.getMinecraft().getItemColors().registerItemColorHandler(new StandartColoringToolItemColor(0, 1), item); } } } } Quote Check out my mods: BTAM Armor sets Avoid Exploding Creepers Tools compressor Anti Id Conflict Key bindings overhaul Colourfull blocks Invisi Zones
Recommended Posts
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.