imacatlolol Posted October 16, 2016 Posted October 16, 2016 I'm having issues getting some of my models to work. I've decided that the best thing I can do is change how I register models. At the moment, I use something like this and I load it in the initialization phase: public static void registerRender(Item item) { Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(item, 0, new ModelResourceLocation(item.getRegistryName(), "inventory")); } public static void registerRender(Block block) { Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(Item.getItemFromBlock(block), 0, new ModelResourceLocation(block.getRegistryName(), "inventory")); } What would be a better alternative? Quote I'm eager to learn and am prone to mistakes. Don't hesitate to tell me how I can improve.
Draco18s Posted October 16, 2016 Posted October 16, 2016 Yes. https://github.com/Draco18s/ReasonableRealism/blob/master/src/main/java/com/draco18s/hardlib/client/ClientEasyRegistry.java#L120 Quote Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given.
imacatlolol Posted October 16, 2016 Author Posted October 16, 2016 On 10/16/2016 at 6:44 PM, Draco18s said: Yes. https://github.com/Draco18s/ReasonableRealism/blob/master/src/main/java/com/draco18s/hardlib/client/ClientEasyRegistry.java#L120 Ha, that's much better, thanks! Quote I'm eager to learn and am prone to mistakes. Don't hesitate to tell me how I can improve.
yooksi Posted October 16, 2016 Posted October 16, 2016 On 10/16/2016 at 5:56 PM, imacatlolol said: At the moment, I use something like this and I load it in the initialization phase: Aren't models suppose to be registered in the pre-initialization phase? Quote I still haven't published a mod because I can never get that in-dev version just right to warrant a public release. And yes, after two years of mod development I am still learning to speak Java. Follow me on GitHub: https://github.com/yooksi Contact me on Twitter: https://twitter.com/yooksi Read my Minecraft blog: https://yooksidoesminecraft.blogspot.de/
Draco18s Posted October 16, 2016 Posted October 16, 2016 On 10/16/2016 at 10:24 PM, yooksi said: Quote At the moment, I use something like this and I load it in the initialization phase: Aren't models suppose to be registered in the pre-initialization phase? The way he was doing it, no. ModelLoader.customModelLocation, yes. Quote Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given.
yooksi Posted October 17, 2016 Posted October 17, 2016 On 10/16/2016 at 10:34 PM, Draco18s said: Quote Quote At the moment, I use something like this and I load it in the initialization phase: Aren't models suppose to be registered in the pre-initialization phase? The way he was doing it, no. ModelLoader.customModelLocation, yes. Hm, okay, I don't know much about registering models that way. Isn't the use of ModelLoader.setCustomModelResourceLocation over getItemModelMesher().register recommended by Forge conventions? At least I recall reading about that more then once here. Quote I still haven't published a mod because I can never get that in-dev version just right to warrant a public release. And yes, after two years of mod development I am still learning to speak Java. Follow me on GitHub: https://github.com/yooksi Contact me on Twitter: https://twitter.com/yooksi Read my Minecraft blog: https://yooksidoesminecraft.blogspot.de/
Draco18s Posted October 17, 2016 Posted October 17, 2016 On 10/17/2016 at 1:05 AM, yooksi said: Hm, okay, I don't know much about registering models that way. Isn't the use of ModelLoader.setCustomModelResourceLocation over getItemModelMesher().register recommended by Forge conventions? At least I recall reading about that more then once here. Yes, because using the ModelMesher directly has issues. Which is why the ModelLoader method exists. Quote Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given.
derf6060 Posted October 17, 2016 Posted October 17, 2016 What issues does getItemModelMesher() have over ModelLoader.setCustomModelResourceLocation. I've used getItemModelMesher since 1.8 came out and I have not had any issues with it so far. Quote
Draco18s Posted October 17, 2016 Posted October 17, 2016 From what I understand it has to be called in Init, but before some things and after others and was just prone to problems that if not properly dealt with would cause issues. You might have code that works fine in 1.8, but you should update to using ModelLoader.setCustomModelResourceLocation on newer version of MC anyway. Quote Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given.
derf6060 Posted October 17, 2016 Posted October 17, 2016 I'm actually using forge 1.10.2 and it works fine. Also I took a look at the ModelLoader to see what it is doing. It stores all of its values into 2 maps and defers the registration. After the initialization stages (I'm not real sure what stages it could be after or before post) forge calls onRegisterItems which registers both maps to ItemModelMesher. That a pretty nice and clean way to handle it. I'm going to change over thanks for the explanation. Quote
derf6060 Posted October 17, 2016 Posted October 17, 2016 Oh lol when I changed to it all item models didn't load so don't call that method during the initialization stage. It defers the model registration before initialization stage happens so make sure to pass all model information during pre initiliaztion stage lol. Quote
Draco18s Posted October 17, 2016 Posted October 17, 2016 Something something there will be problems. Quote Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given.
derf6060 Posted October 17, 2016 Posted October 17, 2016 lol, oh yes there will be problems if you call the old way in pre initialization for example the client exploding or models not loading correctly. That pretty all the issues I ran into while using the old method of loading them models. The method is just the opposite. Its needs to be handled in pre initialization with the added benefit of adding information the the ModelBakery too. So you don't have to worry about variants it is already handled for you for the most part lol. Quote
yooksi Posted October 17, 2016 Posted October 17, 2016 On 10/17/2016 at 6:22 AM, derf6060 said: lol, oh yes there will be problems if you call the old way in pre initialization for example the client exploding or models not loading correctly. That pretty all the issues I ran into while using the old method of loading them models. The method is just the opposite. Its needs to be handled in pre initialization with the added benefit of adding information the the ModelBakery too. So you don't have to worry about variants it is already handled for you for the most part lol. Are there any advantages of using the old method over the new one? Quote I still haven't published a mod because I can never get that in-dev version just right to warrant a public release. And yes, after two years of mod development I am still learning to speak Java. Follow me on GitHub: https://github.com/yooksi Contact me on Twitter: https://twitter.com/yooksi Read my Minecraft blog: https://yooksidoesminecraft.blogspot.de/
derf6060 Posted October 17, 2016 Posted October 17, 2016 Well the old method has one major problem. If you had model variants you would have to explicitly register them with ModelBakery. The new method automatically registers all moddles with the ModelBakery which is fine. The old method also had issues if you called it in pre initialization method which either didn't load the models or other strange issues like the client blowing up on me one or twice because I didn't put them in the Initialization phase. Thats pretty much sums up the differences between the old way and the new way. Quote
yooksi Posted October 17, 2016 Posted October 17, 2016 On 10/17/2016 at 8:11 AM, derf6060 said: Well the old method has one major problem. If you had model variants you would have to explicitly register them with ModelBakery. The new method automatically registers all moddles with the ModelBakery which is fine. The old method also had issues if you called it in pre initialization method which either didn't load the models or other strange issues like the client blowing up on me one or twice because I didn't put them in the Initialization phase. Thats pretty much sums up the differences between the old way and the new way. All really good reasons to start using the new method. Quote I still haven't published a mod because I can never get that in-dev version just right to warrant a public release. And yes, after two years of mod development I am still learning to speak Java. Follow me on GitHub: https://github.com/yooksi Contact me on Twitter: https://twitter.com/yooksi Read my Minecraft blog: https://yooksidoesminecraft.blogspot.de/
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.