Résolu Problème de rendu d'un mob
-
Le mob que j’ai créé a un drôle de bug : on dirait qu’il est composé de deux lui-même. Deux têtes, quatre jambes et quatre bras, tous à la même position mais avec une rotation différente. Il s’agit de mon premier mob avec un modèle Techne, et ne sais pas d’où vient le problème. Voici mes codes :
RenderDemon :
package ca.live.mod.client; import net.minecraft.client.model.ModelBiped; import net.minecraft.client.renderer.entity.RenderBiped; import net.minecraft.entity.EntityLiving; import net.minecraft.util.ResourceLocation; import ca.live.mod.common.EntityDemon; import ca.live.mod.common.ModTest; public class RenderDemon extends RenderBiped { public RenderDemon(ModelDemon model, float shadow) { super(model, shadow); } public final ResourceLocation texture = new ResourceLocation(ModTest.MODID, "textures/entity/demon.png"); protected ResourceLocation getEntityTexture(EntityLiving living) { return this.getDemonTexture((EntityDemon)living); } private ResourceLocation getDemonTexture(EntityDemon demon) { return texture; } }
ClientProxy :
package ca.live.mod.proxy; import net.minecraft.client.model.ModelBiped; import ca.live.mod.client.ModelDemon; import ca.live.mod.client.RenderDemon; import ca.live.mod.common.EntityDemon; import cpw.mods.fml.client.registry.RenderingRegistry; public class ClientProxy extends CommonProxy { @Override public void registerRender() { RenderingRegistry.registerEntityRenderingHandler(EntityDemon.class, new RenderDemon(new ModelDemon(), 0.5F)); } }
EntityDemon :
package ca.live.mod.common; import net.minecraft.entity.SharedMonsterAttributes; import net.minecraft.entity.monster.EntityMob; import net.minecraft.item.Item; import net.minecraft.world.World; public class EntityDemon extends EntityMob { public EntityDemon(World world) { super(world); } public void applyEntityAttributes() { super.applyEntityAttributes(); this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(20); this.getEntityAttribute(SharedMonsterAttributes.attackDamage).setBaseValue(6); this.getEntityAttribute(SharedMonsterAttributes.knockbackResistance).setBaseValue(1); this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(0.8); } public Item getDropItem() { return ModTest.item; } }
-
ModelDemon.java ?
-
package ca.live.mod.client; import net.minecraft.client.model.ModelBase; import net.minecraft.client.model.ModelBiped; import net.minecraft.client.model.ModelRenderer; import net.minecraft.entity.Entity; public class ModelDemon extends ModelBiped { //fields ModelRenderer head; ModelRenderer body; ModelRenderer rightarm; ModelRenderer leftarm; ModelRenderer rightleg; ModelRenderer leftleg; ModelRenderer leftfinger1; ModelRenderer leftfinger2; ModelRenderer leftfinger3; ModelRenderer leftfinger4; ModelRenderer leftfinger5; ModelRenderer rightfinger1; ModelRenderer rightfinger2; ModelRenderer rightfinger3; ModelRenderer rightfinger4; ModelRenderer rightfinger5; ModelRenderer leftwing1; ModelRenderer leftwing2; ModelRenderer leftwing3; ModelRenderer leftwing4; ModelRenderer leftwing5; ModelRenderer leftwing6; ModelRenderer leftwing7; ModelRenderer leftwing8; ModelRenderer leftwing9; ModelRenderer leftwing10; ModelRenderer leftwing11; ModelRenderer leftwing12; ModelRenderer rightwing1; ModelRenderer rightwing2; ModelRenderer rightwing3; ModelRenderer rightwing4; ModelRenderer rightwing5; ModelRenderer rightwing6; ModelRenderer rightwing7; ModelRenderer rightwing8; ModelRenderer rightwing9; ModelRenderer rightwing10; ModelRenderer rightwing11; ModelRenderer rightwing12; ModelRenderer righthorn1; ModelRenderer righthorn2; ModelRenderer righthorn3; ModelRenderer righthorn4; ModelRenderer lefthorn1; ModelRenderer lefthorn2; ModelRenderer lefthorn3; ModelRenderer lefthorn4; public ModelDemon() { textureWidth = 64; textureHeight = 32; head = new ModelRenderer(this, 0, 0); head.addBox(-4F, -8F, -4F, 8, 8, 8); head.setRotationPoint(0F, 0F, 0F); head.setTextureSize(64, 32); head.mirror = true; setRotation(head, 0F, 0F, 0F); body = new ModelRenderer(this, 0, 16); body.addBox(-4F, 0F, -2F, 8, 12, 4); body.setRotationPoint(0F, 0F, 0F); body.setTextureSize(64, 32); body.mirror = true; setRotation(body, 0F, 0F, 0F); rightarm = new ModelRenderer(this, 24, 16); rightarm.addBox(-3F, -2F, -2F, 4, 12, 4); rightarm.setRotationPoint(-5F, 2F, 0F); rightarm.setTextureSize(64, 32); rightarm.mirror = true; setRotation(rightarm, 0F, 0F, 0F); leftarm = new ModelRenderer(this, 24, 16); leftarm.addBox(-1F, -2F, -2F, 4, 12, 4); leftarm.setRotationPoint(5F, 2F, 0F); leftarm.setTextureSize(64, 32); leftarm.mirror = true; setRotation(leftarm, 0F, 0F, 0F); rightleg = new ModelRenderer(this, 40, 16); rightleg.addBox(-2F, 0F, -2F, 4, 12, 4); rightleg.setRotationPoint(-2F, 12F, 0F); rightleg.setTextureSize(64, 32); rightleg.mirror = true; setRotation(rightleg, 0F, 0F, 0F); leftleg = new ModelRenderer(this, 48, 16); leftleg.addBox(-2F, 0F, -2F, 4, 12, 4); leftleg.setRotationPoint(2F, 12F, 0F); leftleg.setTextureSize(64, 32); leftleg.mirror = true; setRotation(leftleg, 0F, 0F, 0F); leftfinger1 = new ModelRenderer(this, 32, 0); leftfinger1.addBox(0F, 0F, 0F, 1, 2, 0); leftfinger1.setRotationPoint(5F, 12F, -2F); leftfinger1.setTextureSize(64, 32); leftfinger1.mirror = true; setRotation(leftfinger1, 0F, 0F, 0F); leftfinger2 = new ModelRenderer(this, 32, 0); leftfinger2.addBox(0F, 0F, 0F, 1, 2, 0); leftfinger2.setRotationPoint(7F, 12F, -1F); leftfinger2.setTextureSize(64, 32); leftfinger2.mirror = true; setRotation(leftfinger2, 0F, 0F, 0F); leftfinger3 = new ModelRenderer(this, 32, 0); leftfinger3.addBox(0F, 0F, 0F, 1, 2, 0); leftfinger3.setRotationPoint(7F, 12F, 0F); leftfinger3.setTextureSize(64, 32); leftfinger3.mirror = true; setRotation(leftfinger3, 0F, 0F, 0.0174533F); leftfinger4 = new ModelRenderer(this, 32, 0); leftfinger4.addBox(0F, 0F, 0F, 1, 2, 0); leftfinger4.setRotationPoint(7F, 12F, 1F); leftfinger4.setTextureSize(64, 32); leftfinger4.mirror = true; setRotation(leftfinger4, 0F, 0F, 0.0174533F); leftfinger5 = new ModelRenderer(this, 32, 0); leftfinger5.addBox(0F, 0F, 0F, 1, 2, 0); leftfinger5.setRotationPoint(7F, 12F, 2F); leftfinger5.setTextureSize(64, 32); leftfinger5.mirror = true; setRotation(leftfinger5, 0F, 0F, 0F); rightfinger1 = new ModelRenderer(this, 32, 0); rightfinger1.addBox(0F, 0F, 0F, 1, 2, 0); rightfinger1.setRotationPoint(-6F, 12F, -2F); rightfinger1.setTextureSize(64, 32); rightfinger1.mirror = true; setRotation(rightfinger1, 0F, 0F, 0.0174533F); rightfinger2 = new ModelRenderer(this, 32, 0); rightfinger2.addBox(0F, 0F, 0F, 1, 2, 0); rightfinger2.setRotationPoint(-8F, 12F, -1F); rightfinger2.setTextureSize(64, 32); rightfinger2.mirror = true; setRotation(rightfinger2, 0F, 0F, 0.0174533F); rightfinger3 = new ModelRenderer(this, 32, 0); rightfinger3.addBox(0F, 0F, 0F, 1, 2, 0); rightfinger3.setRotationPoint(-8F, 12F, 0F); rightfinger3.setTextureSize(64, 32); rightfinger3.mirror = true; setRotation(rightfinger3, 0F, 0F, 0.0174533F); rightfinger4 = new ModelRenderer(this, 32, 0); rightfinger4.addBox(0F, 0F, 0F, 1, 2, 0); rightfinger4.setRotationPoint(-8F, 12F, 1F); rightfinger4.setTextureSize(64, 32); rightfinger4.mirror = true; setRotation(rightfinger4, 0F, 0F, 0.0174533F); rightfinger5 = new ModelRenderer(this, 32, 0); rightfinger5.addBox(0F, 0F, 0F, 1, 2, 0); rightfinger5.setRotationPoint(-8F, 12F, 2F); rightfinger5.setTextureSize(64, 32); rightfinger5.mirror = true; setRotation(rightfinger5, 0F, 0F, 0.0174533F); leftwing1 = new ModelRenderer(this, 34, 0); leftwing1.addBox(0F, 0F, -1F, 0, 15, 1); leftwing1.setRotationPoint(2F, 2F, 2F); leftwing1.setTextureSize(64, 32); leftwing1.mirror = true; setRotation(leftwing1, 0.6981317F, 1.22173F, 0.3490659F); leftwing2 = new ModelRenderer(this, 36, 0); leftwing2.addBox(0F, 0F, 0F, 0, 1, 4); leftwing2.setRotationPoint(2F, 2F, 2F); leftwing2.setTextureSize(64, 32); leftwing2.mirror = true; setRotation(leftwing2, 0.6981317F, 1.22173F, 0.3490659F); leftwing3 = new ModelRenderer(this, 44, 0); leftwing3.addBox(0F, 3F, 0F, 0, 1, 5); leftwing3.setRotationPoint(2F, 2F, 2F); leftwing3.setTextureSize(64, 32); leftwing3.mirror = true; setRotation(leftwing3, 0.6981317F, 1.22173F, 0.3490659F); leftwing4 = new ModelRenderer(this, 44, 6); leftwing4.addBox(0F, 6F, 0F, 0, 1, 6); leftwing4.setRotationPoint(2F, 2F, 2F); leftwing4.setTextureSize(64, 32); leftwing4.mirror = true; setRotation(leftwing4, 0.6981317F, 1.22173F, 0.3490659F); leftwing5 = new ModelRenderer(this, 54, 0); leftwing5.addBox(0F, 1F, 0F, 0, 2, 3); leftwing5.setRotationPoint(2F, 2F, 2F); leftwing5.setTextureSize(64, 32); leftwing5.mirror = true; setRotation(leftwing5, 0.6981317F, 1.22173F, 0.3490659F); leftwing6 = new ModelRenderer(this, 36, 5); leftwing6.addBox(0F, 4F, 0F, 0, 2, 4); leftwing6.setRotationPoint(2F, 2F, 2F); leftwing6.setTextureSize(64, 32); leftwing6.mirror = true; setRotation(leftwing6, 0.6981317F, 1.22173F, 0.3490659F); leftwing7 = new ModelRenderer(this, 32, 2); leftwing7.addBox(0F, 7F, -2F, 0, 7, 1); leftwing7.setRotationPoint(2F, 2F, 2F); leftwing7.setTextureSize(64, 32); leftwing7.mirror = true; setRotation(leftwing7, 0.6981317F, 1.22173F, 0.3490659F); leftwing8 = new ModelRenderer(this, 36, 5); leftwing8.addBox(0F, 7F, 0F, 0, 2, 4); leftwing8.setRotationPoint(2F, 2F, 2F); leftwing8.setTextureSize(64, 32); leftwing8.mirror = true; setRotation(leftwing8, 0.6981317F, 1.22173F, 0.3490659F); leftwing9 = new ModelRenderer(this, 44, 0); leftwing9.addBox(0F, 9F, 0F, 0, 1, 5); leftwing9.setRotationPoint(2F, 2F, 2F); leftwing9.setTextureSize(64, 32); leftwing9.mirror = true; setRotation(leftwing9, 0.6981317F, 1.22173F, 0.3490659F); leftwing10 = new ModelRenderer(this, 54, 0); leftwing10.addBox(0F, 10F, 0F, 0, 2, 3); leftwing10.setRotationPoint(2F, 2F, 2F); leftwing10.setTextureSize(64, 32); leftwing10.mirror = true; setRotation(leftwing10, 0.6981317F, 1.22173F, 0.3490659F); leftwing11 = new ModelRenderer(this, 36, 0); leftwing11.addBox(0F, 12F, 0F, 0, 1, 4); leftwing11.setRotationPoint(2F, 2F, 2F); leftwing11.setTextureSize(64, 32); leftwing11.mirror = true; setRotation(leftwing11, 0.6981317F, 1.22173F, 0.3490659F); leftwing12 = new ModelRenderer(this, 56, 5); leftwing12.addBox(0F, 13F, 0F, 0, 1, 2); leftwing12.setRotationPoint(2F, 2F, 2F); leftwing12.setTextureSize(64, 32); leftwing12.mirror = true; setRotation(leftwing12, 0.6981317F, 1.22173F, 0.3490659F); rightwing1 = new ModelRenderer(this, 34, 0); rightwing1.addBox(0F, 0F, -1F, 0, 15, 1); rightwing1.setRotationPoint(-2F, 2F, 2F); rightwing1.setTextureSize(64, 32); rightwing1.mirror = true; setRotation(rightwing1, 0.6981317F, -1.22173F, -0.3490659F); rightwing2 = new ModelRenderer(this, 36, 0); rightwing2.addBox(0F, 0F, 0F, 0, 1, 4); rightwing2.setRotationPoint(-2F, 2F, 2F); rightwing2.setTextureSize(64, 32); rightwing2.mirror = true; setRotation(rightwing2, 0.6981317F, -1.22173F, -0.3490659F); rightwing3 = new ModelRenderer(this, 44, 0); rightwing3.addBox(0F, 3F, 0F, 0, 1, 5); rightwing3.setRotationPoint(-2F, 2F, 2F); rightwing3.setTextureSize(64, 32); rightwing3.mirror = true; setRotation(rightwing3, 0.6981317F, -1.22173F, -0.3490659F); rightwing4 = new ModelRenderer(this, 44, 6); rightwing4.addBox(0F, 6F, 0F, 0, 1, 6); rightwing4.setRotationPoint(-2F, 2F, 2F); rightwing4.setTextureSize(64, 32); rightwing4.mirror = true; setRotation(rightwing4, 0.6981317F, -1.22173F, -0.3490659F); rightwing5 = new ModelRenderer(this, 54, 0); rightwing5.addBox(0F, 1F, 0F, 0, 2, 3); rightwing5.setRotationPoint(-2F, 2F, 2F); rightwing5.setTextureSize(64, 32); rightwing5.mirror = true; setRotation(rightwing5, 0.6981317F, -1.22173F, -0.3490659F); rightwing6 = new ModelRenderer(this, 36, 5); rightwing6.addBox(0F, 4F, 0F, 0, 2, 4); rightwing6.setRotationPoint(-2F, 2F, 2F); rightwing6.setTextureSize(64, 32); rightwing6.mirror = true; setRotation(rightwing6, 0.6981317F, -1.22173F, -0.3490659F); rightwing7 = new ModelRenderer(this, 32, 2); rightwing7.addBox(0F, 7F, -2F, 0, 7, 1); rightwing7.setRotationPoint(-2F, 2F, 2F); rightwing7.setTextureSize(64, 32); rightwing7.mirror = true; setRotation(rightwing7, 0.6981317F, -1.22173F, -0.3490659F); rightwing8 = new ModelRenderer(this, 36, 5); rightwing8.addBox(0F, 7F, 0F, 0, 2, 4); rightwing8.setRotationPoint(-2F, 2F, 2F); rightwing8.setTextureSize(64, 32); rightwing8.mirror = true; setRotation(rightwing8, 0.6981317F, -1.22173F, -0.3490659F); rightwing9 = new ModelRenderer(this, 44, 0); rightwing9.addBox(0F, 9F, 0F, 0, 1, 5); rightwing9.setRotationPoint(-2F, 2F, 2F); rightwing9.setTextureSize(64, 32); rightwing9.mirror = true; setRotation(rightwing9, 0.6981317F, -1.22173F, -0.3490659F); rightwing10 = new ModelRenderer(this, 54, 0); rightwing10.addBox(0F, 10F, 0F, 0, 2, 3); rightwing10.setRotationPoint(-2F, 2F, 2F); rightwing10.setTextureSize(64, 32); rightwing10.mirror = true; setRotation(rightwing10, 0.6981317F, -1.22173F, -0.3490659F); rightwing11 = new ModelRenderer(this, 36, 0); rightwing11.addBox(0F, 12F, 0F, 0, 1, 4); rightwing11.setRotationPoint(-2F, 2F, 2F); rightwing11.setTextureSize(64, 32); rightwing11.mirror = true; setRotation(rightwing11, 0.6981317F, -1.22173F, -0.3490659F); rightwing12 = new ModelRenderer(this, 56, 5); rightwing12.addBox(0F, 13F, 0F, 0, 1, 2); rightwing12.setRotationPoint(-2F, 2F, 2F); rightwing12.setTextureSize(64, 32); rightwing12.mirror = true; setRotation(rightwing12, 0.6981317F, -1.22173F, -0.3490659F); righthorn1 = new ModelRenderer(this, 36, 11); righthorn1.addBox(0F, 0F, 0F, 1, 2, 1); righthorn1.setRotationPoint(-3F, -7.3F, -1F); righthorn1.setTextureSize(64, 32); righthorn1.mirror = true; setRotation(righthorn1, 0F, 0F, 2.356194F); righthorn2 = new ModelRenderer(this, 36, 14); righthorn2.addBox(0F, 0F, 0F, 1, 1, 1); righthorn2.setRotationPoint(-4.2F, -8.3F, -1F); righthorn2.setTextureSize(64, 32); righthorn2.mirror = true; setRotation(righthorn2, 0F, 0F, 2.792527F); righthorn3 = new ModelRenderer(this, 40, 11); righthorn3.addBox(0F, 0F, 0F, 1, 1, 1); righthorn3.setRotationPoint(-4.5F, -8.7F, -1F); righthorn3.setTextureSize(64, 32); righthorn3.mirror = true; setRotation(righthorn3, 0F, 0F, -3.001966F); righthorn4 = new ModelRenderer(this, 40, 13); righthorn4.addBox(0F, 0F, 0F, 1, 1, 1); righthorn4.setRotationPoint(-4.8F, -9F, -1F); righthorn4.setTextureSize(64, 32); righthorn4.mirror = true; setRotation(righthorn4, 0F, 0F, -2.146755F); lefthorn1 = new ModelRenderer(this, 36, 11); lefthorn1.addBox(0F, 0F, 0F, 1, 2, 1); lefthorn1.setRotationPoint(3F, -7.3F, 0F); lefthorn1.setTextureSize(64, 32); lefthorn1.mirror = true; setRotation(lefthorn1, 0F, 3.141593F, 2.356194F); lefthorn2 = new ModelRenderer(this, 36, 14); lefthorn2.addBox(0F, 0F, 0F, 1, 1, 1); lefthorn2.setRotationPoint(4.2F, -8.3F, 0F); lefthorn2.setTextureSize(64, 32); lefthorn2.mirror = true; setRotation(lefthorn2, 0F, 3.141593F, 2.792527F); lefthorn3 = new ModelRenderer(this, 40, 11); lefthorn3.addBox(0F, 0F, 0F, 1, 1, 1); lefthorn3.setRotationPoint(4.5F, -8.7F, 0F); lefthorn3.setTextureSize(64, 32); lefthorn3.mirror = true; setRotation(lefthorn3, 0F, 3.141593F, -3.001966F); lefthorn4 = new ModelRenderer(this, 40, 13); lefthorn4.addBox(0F, 0F, 0F, 1, 1, 1); lefthorn4.setRotationPoint(4.8F, -9F, 0F); lefthorn4.setTextureSize(64, 32); lefthorn4.mirror = true; setRotation(lefthorn4, 0F, 3.141593F, -2.146755F); } 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, entity); head.render(f5); body.render(f5); rightarm.render(f5); leftarm.render(f5); rightleg.render(f5); leftleg.render(f5); leftfinger1.render(f5); leftfinger2.render(f5); leftfinger3.render(f5); leftfinger4.render(f5); leftfinger5.render(f5); rightfinger1.render(f5); rightfinger2.render(f5); rightfinger3.render(f5); rightfinger4.render(f5); rightfinger5.render(f5); leftwing1.render(f5); leftwing2.render(f5); leftwing3.render(f5); leftwing4.render(f5); leftwing5.render(f5); leftwing6.render(f5); leftwing7.render(f5); leftwing8.render(f5); leftwing9.render(f5); leftwing10.render(f5); leftwing11.render(f5); leftwing12.render(f5); rightwing1.render(f5); rightwing2.render(f5); rightwing3.render(f5); rightwing4.render(f5); rightwing5.render(f5); rightwing6.render(f5); rightwing7.render(f5); rightwing8.render(f5); rightwing9.render(f5); rightwing10.render(f5); rightwing11.render(f5); rightwing12.render(f5); righthorn1.render(f5); righthorn2.render(f5); righthorn3.render(f5); righthorn4.render(f5); lefthorn1.render(f5); lefthorn2.render(f5); lefthorn3.render(f5); lefthorn4.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, Entity entity) { super.setRotationAngles(f, f1, f2, f3, f4, f5, entity); } }
-
Je pense que ça vient des .mirror = true.
-
C’est pas plutôt pour la texture le Mirror ?
-
Il faudrait mettre les .mirror à false ?
Edit : Non, je les ai mis à false, mais ça ne marche pas. Après observation, je remarque que l’un des “doubles” ne bouge pas du tout. Il ne fait qu’être immobile, à la position exacte du second double.
-
Ta classe du model est extends à model biped. Model biped est déjà un model “custom”. Donc tu dois extend à ModelBase. Et le render pareil !
Ensuite concernant le render, je remarque quelques anomalies :
La ligne déclarant la texture doit être au dessus du ressource location. En gros, comme ça :
public final ResourceLocation texture = new ResourceLocation(ModTest.MODID, "textures/entity/demon.png"); public RenderDemon(ModelDemon model, float shadow) { super(model, shadow); }
Ensuite pour les deux méthodes getTexture, il y en a une avec “EntityLiving”… NE JAMAIS TOUCHER A CE PARAMÈTRE ! À changer en “Entity”.
Voili voilou. Ah, et si cela viendrait d’un mirored, le jeux crasherai !
PS: dans ta ligne :
public final ResourceLocation texture = new ResourceLocation(ModTest.MODID, "textures/entity/demon.png");
il n’y a pas le “:” d’écrit, si ta texture n’apparait pas, tu sais ce qu’il te reste à faire !
-
Dans le render, je extend à quoi ?
-
RenderLiving il me semble
-
@‘agabou’:
Dans le render, je extend à quoi ?
RenderLiving
-
C’est ça que j’ai fait, mais il n’a aucune animation de mouvement. Je vais corriger cela. Merci !