Posted January 26, 201312 yr Hello, i created a custom mob. Now my problem is, that the ears from my deer don't move when the head moves. And so it looks kinda crazy Here is my ModelDeer.java : package zcelo.mobs; import net.minecraft.client.model.ModelBase; import net.minecraft.client.model.ModelRenderer; import net.minecraft.entity.Entity; import net.minecraft.util.MathHelper; public class ModelDeer extends ModelBase { //fields ModelRenderer Body; ModelRenderer leftfrontleg; ModelRenderer rightfrontleg; ModelRenderer rightbackleg; ModelRenderer leftbackleg; ModelRenderer throat; ModelRenderer head; ModelRenderer tail; ModelRenderer leftear; ModelRenderer rightear; public ModelDeer() { textureWidth = 64; textureHeight = 32; Body = new ModelRenderer(this, 28, 0); Body.addBox(0F, 0F, 0F, 6, 5, 12); Body.setRotationPoint(-3F, 11F, -5F); Body.setTextureSize(64, 32); Body.mirror = true; setRotation(Body, 0F, 0F, 0F); leftfrontleg = new ModelRenderer(this, 0, 0); leftfrontleg.addBox(-0.5F, 0F, -1F, 1, 9, 2); leftfrontleg.setRotationPoint(2.4F, 15F, -3.9F); leftfrontleg.setTextureSize(64, 32); leftfrontleg.mirror = true; setRotation(leftfrontleg, 0F, 0F, 0F); rightfrontleg = new ModelRenderer(this, 0, 0); rightfrontleg.addBox(-0.5F, 0F, -1F, 1, 9, 2); rightfrontleg.setRotationPoint(-2.4F, 15F, -3.9F); rightfrontleg.setTextureSize(64, 32); rightfrontleg.mirror = true; setRotation(rightfrontleg, 0F, 0F, 0F); rightbackleg = new ModelRenderer(this, 0, 0); rightbackleg.addBox(-0.5F, 0F, -1F, 1, 9, 2); rightbackleg.setRotationPoint(-2.4F, 15F, 4.9F); rightbackleg.setTextureSize(64, 32); rightbackleg.mirror = true; setRotation(rightbackleg, 0F, 0F, 0F); leftbackleg = new ModelRenderer(this, 0, 0); leftbackleg.addBox(-0.5F, 0F, -1F, 1, 9, 2); leftbackleg.setRotationPoint(2.4F, 15F, 4.9F); leftbackleg.setTextureSize(64, 32); leftbackleg.mirror = true; setRotation(leftbackleg, 0F, 0F, 0F); throat = new ModelRenderer(this, 20, 0); throat.addBox(-1F, 0F, 0F, 2, 9, 2); throat.setRotationPoint(0F, 6F, -10F); throat.setTextureSize(64, 32); throat.mirror = true; setRotation(throat, 0.6320364F, 0F, 0F); head = new ModelRenderer(this, 46, 17); head.addBox(-1.5F, -3F, -5F, 3, 3, 6); head.setRotationPoint(0F, 6F, -8.5F); head.setTextureSize(64, 32); head.mirror = true; setRotation(head, 0F, 0F, 0F); tail = new ModelRenderer(this, 6, 0); tail.addBox(-0.5F, 0F, 0F, 1, 3, 1); tail.setRotationPoint(0F, 9F, 7F); tail.setTextureSize(64, 32); tail.mirror = true; setRotation(tail, -0.5205006F, 0F, 0F); leftear = new ModelRenderer(this, 16, 0); leftear.addBox(-0.5F, -3F, -0.5F, 1, 3, 1); leftear.setRotationPoint(0.7F, 4F, -9F); leftear.setTextureSize(64, 32); leftear.mirror = true; setRotation(leftear, -0.5205006F, 0F, 0F); rightear = new ModelRenderer(this, 15, 0); rightear.addBox(-0.5F, -3F, -0.5F, 1, 3, 1); rightear.setRotationPoint(-0.7F, 4F, -9F); rightear.setTextureSize(64, 32); rightear.mirror = true; setRotation(rightear, -0.5205006F, 0F, 0F); } 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); setRotationAngles(f, f1, f2, f3, f4, f5); Body.render(f5); leftfrontleg.render(f5); rightfrontleg.render(f5); rightbackleg.render(f5); leftbackleg.render(f5); throat.render(f5); head.render(f5); tail.render(f5); leftear.render(f5); rightear.render(f5); } private void setRotation(ModelRenderer model, float x, float y, float z) { model.rotateAngleX = x; model.rotateAngleY = y; model.rotateAngleZ = z; } public void setRotationAngles(float f, float f1, float f2, float f3, float f4, float f5) { super.setRotationAngles(f, f1, f2, f3, f4, f5, null); this.head.rotateAngleX = f4 / (180F / (float)Math.PI); this.head.rotateAngleY = f3 / (180F / (float)Math.PI); this.leftfrontleg.rotateAngleX = MathHelper.cos(f * 0.6662F) * 1.4F * f1; this.rightfrontleg.rotateAngleX = MathHelper.cos(f * 0.6662F + (float)Math.PI) * 1.4F * f1; this.leftbackleg.rotateAngleX = MathHelper.cos(f * 0.6662F + (float)Math.PI) * 1.4F * f1; this.rightbackleg.rotateAngleX = MathHelper.cos(f * 0.6662F) * 1.4F * f1; } } Maybe, someone can explain me how to change the rotation of elements in my model.
January 29, 201312 yr Author I still can't find the solution. Maybe someone has a tip or knows how to solve my problem?
January 30, 201312 yr ModelRenderer.addChild() is what your looking for: head.addChild(leftEar); head.addChild(rightEar); Please note, you will need to reoffset the ears because it offsets thier rotation points.
January 30, 201312 yr Author First of all thanks. I'll try it later. I don't understand the last sentence. What is reoffset? I can't find a translation for it, cuz english isn't my mother tongue.
January 30, 201312 yr What I mean is you will have to move the position of the ears around because addChild moves them to a new place so the rotation point is the same as the head. To fix it, in Techne, just move both ears' rotation points to where the head is and then move the actual model back into position.
February 1, 201312 yr Author Hey, now i've the problem that i have 2 rightears and 2 leftears? I only added the code above from you.
August 23, 201411 yr You don't have to call the render function on the children since they will be rendered automatically. http://i.imgur.com/RvFDhZj.gif[/img]
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.