Posted April 17, 20169 yr I'm trying to make a mod that changes vanilla item model based off of its name or lore. But before I get to that, I'm trying to get it to even change the model in the first place! Nothing seems to happen. Am I missing anything? Main mod file: http://pastebin.com/KKhrD2bC CustomItemModel: http://pastebin.com/sEXEffZ9 TestDiamondSwordModel: http://pastebin.com/hbjSJsaN
April 17, 20169 yr Author Also, I noticed that MinecraftForgeClient.registerItemRenderer is not a thing in 1.9. Any reason for this?
April 17, 20169 yr There is a new way handling models in 1.9. Here is a thread I made that helped me figure it out, might have what you are looking for. Current Project: Armerger Planned mods: Light Drafter | Ore Swords Looking for help getting a mod off the ground? Coding | Textures
April 17, 20169 yr Author I'm sorry, I tried reading it, but I can't quite understand what exactly I need to do. Could you please explain to me?
April 17, 20169 yr Make a class that implements ICustomModelLoader . In accepts return true if it is the RL for your Item. In loadModel return a new IModel. In the IModel: bake : return a new instance of your ISmartItemModel. getDependencies / getTextures : Return ImmutableList.of() (the empty list). getDefaultState : Return TRSRTransformation.identiy. Then register your loader using ModelLoaderRegistry.registerLoader in preInit. You now no longer need the bake event handler. The difference for you is that you have a texture to return and you will probably be using IBakedModle instead of ISmartItemModel Current Project: Armerger Planned mods: Light Drafter | Ore Swords Looking for help getting a mod off the ground? Coding | Textures
April 17, 20169 yr Author I don't have any access to the ItemStack here though, so how can I change it using the lore or name?
April 17, 20169 yr Author Wouldn't an IBakedModel require me to model it in Techne? I want to use it with Minecraft json models, supplied by the resource pack.
April 17, 20169 yr Author I figured out that you can use ItemOverrideList and handleItemState to get the itemstack info, but now I need to know how to generate a baked model from a model json file.
April 17, 20169 yr I haven't done that myself but minecrafts model loader also implements ICustomModelLoader so if you look around through that you should be able to see how they do it. In case you don't know: right click -> the 3 opens are a great way to trace through classes and method calls. Current Project: Armerger Planned mods: Light Drafter | Ore Swords Looking for help getting a mod off the ground? Coding | Textures
April 17, 20169 yr Author I made it turn to an apple when named Apple, but it crashes when it's a non-apple diamond sword! EDIT: Whoops, forgot to pastebin! http://pastebin.com/wsDQqW5w
April 17, 20169 yr Author http://www.minecraftforge.net/forum/index.php/topic,37398.msg197123.html#msg197123 they were successfully able to use it in 1.9, so I do believe it should work in 1.9. Perhaps it doesn't work because I'm using it with vanilla items?
April 17, 20169 yr Author It seems the problem with ItemMeshDefinition is that getModelLocation() is never called. I can't figure out why.
April 17, 20169 yr Author I discovered in ItemModelMesher: public IBakedModel getItemModel(ItemStack stack) { Item item = stack.getItem(); IBakedModel ibakedmodel = this.getItemModel(item, this.getMetadata(stack)); if (ibakedmodel == null) { ItemMeshDefinition itemmeshdefinition = (ItemMeshDefinition)this.shapers.get(item); if (itemmeshdefinition != null) { ibakedmodel = this.modelManager.getModel(itemmeshdefinition.getModelLocation(stack)); } } if (ibakedmodel == null) { ibakedmodel = this.modelManager.getMissingModel(); } return ibakedmodel; } Does that mean that it's only called for nonexistent meshes? (It checks if baked mesh is null first)
April 17, 20169 yr If you know what the model should be during pre-post Initialization you should be able to just over write the original locations. Current Project: Armerger Planned mods: Light Drafter | Ore Swords Looking for help getting a mod off the ground? Coding | Textures
April 17, 20169 yr Author @SuppressWarnings("unchecked") private void removeItemFromMesher(Item item, int meta) { try { Field field1 = ItemModelMesher.class.getDeclaredField("simpleShapesCache"); field1.setAccessible(true); Map<Integer, IBakedModel> simpleShapesCache = (Map<Integer, IBakedModel>) field1.get(getMesher()); simpleShapesCache.remove(getIndex(item, meta)); field1.set(getMesher(), simpleShapesCache); Field field2 = ItemModelMesher.class.getDeclaredField("simpleShapes"); field2.setAccessible(true); Map<Integer, ModelResourceLocation> simpleShapes = (Map<Integer, ModelResourceLocation>) field2.get(getMesher()); simpleShapes.remove(getIndex(item, meta)); field2.set(getMesher(), simpleShapes); } catch (NoSuchFieldException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (SecurityException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IllegalArgumentException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IllegalAccessException e) { // TODO Auto-generated catch block e.printStackTrace(); } } I tried doing this on postinit, but it did nothing.
April 18, 20169 yr Author I GOT IT TO WORK WITH ICUSTOMMODELLOADER! It now looks like a potato unless it is named Apple, in which case it looks like an apple. It works as expected My new code: http://pastebin.com/bQAWSUVx Now that I know how, I can use that same concept to make an actual system for it. (Code is very hacky, so anyone reading this shouldn't copy and paste )
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.