Posted November 12, 20177 yr Recently I've gotten into making custom models for my armour sets. I have used this tutorial to guide me. Now, the armour works mostly fine. The only thing that goes wrong is that the armour model does not change according to the entity wearing it. That is, it is always rendered small, the arms always move (even on armour stands) and the armour does not follow the player sneaking, holding an item, guarding with a sword, etc. I do realise that some of these things can be circumvented by changing certain fields in ModelBiped and ModelBase (e.g. isChild, isSneaking), but these fields do not cover every movement. How would I go about making the armour render correctly according to the attributes of the entity wearing it? Thanks in advance for any help! Here are the classes involved for reference: ModelElementalArmourIce.java: Spoiler public class ModelElementalArmourIce extends ModelBiped { public ModelElementalArmourIce(int slot, float scale) { super(scale, 0, 64, 64); ModelRenderer icyEyes = new ModelRenderer(this, 0, 32); icyEyes.addBox(-11F, -3F, 0F, 22, 8, 0); icyEyes.setRotationPoint(0F, -8F, -5.1F); icyEyes.setTextureSize(64, 64); icyEyes.mirror = true; setRotation(icyEyes, 0F, 0F); bipedHeadwear.addChild(icyEyes); ModelRenderer spike1 = new ModelRenderer(this, 48, 32); spike1.addBox(-0.5F, -0.5F, 0F, 1, 1, 4); spike1.setRotationPoint(1.5F, 2.5F, 2F); spike1.setTextureSize(64, 64); setRotation(spike1, 0.2617994F, 0.0872665F); bipedBody.addChild(spike1); ModelRenderer spike2 = new ModelRenderer(this, 48, 32); spike2.addBox(-0.5F, -0.5F, 0F, 1, 1, 4); spike2.setRotationPoint(-1.5F, 2.5F, 2F); spike2.setTextureSize(64, 64); spike2.mirror = true; setRotation(spike2, 0.2617994F, -0.0872665F); bipedBody.addChild(spike2); ModelRenderer spike3 = new ModelRenderer(this, 48, 32); spike3.addBox(-0.5F, -0.5F, 0F, 1, 1, 4); spike3.setRotationPoint(2F, 6F, 2F); spike3.setTextureSize(64, 64); setRotation(spike3, 0F, 0.1745329F); bipedBody.addChild(spike3); ModelRenderer spike4 = new ModelRenderer(this, 48, 32); spike4.addBox(-0.5F, -0.5F, 0F, 1, 1, 4); spike4.setRotationPoint(-2F, 6F, 2F); spike4.setTextureSize(64, 64); spike4.mirror = true; setRotation(spike4, 0F, -0.1745329F); bipedBody.addChild(spike4); ModelRenderer spike5 = new ModelRenderer(this, 48, 32); spike5.addBox(-0.5F, -0.5F, 0F, 1, 1, 4); spike5.setRotationPoint(1.5F, 9.5F, 2F); spike5.setTextureSize(64, 64); setRotation(spike5, -0.2617994F, 0.0872665F); bipedBody.addChild(spike5); ModelRenderer spike6 = new ModelRenderer(this, 48, 32); spike6.addBox(-0.5F, -0.5F, 0F, 1, 1, 4); spike6.setRotationPoint(-1.5F, 9.5F, 2F); spike6.setTextureSize(64, 64); spike6.mirror = true; setRotation(spike6, -0.2617994F, -0.0872665F); bipedBody.addChild(spike6); ModelRenderer clawRightFront = new ModelRenderer(this, 44, 32); clawRightFront.addBox(0F, 0F, -0.5F, 1, 5, 1); clawRightFront.setRotationPoint(-3F, 10F, -0.7F); clawRightFront.setTextureSize(64, 64); clawRightFront.mirror = true; setRotation(clawRightFront, 0F, 0F); bipedRightArm.addChild(clawRightFront); ModelRenderer clawRightBack = new ModelRenderer(this, 44, 32); clawRightBack.addBox(0F, 0F, -0.5F, 1, 5, 1); clawRightBack.setRotationPoint(-3F, 10F, 0.67F); clawRightBack.setTextureSize(64, 64); clawRightBack.mirror = true; setRotation(clawRightBack, 0F, 0F); bipedRightArm.addChild(clawRightBack); ModelRenderer clawLeftFront = new ModelRenderer(this, 44, 32); clawLeftFront.addBox(-1F, 0F, -0.5F, 1, 5, 1); clawLeftFront.setRotationPoint(3F, 10F, -0.7F); clawLeftFront.setTextureSize(64, 64); setRotation(clawLeftFront, 0F, 0F); bipedLeftArm.addChild(clawLeftFront); ModelRenderer clawLeftBack = new ModelRenderer(this, 44, 32); clawLeftBack.addBox(-1F, 0F, -0.5F, 1, 5, 1); clawLeftBack.setRotationPoint(3F, 10F, 0.7F); clawLeftBack.setTextureSize(64, 64); setRotation(clawLeftBack, 0F, 0F); bipedLeftArm.addChild(clawLeftBack); switch (slot) { case 0: bipedHeadwear.showModel = true; bipedHead.showModel = true; bipedBody.showModel = false; bipedLeftArm.showModel = false; bipedRightArm.showModel = false; bipedLeftLeg.showModel = false; bipedRightLeg.showModel = false; break; case 1: bipedHeadwear.showModel = false; bipedHead.showModel = false; bipedBody.showModel = true; bipedLeftArm.showModel = true; bipedRightArm.showModel = true; bipedLeftLeg.showModel = false; bipedRightLeg.showModel = false; break; case 2: bipedHeadwear.showModel = false; bipedHead.showModel = false; bipedBody.showModel = true; bipedLeftArm.showModel = false; bipedRightArm.showModel = false; bipedLeftLeg.showModel = true; bipedRightLeg.showModel = true; spike1.showModel = false; spike2.showModel = false; spike3.showModel = false; spike4.showModel = false; spike5.showModel = false; spike6.showModel = false; break; case 3: bipedHeadwear.showModel = false; bipedHead.showModel = false; bipedBody.showModel = false; bipedLeftArm.showModel = false; bipedRightArm.showModel = false; bipedLeftLeg.showModel = true; bipedRightLeg.showModel = true; break; } } public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) { super.render(entity, f, f1, f2, f3, f4, f5); super.setRotationAngles(f, f1, f2, f3, f4, f5, entity); } private void setRotation(ModelRenderer model, float x, float y) { model.rotateAngleX = x; model.rotateAngleY = y; model.rotateAngleZ = 0F; } } ElementalArmourItem.java: Spoiler [unimportant contructors and the like] @Override @SideOnly(Side.CLIENT) public ModelBiped getArmorModel(EntityLivingBase entity, ItemStack stack, int armorSlot) { GL11.glPushMatrix(); GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GL11.glPopMatrix(); ModelElementalArmourIce model = ClientProxy.getElementalArmourModel(4 - armorSlot); return model; } ClientProxy.java: Spoiler public class ClientProxy extends CommonProxy { private static ModelElementalArmourIce[] elementalArmour; [preInit] @Override public void init(FMLInitializationEvent e) { super.init(e); elementalArmour = new ModelElementalArmourIce[4]; elementalArmour[0] = new ModelElementalArmourIce(0, 0.5F); elementalArmour[1] = new ModelElementalArmourIce(1, 1.0F); elementalArmour[2] = new ModelElementalArmourIce(2, 0.5F); elementalArmour[3] = new ModelElementalArmourIce(3, 0.5F); [other stuff] } [postInit] public static ModelElementalArmourIce getElementalArmourModel(int slot) { return elementalArmour[slot]; } } Edited November 12, 20177 yr by JoieNL
November 14, 20177 yr Author A few days have passed now and I have made little progress. I have found a way to easily apply most important attributes that the model can have: @Override @SideOnly(Side.CLIENT) public ModelBiped getArmorModel(EntityLivingBase entity, ItemStack stack, int armorSlot) { [...] ModelElementalArmourIce model = ClientProxy.getElementalArmourModel(4 - armorSlot); ModelBase defaultModel = RendererLivingEntity.class.cast(Minecraft.getMinecraft().getRenderManager().getEntityRenderObject(entity)).getMainModel(); model.setModelAttributes(defaultModel); return model; } This way of doing things does not look particularly beautiful and I would not be surprised if there was some better way of retrieving an entity's default model. Of course, my problem still stands. I have experimented some more with the armour, and have been able to pinpoint several issues that all relate to the entity wearing the armour. - On armour stands, the helmet's front always faces south and the arms move (idle animation). - For entities that have their arms sticking forward (e.g. zombies, skeletons), the armour's arms simply hang downwards. - Zombie villagers also have their heads sticking out the top of the helmet. I will persist in trying to find a solution. I hope someone may be able to help me out.
November 14, 20177 yr Why are you casting that way? (ModelBase)foo is sufficient. 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.
November 16, 20177 yr Author Right, that was just a thing I left there for no reason. The casting is to RendererLivingEntity by the way, not ModelBase. Here's the preferred thing: ModelBase defaultModel = ((RendererLivingEntity) Minecraft.getMinecraft().getRenderManager().getEntityRenderObject(entity)).getMainModel(); The weird cast was there because I was getting confused with both RendererLiving and Render being generic classes. Anyway, this is kind of besides the point of the thread, and I still haven't made any progress on the topic. Edited November 16, 20177 yr by JoieNL
November 16, 20177 yr 36 minutes ago, JoieNL said: Right, that was just a thing I left there for no reason. The casting is to RendererLivingEntity by the way, not ModelBase. you are correct, I'm on a tablet right now, so things are tricky. 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.
November 27, 20177 yr Author It has been over two weeks since my original post and I have not made even the slightest amount of progress. Any help would be greatly appreciated.
January 6, 20187 yr Author I thought maybe another mod's code might help me out. I know Twilight Forest has some custom armour models and luckily for me the source code is on GitHub. I will look into things a bit more and report my findings. Edited January 6, 20187 yr by JoieNL
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.