Posted August 19, 201510 yr Hi, I need to be able to grab my model's texture during runtime (specifically after the player object is created in the world) and be able to replace it. Keep in mind I am using ISmartItemModel as well as IPerspectiveAwareModel, if that helps with the effort any. Basically, can you even change a model's texture? If so, is it possible at runtime? Any help is greatly appreciated. Note: I know of this method found in the IBakedModel class as well as its subclasses that might be useful: @Override public TextureAtlasSprite getTexture() { return SOMEMODEL.getTexture(); } Development of Plugins [2012 - 2014] Development of Mods [2012 - Current]
August 23, 201510 yr I use something more light and less deep than this for multi textured items. Register the textures and make the relationship with an item (example from my mod): renderItem.register(ironGun, 0, new ModelResourceLocation(RedMagnet.MODID+":"+((RMGun) ironGun).getName(), "inventory")); renderItem.register(ironGun, 1, new ModelResourceLocation(RedMagnet.MODID+":"+((RMGun) ironGun).getName()+"_black", "inventory")); ModelBakery.addVariantName(ironGun, new String[] { RedMagnet.MODID +":"+ ((RMGun)ironGun).getName(), RedMagnet.MODID +":"+ ((RMGun)ironGun).getName()+"_black" }); And then, make a logic to change the textures (example from my mod, item gun class): @Override public int getMetadata(ItemStack stack) { if(stack.getTagCompound() != null) return stack.getTagCompound().getInteger("color"); else return 0; } You can see too the method getModel of Item.class (Minecraft): @Override @SideOnly(Side.CLIENT) public ModelResourceLocation getModel(ItemStack stack, EntityPlayer player, int useRemaining){} Here is a video from my mod; if you can see, the "rifle with mag" changes the texture after all shots (mag off). // BSc CIS, hardcore gamer and a big fan of Minecraft. TmzOS ::..
August 23, 201510 yr Author Thanks for the reply, haven't had much support for rendering. It's not that simple - I used to do I that way but I am using complex (multi-part) .JSON models and baking a smart / perspective model during the ModelBakeEvent. I don't need to switch between models using the getModel() method, I need to modify its texture specifically at runtime. What I am trying to do is UV the model texture to the player skin correctly and then bind the skin texture to the model (the player object is null when baking the models , so I cannot bind the player skin). An idea would be to set NBT to an existing item an if the nbt boolean is true, create a new model with the texture (done at runtime). Please feel free to give me suggestions - any help is still appreciated! Development of Plugins [2012 - 2014] Development of Mods [2012 - Current]
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.