Résolu Problème render
-
Bonjour/Bonsoir, j’ai créé un mod avec deux Dragons, mais quand je fais spawn le dragon de glace, il possède le rendu du dragon de feu. C’est sûrement dû à une erreur bête mais après plusieurs heures passées dessus, je ne trouve rien :'(.
Code :
RenderIceDragon.java :
package fr.MrBlockTNT.Dragons.render; import java.util.Random; import net.minecraft.client.renderer.OpenGlHelper; import net.minecraft.client.renderer.RenderHelper; import net.minecraft.client.renderer.Tessellator; import net.minecraft.client.renderer.entity.RenderLiving; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLiving; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.boss.BossStatus; import net.minecraft.util.MathHelper; import net.minecraft.util.ResourceLocation; import org.lwjgl.opengl.GL11; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import fr.MrBlockTNT.Dragons.entity.icedragon.EntityIceDragon; import fr.MrBlockTNT.Dragons.models.ModelIceDragon; @SideOnly(Side.CLIENT) public class RenderIceDragon extends RenderLiving { private static final ResourceLocation iceDragonExplodingTextures = new ResourceLocation("dragons", "entity/icedragon/dragon_exploding.png"); private static final ResourceLocation iceDragonCrystalBeamTextures = new ResourceLocation("dragons", "entity/crystal/crystal_beam.png"); private static final ResourceLocation iceDragonEyesTextures = new ResourceLocation("dragons", "entity/icedragon/dragon_eyes.png"); private static final ResourceLocation iceDragonTextures = new ResourceLocation("dragons", "entity/icedragon/dragon.png"); /** An instance of the dragon model in RenderDragon */ protected ModelIceDragon modelDragon; public RenderIceDragon() { super(new ModelIceDragon(0.0F), 0.5F); this.modelDragon = (ModelIceDragon)this.mainModel; this.setRenderPassModel(this.mainModel); } protected void rotateCorpse(EntityIceDragon par1EntityDragon, float par2, float par3, float par4) { float f3 = (float)par1EntityDragon.getMovementOffsets(7, par4)[0]; float f4 = (float)(par1EntityDragon.getMovementOffsets(5, par4)[1] - par1EntityDragon.getMovementOffsets(10, par4)[1]); GL11.glRotatef(-f3, 0.0F, 1.0F, 0.0F); GL11.glRotatef(f4 * 10.0F, 1.0F, 0.0F, 0.0F); GL11.glTranslatef(0.0F, 0.0F, 1.0F); if(par1EntityDragon.deathTime > 0) { float f5 = ((float)par1EntityDragon.deathTime + par4 - 1.0F) / 20.0F * 1.6F; f5 = MathHelper.sqrt_float(f5); if(f5 > 1.0F) { f5 = 1.0F; } GL11.glRotatef(f5 * this.getDeathMaxRotation(par1EntityDragon), 0.0F, 0.0F, 1.0F); } } /** * Renders the model in RenderLiving */ protected void renderModel(EntityIceDragon par1EntityDragon, float par2, float par3, float par4, float par5, float par6, float par7) { if(par1EntityDragon.deathTicks > 0) { float f6 = (float)par1EntityDragon.deathTicks / 200.0F; GL11.glDepthFunc(GL11.GL_LEQUAL); GL11.glEnable(GL11.GL_ALPHA_TEST); GL11.glAlphaFunc(GL11.GL_GREATER, f6); this.bindTexture(iceDragonExplodingTextures); this.mainModel.render(par1EntityDragon, par2, par3, par4, par5, par6, par7); GL11.glAlphaFunc(GL11.GL_GREATER, 0.1F); GL11.glDepthFunc(GL11.GL_EQUAL); } this.bindEntityTexture(par1EntityDragon); this.mainModel.render(par1EntityDragon, par2, par3, par4, par5, par6, par7); if(par1EntityDragon.hurtTime > 0) { GL11.glDepthFunc(GL11.GL_EQUAL); GL11.glDisable(GL11.GL_TEXTURE_2D); GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GL11.glColor4f(1.0F, 0.0F, 0.0F, 0.5F); this.mainModel.render(par1EntityDragon, par2, par3, par4, par5, par6, par7); GL11.glEnable(GL11.GL_TEXTURE_2D); GL11.glDisable(GL11.GL_BLEND); GL11.glDepthFunc(GL11.GL_LEQUAL); } } /** * Actually renders the given argument. This is a synthetic bridge method, always casting down its argument and then * handing it off to a worker function which does the actual work. In all probabilty, the class Render is generic * (Render <t extends="" entity)="" and="" this="" method="" has="" signature="" public="" void="" func_76986_a(t="" entity,="" double="" d,="" d1,<br="">* double d2, float f, float f1). But JAD * is pre 1.5 so doesn't do that. */ public void doRender(EntityIceDragon par1EntityDragon, double par2, double par4, double par6, float par8, float par9) { BossStatus.setBossStatus(par1EntityDragon, false); super.doRender((EntityLiving)par1EntityDragon, par2, par4, par6, par8, par9); if(par1EntityDragon.healingIceCrystal != null) { float f2 = (float)par1EntityDragon.healingIceCrystal.innerRotation + par9; float f3 = MathHelper.sin(f2 * 0.2F) / 2.0F + 0.5F; f3 = (f3 * f3 + f3) * 0.2F; float f4 = (float)(par1EntityDragon.healingIceCrystal.posX - par1EntityDragon.posX - (par1EntityDragon.prevPosX - par1EntityDragon.posX) * (double)(1.0F - par9)); float f5 = (float)((double)f3 + par1EntityDragon.healingIceCrystal.posY - 1.0D - par1EntityDragon.posY - (par1EntityDragon.prevPosY - par1EntityDragon.posY) * (double)(1.0F - par9)); float f6 = (float)(par1EntityDragon.healingIceCrystal.posZ - par1EntityDragon.posZ - (par1EntityDragon.prevPosZ - par1EntityDragon.posZ) * (double)(1.0F - par9)); float f7 = MathHelper.sqrt_float(f4 * f4 + f6 * f6); float f8 = MathHelper.sqrt_float(f4 * f4 + f5 * f5 + f6 * f6); GL11.glPushMatrix(); GL11.glTranslatef((float)par2, (float)par4 + 2.0F, (float)par6); GL11.glRotatef((float)(-Math.atan2((double)f6, (double)f4)) * 180.0F / (float)Math.PI - 90.0F, 0.0F, 1.0F, 0.0F); GL11.glRotatef((float)(-Math.atan2((double)f7, (double)f5)) * 180.0F / (float)Math.PI - 90.0F, 1.0F, 0.0F, 0.0F); Tessellator tessellator = Tessellator.instance; RenderHelper.disableStandardItemLighting(); GL11.glDisable(GL11.GL_CULL_FACE); this.bindTexture(iceDragonCrystalBeamTextures); GL11.glShadeModel(GL11.GL_SMOOTH); float f9 = 0.0F - ((float)par1EntityDragon.ticksExisted + par9) * 0.01F; float f10 = MathHelper.sqrt_float(f4 * f4 + f5 * f5 + f6 * f6) / 32.0F - ((float)par1EntityDragon.ticksExisted + par9) * 0.01F; tessellator.startDrawing(5); byte b0 = 8; for(int i = 0; i <= b0; ++i) { float f11 = MathHelper.sin((float)(i % b0) * (float)Math.PI * 2.0F / (float)b0) * 0.75F; float f12 = MathHelper.cos((float)(i % b0) * (float)Math.PI * 2.0F / (float)b0) * 0.75F; float f13 = (float)(i % b0) * 1.0F / (float)b0; tessellator.setColorOpaque_I(0); tessellator.addVertexWithUV((double)(f11 * 0.2F), (double)(f12 * 0.2F), 0.0D, (double)f13, (double)f10); tessellator.setColorOpaque_I(16777215); tessellator.addVertexWithUV((double)f11, (double)f12, (double)f8, (double)f13, (double)f9); } tessellator.draw(); GL11.glEnable(GL11.GL_CULL_FACE); GL11.glShadeModel(GL11.GL_FLAT); RenderHelper.enableStandardItemLighting(); GL11.glPopMatrix(); } } /** * Returns the location of an entity's texture. Doesn't seem to be called unless you call Render.bindEntityTexture. */ protected ResourceLocation getEntityTexture(EntityIceDragon par1EntityDragon) { return iceDragonTextures; } protected void renderEquippedItems(EntityIceDragon par1EntityDragon, float par2) { super.renderEquippedItems(par1EntityDragon, par2); Tessellator tessellator = Tessellator.instance; if(par1EntityDragon.deathTicks > 0) { RenderHelper.disableStandardItemLighting(); float f1 = ((float)par1EntityDragon.deathTicks + par2) / 200.0F; float f2 = 0.0F; if(f1 > 0.8F) { f2 = (f1 - 0.8F) / 0.2F; } Random random = new Random(432L); GL11.glDisable(GL11.GL_TEXTURE_2D); GL11.glShadeModel(GL11.GL_SMOOTH); GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE); GL11.glDisable(GL11.GL_ALPHA_TEST); GL11.glEnable(GL11.GL_CULL_FACE); GL11.glDepthMask(false); GL11.glPushMatrix(); GL11.glTranslatef(0.0F, -1.0F, -2.0F); for(int i = 0; (float)i < (f1 + f1 * f1) / 2.0F * 60.0F; ++i) { GL11.glRotatef(random.nextFloat() * 360.0F, 1.0F, 0.0F, 0.0F); GL11.glRotatef(random.nextFloat() * 360.0F, 0.0F, 1.0F, 0.0F); GL11.glRotatef(random.nextFloat() * 360.0F, 0.0F, 0.0F, 1.0F); GL11.glRotatef(random.nextFloat() * 360.0F, 1.0F, 0.0F, 0.0F); GL11.glRotatef(random.nextFloat() * 360.0F, 0.0F, 1.0F, 0.0F); GL11.glRotatef(random.nextFloat() * 360.0F + f1 * 90.0F, 0.0F, 0.0F, 1.0F); tessellator.startDrawing(6); float f3 = random.nextFloat() * 20.0F + 5.0F + f2 * 10.0F; float f4 = random.nextFloat() * 2.0F + 1.0F + f2 * 2.0F; tessellator.setColorRGBA_I(16777215, (int)(255.0F * (1.0F - f2))); tessellator.addVertex(0.0D, 0.0D, 0.0D); tessellator.setColorRGBA_I(16711935, 0); tessellator.addVertex(-0.866D * (double)f4, (double)f3, (double)(-0.5F * f4)); tessellator.addVertex(0.866D * (double)f4, (double)f3, (double)(-0.5F * f4)); tessellator.addVertex(0.0D, (double)f3, (double)(1.0F * f4)); tessellator.addVertex(-0.866D * (double)f4, (double)f3, (double)(-0.5F * f4)); tessellator.draw(); } GL11.glPopMatrix(); GL11.glDepthMask(true); GL11.glDisable(GL11.GL_CULL_FACE); GL11.glDisable(GL11.GL_BLEND); GL11.glShadeModel(GL11.GL_FLAT); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); GL11.glEnable(GL11.GL_TEXTURE_2D); GL11.glEnable(GL11.GL_ALPHA_TEST); RenderHelper.enableStandardItemLighting(); } } /** * Queries whether should render the specified pass or not. */ protected int shouldRenderPass(EntityIceDragon par1EntityDragon, int par2, float par3) { if(par2 == 1) { GL11.glDepthFunc(GL11.GL_LEQUAL); } if(par2 != 0) { return -1; } else { this.bindTexture(iceDragonEyesTextures); GL11.glEnable(GL11.GL_BLEND); GL11.glDisable(GL11.GL_ALPHA_TEST); GL11.glBlendFunc(GL11.GL_ONE, GL11.GL_ONE); GL11.glDisable(GL11.GL_LIGHTING); GL11.glDepthFunc(GL11.GL_EQUAL); char c0 = 61680; int j = c0 % 65536; int k = c0 / 65536; OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, (float)j / 1.0F, (float)k / 1.0F); GL11.glEnable(GL11.GL_LIGHTING); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); return 1; } } /** * Actually renders the given argument. This is a synthetic bridge method, always casting down its argument and then * handing it off to a worker function which does the actual work. In all probabilty, the class Render is generic * (Render <t extends="" entity)="" and="" this="" method="" has="" signature="" public="" void="" func_76986_a(t="" entity,="" double="" d,="" d1,<br="">* double d2, float f, float f1). But JAD * is pre 1.5 so doesn't do that. */ public void doRender(EntityLiving par1EntityLiving, double par2, double par4, double par6, float par8, float par9) { this.doRender((EntityIceDragon)par1EntityLiving, par2, par4, par6, par8, par9); } /** * Queries whether should render the specified pass or not. */ protected int shouldRenderPass(EntityLivingBase par1EntityLivingBase, int par2, float par3) { return this.shouldRenderPass((EntityIceDragon)par1EntityLivingBase, par2, par3); } protected void renderEquippedItems(EntityLivingBase par1EntityLivingBase, float par2) { this.renderEquippedItems((EntityIceDragon)par1EntityLivingBase, par2); } protected void rotateCorpse(EntityLivingBase par1EntityLivingBase, float par2, float par3, float par4) { this.rotateCorpse((EntityIceDragon)par1EntityLivingBase, par2, par3, par4); } /** * Renders the model in RenderLiving */ protected void renderModel(EntityLivingBase par1EntityLivingBase, float par2, float par3, float par4, float par5, float par6, float par7) { this.renderModel((EntityIceDragon)par1EntityLivingBase, par2, par3, par4, par5, par6, par7); } /** * Actually renders the given argument. This is a synthetic bridge method, always casting down its argument and then * handing it off to a worker function which does the actual work. In all probabilty, the class Render is generic * (Render <t extends="" entity)="" and="" this="" method="" has="" signature="" public="" void="" func_76986_a(t="" entity,="" double="" d,="" d1,<br="">* double d2, float f, float f1). But JAD * is pre 1.5 so doesn't do that. */ public void doRender(EntityLivingBase par1Entity, double par2, double par4, double par6, float par8, float par9) { this.doRender((EntityIceDragon)par1Entity, par2, par4, par6, par8, par9); } /** * Returns the location of an entity's texture. Doesn't seem to be called unless you call Render.bindEntityTexture. */ protected ResourceLocation getEntityTexture(Entity par1Entity) { return this.getEntityTexture((EntityIceDragon)par1Entity); } /** * Actually renders the given argument. This is a synthetic bridge method, always casting down its argument and then * handing it off to a worker function which does the actual work. In all probabilty, the class Render is generic * (Render <t extends="" entity)="" and="" this="" method="" has="" signature="" public="" void="" func_76986_a(t="" entity,="" double="" d,="" d1,<br="">* double d2, float f, float f1). But JAD * is pre 1.5 so doesn't do that. */ public void doRender(Entity par1Entity, double par2, double par4, double par6, float par8, float par9) { this.doRender((EntityIceDragon)par1Entity, par2, par4, par6, par8, par9); } }
RenderFireDragon.java :
package fr.MrBlockTNT.Dragons.render; import java.util.Random; import net.minecraft.client.renderer.OpenGlHelper; import net.minecraft.client.renderer.RenderHelper; import net.minecraft.client.renderer.Tessellator; import net.minecraft.client.renderer.entity.RenderLiving; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLiving; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.boss.BossStatus; import net.minecraft.util.MathHelper; import net.minecraft.util.ResourceLocation; import org.lwjgl.opengl.GL11; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import fr.MrBlockTNT.Dragons.entity.firedragon.EntityFireDragon; import fr.MrBlockTNT.Dragons.models.ModelFireDragon; @SideOnly(Side.CLIENT) public class RenderFireDragon extends RenderLiving { private static final ResourceLocation fireDragonExplodingTextures = new ResourceLocation("dragons", "entity/firedragon/dragon_exploding.png"); private static final ResourceLocation fireDragonCrystalBeamTextures = new ResourceLocation("dragons", "entity/crystal/crystal_beam.png"); private static final ResourceLocation fireDragonEyesTextures = new ResourceLocation("dragons", "entity/firedragon/dragon_eyes.png"); private static final ResourceLocation fireDragonTextures = new ResourceLocation("dragons", "entity/firedragon/dragon.png"); /** An instance of the dragon model in RenderDragon */ protected ModelFireDragon modelDragon; public RenderFireDragon() { super(new ModelFireDragon(0.0F), 0.5F); this.modelDragon = (ModelFireDragon)this.mainModel; this.setRenderPassModel(this.mainModel); } protected void rotateCorpse(EntityFireDragon par1EntityDragon, float par2, float par3, float par4) { float f3 = (float)par1EntityDragon.getMovementOffsets(7, par4)[0]; float f4 = (float)(par1EntityDragon.getMovementOffsets(5, par4)[1] - par1EntityDragon.getMovementOffsets(10, par4)[1]); GL11.glRotatef(-f3, 0.0F, 1.0F, 0.0F); GL11.glRotatef(f4 * 10.0F, 1.0F, 0.0F, 0.0F); GL11.glTranslatef(0.0F, 0.0F, 1.0F); if(par1EntityDragon.deathTime > 0) { float f5 = ((float)par1EntityDragon.deathTime + par4 - 1.0F) / 20.0F * 1.6F; f5 = MathHelper.sqrt_float(f5); if(f5 > 1.0F) { f5 = 1.0F; } GL11.glRotatef(f5 * this.getDeathMaxRotation(par1EntityDragon), 0.0F, 0.0F, 1.0F); } } /** * Renders the model in RenderLiving */ protected void renderModel(EntityFireDragon par1EntityDragon, float par2, float par3, float par4, float par5, float par6, float par7) { if(par1EntityDragon.deathTicks > 0) { float f6 = (float)par1EntityDragon.deathTicks / 200.0F; GL11.glDepthFunc(GL11.GL_LEQUAL); GL11.glEnable(GL11.GL_ALPHA_TEST); GL11.glAlphaFunc(GL11.GL_GREATER, f6); this.bindTexture(fireDragonExplodingTextures); this.mainModel.render(par1EntityDragon, par2, par3, par4, par5, par6, par7); GL11.glAlphaFunc(GL11.GL_GREATER, 0.1F); GL11.glDepthFunc(GL11.GL_EQUAL); } this.bindEntityTexture(par1EntityDragon); this.mainModel.render(par1EntityDragon, par2, par3, par4, par5, par6, par7); if(par1EntityDragon.hurtTime > 0) { GL11.glDepthFunc(GL11.GL_EQUAL); GL11.glDisable(GL11.GL_TEXTURE_2D); GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GL11.glColor4f(1.0F, 0.0F, 0.0F, 0.5F); this.mainModel.render(par1EntityDragon, par2, par3, par4, par5, par6, par7); GL11.glEnable(GL11.GL_TEXTURE_2D); GL11.glDisable(GL11.GL_BLEND); GL11.glDepthFunc(GL11.GL_LEQUAL); } } /** * Actually renders the given argument. This is a synthetic bridge method, always casting down its argument and then * handing it off to a worker function which does the actual work. In all probabilty, the class Render is generic * (Render <t extends="" entity)="" and="" this="" method="" has="" signature="" public="" void="" func_76986_a(t="" entity,="" double="" d,="" d1,<br="">* double d2, float f, float f1). But JAD * is pre 1.5 so doesn't do that. */ public void doRender(EntityFireDragon par1EntityDragon, double par2, double par4, double par6, float par8, float par9) { BossStatus.setBossStatus(par1EntityDragon, false); super.doRender((EntityLiving)par1EntityDragon, par2, par4, par6, par8, par9); if(par1EntityDragon.healingFireCrystal != null) { float f2 = (float)par1EntityDragon.healingFireCrystal.innerRotation + par9; float f3 = MathHelper.sin(f2 * 0.2F) / 2.0F + 0.5F; f3 = (f3 * f3 + f3) * 0.2F; float f4 = (float)(par1EntityDragon.healingFireCrystal.posX - par1EntityDragon.posX - (par1EntityDragon.prevPosX - par1EntityDragon.posX) * (double)(1.0F - par9)); float f5 = (float)((double)f3 + par1EntityDragon.healingFireCrystal.posY - 1.0D - par1EntityDragon.posY - (par1EntityDragon.prevPosY - par1EntityDragon.posY) * (double)(1.0F - par9)); float f6 = (float)(par1EntityDragon.healingFireCrystal.posZ - par1EntityDragon.posZ - (par1EntityDragon.prevPosZ - par1EntityDragon.posZ) * (double)(1.0F - par9)); float f7 = MathHelper.sqrt_float(f4 * f4 + f6 * f6); float f8 = MathHelper.sqrt_float(f4 * f4 + f5 * f5 + f6 * f6); GL11.glPushMatrix(); GL11.glTranslatef((float)par2, (float)par4 + 2.0F, (float)par6); GL11.glRotatef((float)(-Math.atan2((double)f6, (double)f4)) * 180.0F / (float)Math.PI - 90.0F, 0.0F, 1.0F, 0.0F); GL11.glRotatef((float)(-Math.atan2((double)f7, (double)f5)) * 180.0F / (float)Math.PI - 90.0F, 1.0F, 0.0F, 0.0F); Tessellator tessellator = Tessellator.instance; RenderHelper.disableStandardItemLighting(); GL11.glDisable(GL11.GL_CULL_FACE); this.bindTexture(fireDragonCrystalBeamTextures); GL11.glShadeModel(GL11.GL_SMOOTH); float f9 = 0.0F - ((float)par1EntityDragon.ticksExisted + par9) * 0.01F; float f10 = MathHelper.sqrt_float(f4 * f4 + f5 * f5 + f6 * f6) / 32.0F - ((float)par1EntityDragon.ticksExisted + par9) * 0.01F; tessellator.startDrawing(5); byte b0 = 8; for(int i = 0; i <= b0; ++i) { float f11 = MathHelper.sin((float)(i % b0) * (float)Math.PI * 2.0F / (float)b0) * 0.75F; float f12 = MathHelper.cos((float)(i % b0) * (float)Math.PI * 2.0F / (float)b0) * 0.75F; float f13 = (float)(i % b0) * 1.0F / (float)b0; tessellator.setColorOpaque_I(0); tessellator.addVertexWithUV((double)(f11 * 0.2F), (double)(f12 * 0.2F), 0.0D, (double)f13, (double)f10); tessellator.setColorOpaque_I(16777215); tessellator.addVertexWithUV((double)f11, (double)f12, (double)f8, (double)f13, (double)f9); } tessellator.draw(); GL11.glEnable(GL11.GL_CULL_FACE); GL11.glShadeModel(GL11.GL_FLAT); RenderHelper.enableStandardItemLighting(); GL11.glPopMatrix(); } } /** * Returns the location of an entity's texture. Doesn't seem to be called unless you call Render.bindEntityTexture. */ protected ResourceLocation getEntityTexture(EntityFireDragon par1EntityDragon) { return fireDragonTextures; } protected void renderEquippedItems(EntityFireDragon par1EntityDragon, float par2) { super.renderEquippedItems(par1EntityDragon, par2); Tessellator tessellator = Tessellator.instance; if(par1EntityDragon.deathTicks > 0) { RenderHelper.disableStandardItemLighting(); float f1 = ((float)par1EntityDragon.deathTicks + par2) / 200.0F; float f2 = 0.0F; if(f1 > 0.8F) { f2 = (f1 - 0.8F) / 0.2F; } Random random = new Random(432L); GL11.glDisable(GL11.GL_TEXTURE_2D); GL11.glShadeModel(GL11.GL_SMOOTH); GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE); GL11.glDisable(GL11.GL_ALPHA_TEST); GL11.glEnable(GL11.GL_CULL_FACE); GL11.glDepthMask(false); GL11.glPushMatrix(); GL11.glTranslatef(0.0F, -1.0F, -2.0F); for(int i = 0; (float)i < (f1 + f1 * f1) / 2.0F * 60.0F; ++i) { GL11.glRotatef(random.nextFloat() * 360.0F, 1.0F, 0.0F, 0.0F); GL11.glRotatef(random.nextFloat() * 360.0F, 0.0F, 1.0F, 0.0F); GL11.glRotatef(random.nextFloat() * 360.0F, 0.0F, 0.0F, 1.0F); GL11.glRotatef(random.nextFloat() * 360.0F, 1.0F, 0.0F, 0.0F); GL11.glRotatef(random.nextFloat() * 360.0F, 0.0F, 1.0F, 0.0F); GL11.glRotatef(random.nextFloat() * 360.0F + f1 * 90.0F, 0.0F, 0.0F, 1.0F); tessellator.startDrawing(6); float f3 = random.nextFloat() * 20.0F + 5.0F + f2 * 10.0F; float f4 = random.nextFloat() * 2.0F + 1.0F + f2 * 2.0F; tessellator.setColorRGBA_I(16777215, (int)(255.0F * (1.0F - f2))); tessellator.addVertex(0.0D, 0.0D, 0.0D); tessellator.setColorRGBA_I(16711935, 0); tessellator.addVertex(-0.866D * (double)f4, (double)f3, (double)(-0.5F * f4)); tessellator.addVertex(0.866D * (double)f4, (double)f3, (double)(-0.5F * f4)); tessellator.addVertex(0.0D, (double)f3, (double)(1.0F * f4)); tessellator.addVertex(-0.866D * (double)f4, (double)f3, (double)(-0.5F * f4)); tessellator.draw(); } GL11.glPopMatrix(); GL11.glDepthMask(true); GL11.glDisable(GL11.GL_CULL_FACE); GL11.glDisable(GL11.GL_BLEND); GL11.glShadeModel(GL11.GL_FLAT); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); GL11.glEnable(GL11.GL_TEXTURE_2D); GL11.glEnable(GL11.GL_ALPHA_TEST); RenderHelper.enableStandardItemLighting(); } } /** * Queries whether should render the specified pass or not. */ protected int shouldRenderPass(EntityFireDragon par1EntityDragon, int par2, float par3) { if(par2 == 1) { GL11.glDepthFunc(GL11.GL_LEQUAL); } if(par2 != 0) { return -1; } else { this.bindTexture(fireDragonEyesTextures); GL11.glEnable(GL11.GL_BLEND); GL11.glDisable(GL11.GL_ALPHA_TEST); GL11.glBlendFunc(GL11.GL_ONE, GL11.GL_ONE); GL11.glDisable(GL11.GL_LIGHTING); GL11.glDepthFunc(GL11.GL_EQUAL); char c0 = 61680; int j = c0 % 65536; int k = c0 / 65536; OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, (float)j / 1.0F, (float)k / 1.0F); GL11.glEnable(GL11.GL_LIGHTING); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); return 1; } } /** * Actually renders the given argument. This is a synthetic bridge method, always casting down its argument and then * handing it off to a worker function which does the actual work. In all probabilty, the class Render is generic * (Render <t extends="" entity)="" and="" this="" method="" has="" signature="" public="" void="" func_76986_a(t="" entity,="" double="" d,="" d1,<br="">* double d2, float f, float f1). But JAD * is pre 1.5 so doesn't do that. */ public void doRender(EntityLiving par1EntityLiving, double par2, double par4, double par6, float par8, float par9) { this.doRender((EntityFireDragon)par1EntityLiving, par2, par4, par6, par8, par9); } /** * Queries whether should render the specified pass or not. */ protected int shouldRenderPass(EntityLivingBase par1EntityLivingBase, int par2, float par3) { return this.shouldRenderPass((EntityFireDragon)par1EntityLivingBase, par2, par3); } protected void renderEquippedItems(EntityLivingBase par1EntityLivingBase, float par2) { this.renderEquippedItems((EntityFireDragon)par1EntityLivingBase, par2); } protected void rotateCorpse(EntityLivingBase par1EntityLivingBase, float par2, float par3, float par4) { this.rotateCorpse((EntityFireDragon)par1EntityLivingBase, par2, par3, par4); } /** * Renders the model in RenderLiving */ protected void renderModel(EntityLivingBase par1EntityLivingBase, float par2, float par3, float par4, float par5, float par6, float par7) { this.renderModel((EntityFireDragon)par1EntityLivingBase, par2, par3, par4, par5, par6, par7); } /** * Actually renders the given argument. This is a synthetic bridge method, always casting down its argument and then * handing it off to a worker function which does the actual work. In all probabilty, the class Render is generic * (Render <t extends="" entity)="" and="" this="" method="" has="" signature="" public="" void="" func_76986_a(t="" entity,="" double="" d,="" d1,<br="">* double d2, float f, float f1). But JAD * is pre 1.5 so doesn't do that. */ public void doRender(EntityLivingBase par1Entity, double par2, double par4, double par6, float par8, float par9) { this.doRender((EntityFireDragon)par1Entity, par2, par4, par6, par8, par9); } /** * Returns the location of an entity's texture. Doesn't seem to be called unless you call Render.bindEntityTexture. */ protected ResourceLocation getEntityTexture(Entity par1Entity) { return this.getEntityTexture((EntityFireDragon)par1Entity); } /** * Actually renders the given argument. This is a synthetic bridge method, always casting down its argument and then * handing it off to a worker function which does the actual work. In all probabilty, the class Render is generic * (Render <t extends entity) and this method has signature public void func_76986_a(t entity, double d, d1,<br>* double d2, float f, float f1). But JAD * is pre 1.5 so doesn't do that. */ public void doRender(Entity par1Entity, double par2, double par4, double par6, float par8, float par9) { this.doRender((EntityFireDragon)par1Entity, par2, par4, par6, par8, par9); } }
ClientProxy.java :
package fr.MrBlockTNT.Dragons.proxy; import cpw.mods.fml.client.registry.RenderingRegistry; import fr.MrBlockTNT.Dragons.entity.firedragon.EntityFireDragon; import fr.MrBlockTNT.Dragons.render.RenderFireDragon; import fr.MrBlockTNT.Dragons.entity.icedragon.EntityIceDragon; import fr.MrBlockTNT.Dragons.render.RenderIceDragon; public class ClientProxy extends CommonProxy { @Override public void registerRender() { RenderingRegistry.registerEntityRenderingHandler(EntityFireDragon.class, new RenderFireDragon()); RenderingRegistry.registerEntityRenderingHandler(EntityIceDragon.class, new RenderIceDragon()); } }
Pouvez-vous m’aider ?
Merci. -
vérifiez que t’es deux dragon.png ne sois pas les même
-
Ce ne sont pas les même. De plus le nom du Dragon (Barre de vie de boss) est aussi Fire Dragon (au lieu de Ice Dragon).
-
Le reste du code ?
-
oue envoi els code des dragon tu as du faire une bourde
-
Ok :
EntityFireDragon.java :
public class EntityFireDragon extends EntityLiving implements IBossDisplayData { public String mobName; public double targetX; public double targetY; public double targetZ; public double[][] ringBuffer = new double[64][3]; public int ringBufferIndex = -1; public EntityFireDragonPart[] dragonPartArray; public EntityFireDragonPart dragonPartHead; public EntityFireDragonPart dragonPartBody; public EntityFireDragonPart dragonPartTail1; public EntityFireDragonPart dragonPartTail2; public EntityFireDragonPart dragonPartTail3; public EntityFireDragonPart dragonPartWing1; public EntityFireDragonPart dragonPartWing2; public float prevAnimTime; public float animTime; public boolean forceNewTarget; public boolean slowed; private Entity target; public int deathTicks; public EntityFireCrystal healingFireCrystal; public EntityFireDragon(World world) { super(world); mobName = "Fire Dragon"; this.dragonPartArray = new EntityFireDragonPart[] {this.dragonPartHead = new EntityFireDragonPart(this, "head", 6.0F, 6.0F), this.dragonPartBody = new EntityFireDragonPart(this, "body", 8.0F, 8.0F), this.dragonPartTail1 = new EntityFireDragonPart(this, "tail", 4.0F, 4.0F), this.dragonPartTail2 = new EntityFireDragonPart(this, "tail", 4.0F, 4.0F), this.dragonPartTail3 = new EntityFireDragonPart(this, "tail", 4.0F, 4.0F), this.dragonPartWing1 = new EntityFireDragonPart(this, "wing", 4.0F, 4.0F), this.dragonPartWing2 = new EntityFireDragonPart(this, "wing", 4.0F, 4.0F)}; this.setHealth(this.getMaxHealth()); this.setSize(16.0F, 8.0F); this.noClip = true; this.isImmuneToFire = true; this.targetY = 100.0D; this.ignoreFrustumCheck = true; } protected void applyEntityAttributes() { super.applyEntityAttributes(); this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(1000.0D); } protected void entityInit() { super.entityInit(); } public double[] getMovementOffsets(int par1, float par2) { if (this.getHealth() <= 0.0F) { par2 = 0.0F; } par2 = 1.0F - par2; int j = this.ringBufferIndex - par1 * 1 & 63; int k = this.ringBufferIndex - par1 * 1 - 1 & 63; double[] adouble = new double[3]; double d0 = this.ringBuffer[j][0]; double d1 = MathHelper.wrapAngleTo180_double(this.ringBuffer[k][0] - d0); adouble[0] = d0 + d1 * (double)par2; d0 = this.ringBuffer[j][1]; d1 = this.ringBuffer[k][1] - d0; adouble[1] = d0 + d1 * (double)par2; adouble[2] = this.ringBuffer[j][2] + (this.ringBuffer[k][2] - this.ringBuffer[j][2]) * (double)par2; return adouble; } public void onLivingUpdate() { float f; float f1; // IA - Caché :p if (this.worldObj.isRemote) { f = MathHelper.cos(this.animTime * (float)Math.PI * 2.0F); f1 = MathHelper.cos(this.prevAnimTime * (float)Math.PI * 2.0F); if (f1 <= -0.3F && f >= -0.3F) { this.worldObj.playSound(this.posX, this.posY, this.posZ, "mob.enderdragon.wings", 5.0F, 0.8F + this.rand.nextFloat() * 0.3F, false); } } this.prevAnimTime = this.animTime; float f2; if (this.getHealth() <= 0.0F) { f = (this.rand.nextFloat() - 0.5F) * 8.0F; f1 = (this.rand.nextFloat() - 0.5F) * 4.0F; f2 = (this.rand.nextFloat() - 0.5F) * 8.0F; this.worldObj.spawnParticle("largeexplode", this.posX + (double)f, this.posY + 2.0D + (double)f1, this.posZ + (double)f2, 0.0D, 0.0D, 0.0D); } else { this.updateDragonEnderCrystal(); f = 0.2F / (MathHelper.sqrt_double(this.motionX * this.motionX + this.motionZ * this.motionZ) * 10.0F + 1.0F); f *= (float)Math.pow(2.0D, this.motionY); if (this.slowed) { this.animTime += f * 0.5F; } else { this.animTime += f; } this.rotationYaw = MathHelper.wrapAngleTo180_float(this.rotationYaw); if (this.ringBufferIndex < 0) { for (int i = 0; i < this.ringBuffer.length; ++i) { this.ringBuffer*[0] = (double)this.rotationYaw; this.ringBuffer*[1] = this.posY; } } if (++this.ringBufferIndex == this.ringBuffer.length) { this.ringBufferIndex = 0; } this.ringBuffer[this.ringBufferIndex][0] = (double)this.rotationYaw; this.ringBuffer[this.ringBufferIndex][1] = this.posY; double d0; double d1; double d2; double d3; float f3; if (this.worldObj.isRemote) { if (this.newPosRotationIncrements > 0) { d3 = this.posX + (this.newPosX - this.posX) / (double)this.newPosRotationIncrements; d0 = this.posY + (this.newPosY - this.posY) / (double)this.newPosRotationIncrements; d1 = this.posZ + (this.newPosZ - this.posZ) / (double)this.newPosRotationIncrements; d2 = MathHelper.wrapAngleTo180_double(this.newRotationYaw - (double)this.rotationYaw); this.rotationYaw = (float)((double)this.rotationYaw + d2 / (double)this.newPosRotationIncrements); this.rotationPitch = (float)((double)this.rotationPitch + (this.newRotationPitch - (double)this.rotationPitch) / (double)this.newPosRotationIncrements); –this.newPosRotationIncrements; this.setPosition(d3, d0, d1); this.setRotation(this.rotationYaw, this.rotationPitch); } } else { d3 = this.targetX - this.posX; d0 = this.targetY - this.posY; d1 = this.targetZ - this.posZ; d2 = d3 * d3 + d0 * d0 + d1 * d1; if (this.target != null) { this.targetX = this.target.posX; this.targetZ = this.target.posZ; double d4 = this.targetX - this.posX; double d5 = this.targetZ - this.posZ; double d6 = Math.sqrt(d4 * d4 + d5 * d5); double d7 = 0.4000000059604645D + d6 / 80.0D - 1.0D; if (d7 > 10.0D) { d7 = 10.0D; } this.targetY = this.target.boundingBox.minY + d7; } else { this.targetX += this.rand.nextGaussian() * 2.0D; this.targetZ += this.rand.nextGaussian() * 2.0D; } if (this.forceNewTarget || d2 < 100.0D || d2 > 22500.0D || this.isCollidedHorizontally || this.isCollidedVertically) { this.setNewTarget(); } d0 /= (double)MathHelper.sqrt_double(d3 * d3 + d1 * d1); f3 = 0.6F; if (d0 < (double)(-f3)) { d0 = (double)(-f3); } if (d0 > (double)f3) { d0 = (double)f3; } this.motionY += d0 * 0.10000000149011612D; this.rotationYaw = MathHelper.wrapAngleTo180_float(this.rotationYaw); double d8 = 180.0D - Math.atan2(d3, d1) * 180.0D / Math.PI; double d9 = MathHelper.wrapAngleTo180_double(d8 - (double)this.rotationYaw); if (d9 > 50.0D) { d9 = 50.0D; } if (d9 < -50.0D) { d9 = -50.0D; } Vec3 vec3 = this.worldObj.getWorldVec3Pool().getVecFromPool(this.targetX - this.posX, this.targetY - this.posY, this.targetZ - this.posZ).normalize(); Vec3 vec31 = this.worldObj.getWorldVec3Pool().getVecFromPool((double)MathHelper.sin(this.rotationYaw * (float)Math.PI / 180.0F), this.motionY, (double)(-MathHelper.cos(this.rotationYaw * (float)Math.PI / 180.0F))).normalize(); float f4 = (float)(vec31.dotProduct(vec3) + 0.5D) / 1.5F; if (f4 < 0.0F) { f4 = 0.0F; } this.randomYawVelocity *= 0.8F; float f5 = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionZ * this.motionZ) * 1.0F + 1.0F; double d10 = Math.sqrt(this.motionX * this.motionX + this.motionZ * this.motionZ) * 1.0D + 1.0D; if (d10 > 40.0D) { d10 = 40.0D; } this.randomYawVelocity = (float)((double)this.randomYawVelocity + d9 * (0.699999988079071D / d10 / (double)f5)); this.rotationYaw += this.randomYawVelocity * 0.1F; float f6 = (float)(2.0D / (d10 + 1.0D)); float f7 = 0.06F; this.moveFlying(0.0F, -1.0F, f7 * (f4 * f6 + (1.0F - f6))); if (this.slowed) { this.moveEntity(this.motionX * 0.800000011920929D, this.motionY * 0.800000011920929D, this.motionZ * 0.800000011920929D); } else { this.moveEntity(this.motionX, this.motionY, this.motionZ); } Vec3 vec32 = this.worldObj.getWorldVec3Pool().getVecFromPool(this.motionX, this.motionY, this.motionZ).normalize(); float f8 = (float)(vec32.dotProduct(vec31) + 1.0D) / 2.0F; f8 = 0.8F + 0.15F * f8; this.motionX *= (double)f8; this.motionZ *= (double)f8; this.motionY *= 0.9100000262260437D; } this.renderYawOffset = this.rotationYaw; this.dragonPartHead.width = this.dragonPartHead.height = 3.0F; this.dragonPartTail1.width = this.dragonPartTail1.height = 2.0F; this.dragonPartTail2.width = this.dragonPartTail2.height = 2.0F; this.dragonPartTail3.width = this.dragonPartTail3.height = 2.0F; this.dragonPartBody.height = 3.0F; this.dragonPartBody.width = 5.0F; this.dragonPartWing1.height = 2.0F; this.dragonPartWing1.width = 4.0F; this.dragonPartWing2.height = 3.0F; this.dragonPartWing2.width = 4.0F; f1 = (float)(this.getMovementOffsets(5, 1.0F)[1] - this.getMovementOffsets(10, 1.0F)[1]) * 10.0F / 180.0F * (float)Math.PI; f2 = MathHelper.cos(f1); float f9 = -MathHelper.sin(f1); float f10 = this.rotationYaw * (float)Math.PI / 180.0F; float f11 = MathHelper.sin(f10); float f12 = MathHelper.cos(f10); this.dragonPartBody.onUpdate(); this.dragonPartBody.setLocationAndAngles(this.posX + (double)(f11 * 0.5F), this.posY, this.posZ - (double)(f12 * 0.5F), 0.0F, 0.0F); this.dragonPartWing1.onUpdate(); this.dragonPartWing1.setLocationAndAngles(this.posX + (double)(f12 * 4.5F), this.posY + 2.0D, this.posZ + (double)(f11 * 4.5F), 0.0F, 0.0F); this.dragonPartWing2.onUpdate(); this.dragonPartWing2.setLocationAndAngles(this.posX - (double)(f12 * 4.5F), this.posY + 2.0D, this.posZ - (double)(f11 * 4.5F), 0.0F, 0.0F); if (!this.worldObj.isRemote && this.hurtTime == 0) { if (!this.worldObj.isRemote && this.hurtTime == 0) { this.collideWithEntities(this.worldObj.getEntitiesWithinAABBExcludingEntity(this, this.dragonPartWing1.boundingBox.expand(4.0D, 2.0D, 4.0D).offset(0.0D, -2.0D, 0.0D))); this.collideWithEntities(this.worldObj.getEntitiesWithinAABBExcludingEntity(this, this.dragonPartWing2.boundingBox.expand(4.0D, 2.0D, 4.0D).offset(0.0D, -2.0D, 0.0D))); this.attackEntitiesInList(this.worldObj.getEntitiesWithinAABBExcludingEntity(this, this.dragonPartHead.boundingBox.expand(1.0D, 1.0D, 1.0D))); } } double[] adouble = this.getMovementOffsets(5, 1.0F); double[] adouble1 = this.getMovementOffsets(0, 1.0F); f3 = MathHelper.sin(this.rotationYaw * (float)Math.PI / 180.0F - this.randomYawVelocity * 0.01F); float f13 = MathHelper.cos(this.rotationYaw * (float)Math.PI / 180.0F - this.randomYawVelocity * 0.01F); this.dragonPartHead.onUpdate(); this.dragonPartHead.setLocationAndAngles(this.posX + (double)(f3 * 5.5F * f2), this.posY + (adouble1[1] - adouble[1]) * 1.0D + (double)(f9 * 5.5F), this.posZ - (double)(f13 * 5.5F * f2), 0.0F, 0.0F); for (int j = 0; j < 3; ++j) { EntityFireDragonPart entitydragonpart = null; if (j == 0) { entitydragonpart = this.dragonPartTail1; } if (j == 1) { entitydragonpart = this.dragonPartTail2; } if (j == 2) { entitydragonpart = this.dragonPartTail3; } double[] adouble2 = this.getMovementOffsets(12 + j * 2, 1.0F); float f14 = this.rotationYaw * (float)Math.PI / 180.0F + this.simplifyAngle(adouble2[0] - adouble[0]) * (float)Math.PI / 180.0F * 1.0F; float f15 = MathHelper.sin(f14); float f16 = MathHelper.cos(f14); float f17 = 1.5F; float f18 = (float)(j + 1) * 2.0F; entitydragonpart.onUpdate(); entitydragonpart.setLocationAndAngles(this.posX - (double)((f11 * f17 + f15 * f18) * f2), this.posY + (adouble2[1] - adouble[1]) * 1.0D - (double)((f18 + f17) * f9) + 1.5D, this.posZ + (double)((f12 * f17 + f16 * f18) * f2), 0.0F, 0.0F); } } } private void updateDragonEnderCrystal() { if (this.healingFireCrystal != null) { if (this.healingFireCrystal.isDead) { if (!this.worldObj.isRemote) { this.attackEntityFromPart(this.dragonPartHead, DamageSource.setExplosionSource((Explosion)null), 10.0F); } this.healingFireCrystal = null; } else if (this.ticksExisted % 10 == 0 && this.getHealth() < this.getMaxHealth()) { this.setHealth(this.getHealth() + 1.0F); } } if (this.rand.nextInt(10) == 0) { float f = 32.0F; List list = this.worldObj.getEntitiesWithinAABB(EntityFireCrystal.class, this.boundingBox.expand((double)f, (double)f, (double)f)); EntityFireCrystal entityendercrystal = null; double d0 = Double.MAX_VALUE; Iterator iterator = list.iterator(); while (iterator.hasNext()) { EntityFireCrystal entityendercrystal1 = (EntityFireCrystal)iterator.next(); double d1 = entityendercrystal1.getDistanceSqToEntity(this); if (d1 < d0) { d0 = d1; entityendercrystal = entityendercrystal1; } } this.healingFireCrystal = entityendercrystal; } } private void collideWithEntities(List par1List) { double d0 = (this.dragonPartBody.boundingBox.minX + this.dragonPartBody.boundingBox.maxX) / 2.0D; double d1 = (this.dragonPartBody.boundingBox.minZ + this.dragonPartBody.boundingBox.maxZ) / 2.0D; Iterator iterator = par1List.iterator(); while (iterator.hasNext()) { Entity entity = (Entity)iterator.next(); if (entity instanceof EntityLivingBase) { double d2 = entity.posX - d0; double d3 = entity.posZ - d1; double d4 = d2 * d2 + d3 * d3; entity.addVelocity(d2 / d4 * 4.0D, 0.20000000298023224D, d3 / d4 * 4.0D); } } } private void attackEntitiesInList(List par1List) { for (int i = 0; i < par1List.size(); ++i) { Entity entity = (Entity)par1List.get(i); if (entity instanceof EntityLivingBase) { entity.attackEntityFrom(DamageSource.causeMobDamage(this), 10.0F); } } } private void setNewTarget() { this.forceNewTarget = false; if (this.rand.nextInt(2) == 0 && !this.worldObj.playerEntities.isEmpty()) { this.target = (Entity)this.worldObj.playerEntities.get(this.rand.nextInt(this.worldObj.playerEntities.size())); } else { boolean flag = false; do { this.targetX = 0.0D; this.targetY = (double)(70.0F + this.rand.nextFloat() * 50.0F); this.targetZ = 0.0D; this.targetX += (double)(this.rand.nextFloat() * 120.0F - 60.0F); this.targetZ += (double)(this.rand.nextFloat() * 120.0F - 60.0F); double d0 = this.posX - this.targetX; double d1 = this.posY - this.targetY; double d2 = this.posZ - this.targetZ; flag = d0 * d0 + d1 * d1 + d2 * d2 > 100.0D; } while (!flag); this.target = null; } } private float simplifyAngle(double par1) { return (float)MathHelper.wrapAngleTo180_double(par1); } public boolean attackEntityFromPart(EntityFireDragonPart par1EntityDragonPart, DamageSource par2DamageSource, float par3) { if (par1EntityDragonPart != this.dragonPartHead) { par3 = par3 / 4.0F + 1.0F; } float f1 = this.rotationYaw * (float)Math.PI / 180.0F; float f2 = MathHelper.sin(f1); float f3 = MathHelper.cos(f1); this.targetX = this.posX + (double)(f2 * 5.0F) + (double)((this.rand.nextFloat() - 0.5F) * 2.0F); this.targetY = this.posY + (double)(this.rand.nextFloat() * 3.0F) + 1.0D; this.targetZ = this.posZ - (double)(f3 * 5.0F) + (double)((this.rand.nextFloat() - 0.5F) * 2.0F); this.target = null; if (par2DamageSource.getEntity() instanceof EntityPlayer || par2DamageSource.isExplosion()) { this.func_82195_e(par2DamageSource, par3); } return true; } public boolean attackEntityFrom(DamageSource par1DamageSource, float par2) { return false; } protected boolean func_82195_e(DamageSource par1DamageSource, float par2) { return super.attackEntityFrom(par1DamageSource, par2); } protected void onDeathUpdate() { Minecraft mc = Minecraft.getMinecraft(); EntityPlayer player = mc.thePlayer; ++this.deathTicks; if (this.deathTicks >= 180 && this.deathTicks <= 200) { float f = (this.rand.nextFloat() - 0.5F) * 8.0F; float f1 = (this.rand.nextFloat() - 0.5F) * 4.0F; float f2 = (this.rand.nextFloat() - 0.5F) * 8.0F; this.worldObj.spawnParticle("hugeexplosion", this.posX + (double)f, this.posY + 2.0D + (double)f1, this.posZ + (double)f2, 0.0D, 0.0D, 0.0D); } int i; int j; if (!this.worldObj.isRemote) { if (this.deathTicks > 150 && this.deathTicks % 5 == 0) { this.playEndSound(player, worldObj); i = 2500; while (i > 0) { j = EntityXPOrb.getXPSplit(i); i -= j; this.worldObj.spawnEntityInWorld(new EntityXPOrb(this.worldObj, this.posX, this.posY, this.posZ, j)); } } if (this.deathTicks == 1) { this.worldObj.playBroadcastSound(1018, (int)this.posX, (int)this.posY, (int)this.posZ, 0); } } this.moveEntity(0.0D, 0.10000000149011612D, 0.0D); this.renderYawOffset = this.rotationYaw += 20.0F; if (this.deathTicks == 200 && !this.worldObj.isRemote) { i = 5000; while (i > 0) { j = EntityXPOrb.getXPSplit(i); i -= j; this.worldObj.spawnEntityInWorld(new EntityXPOrb(this.worldObj, this.posX, this.posY, this.posZ, j)); } this.setDead(); } } protected void despawnEntity() {} public Entity[] getParts() { return this.dragonPartArray; } public boolean canBeCollidedWith() { return false; } public World func_82194_d() { return this.worldObj; } protected String getLivingSound() { return "mob.enderdragon.growl"; } protected String getHurtSound() { return "mob.enderdragon.hit"; } public String getDeathSound() { return "mob.enderdragon.death"; } protected float getSoundVolume() { return 5.0F; } }
EntityIceDragon.java
public class EntityIceDragon extends EntityLiving implements IBossDisplayData { public String mobName; public double targetX; public double targetY; public double targetZ; public double[][] ringBuffer = new double[64][3]; public int ringBufferIndex = -1; public EntityIceDragonPart[] dragonPartArray; public EntityIceDragonPart dragonPartHead; public EntityIceDragonPart dragonPartBody; public EntityIceDragonPart dragonPartTail1; public EntityIceDragonPart dragonPartTail2; public EntityIceDragonPart dragonPartTail3; public EntityIceDragonPart dragonPartWing1; public EntityIceDragonPart dragonPartWing2; public float prevAnimTime; public float animTime; public boolean forceNewTarget; public boolean slowed; private Entity target; public int deathTicks; public EntityIceCrystal healingIceCrystal; public EntityIceDragon(World world) { super(world); mobName = "Ice Dragon"; this.dragonPartArray = new EntityIceDragonPart[] {this.dragonPartHead = new EntityIceDragonPart(this, "head", 6.0F, 6.0F), this.dragonPartBody = new EntityIceDragonPart(this, "body", 8.0F, 8.0F), this.dragonPartTail1 = new EntityIceDragonPart(this, "tail", 4.0F, 4.0F), this.dragonPartTail2 = new EntityIceDragonPart(this, "tail", 4.0F, 4.0F), this.dragonPartTail3 = new EntityIceDragonPart(this, "tail", 4.0F, 4.0F), this.dragonPartWing1 = new EntityIceDragonPart(this, "wing", 4.0F, 4.0F), this.dragonPartWing2 = new EntityIceDragonPart(this, "wing", 4.0F, 4.0F)}; this.setHealth(this.getMaxHealth()); this.setSize(16.0F, 8.0F); this.noClip = true; this.isImmuneToFire = false; this.targetY = 100.0D; this.ignoreFrustumCheck = true; } protected void applyEntityAttributes() { super.applyEntityAttributes(); this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(2000.0D); } protected void entityInit() { super.entityInit(); } public double[] getMovementOffsets(int par1, float par2) { if (this.getHealth() <= 0.0F) { par2 = 0.0F; } par2 = 1.0F - par2; int j = this.ringBufferIndex - par1 * 1 & 63; int k = this.ringBufferIndex - par1 * 1 - 1 & 63; double[] adouble = new double[3]; double d0 = this.ringBuffer[j][0]; double d1 = MathHelper.wrapAngleTo180_double(this.ringBuffer[k][0] - d0); adouble[0] = d0 + d1 * (double)par2; d0 = this.ringBuffer[j][1]; d1 = this.ringBuffer[k][1] - d0; adouble[1] = d0 + d1 * (double)par2; adouble[2] = this.ringBuffer[j][2] + (this.ringBuffer[k][2] - this.ringBuffer[j][2]) * (double)par2; return adouble; } public void onLivingUpdate() { float f; float f1; // IA - Caché :p if (this.worldObj.isRemote) { f = MathHelper.cos(this.animTime * (float)Math.PI * 2.0F); f1 = MathHelper.cos(this.prevAnimTime * (float)Math.PI * 2.0F); if (f1 <= -0.3F && f >= -0.3F) { this.worldObj.playSound(this.posX, this.posY, this.posZ, "mob.enderdragon.wings", 5.0F, 0.8F + this.rand.nextFloat() * 0.3F, false); } } this.prevAnimTime = this.animTime; float f2; if (this.getHealth() <= 0.0F) { f = (this.rand.nextFloat() - 0.5F) * 8.0F; f1 = (this.rand.nextFloat() - 0.5F) * 4.0F; f2 = (this.rand.nextFloat() - 0.5F) * 8.0F; this.worldObj.spawnParticle("largeexplode", this.posX + (double)f, this.posY + 2.0D + (double)f1, this.posZ + (double)f2, 0.0D, 0.0D, 0.0D); } else { this.updateDragonEnderCrystal(); f = 0.2F / (MathHelper.sqrt_double(this.motionX * this.motionX + this.motionZ * this.motionZ) * 10.0F + 1.0F); f *= (float)Math.pow(2.0D, this.motionY); if (this.slowed) { this.animTime += f * 0.5F; } else { this.animTime += f; } this.rotationYaw = MathHelper.wrapAngleTo180_float(this.rotationYaw); if (this.ringBufferIndex < 0) { for (int i = 0; i < this.ringBuffer.length; ++i) { this.ringBuffer*[0] = (double)this.rotationYaw; this.ringBuffer*[1] = this.posY; } } if (++this.ringBufferIndex == this.ringBuffer.length) { this.ringBufferIndex = 0; } this.ringBuffer[this.ringBufferIndex][0] = (double)this.rotationYaw; this.ringBuffer[this.ringBufferIndex][1] = this.posY; double d0; double d1; double d2; double d3; float f3; if (this.worldObj.isRemote) { if (this.newPosRotationIncrements > 0) { d3 = this.posX + (this.newPosX - this.posX) / (double)this.newPosRotationIncrements; d0 = this.posY + (this.newPosY - this.posY) / (double)this.newPosRotationIncrements; d1 = this.posZ + (this.newPosZ - this.posZ) / (double)this.newPosRotationIncrements; d2 = MathHelper.wrapAngleTo180_double(this.newRotationYaw - (double)this.rotationYaw); this.rotationYaw = (float)((double)this.rotationYaw + d2 / (double)this.newPosRotationIncrements); this.rotationPitch = (float)((double)this.rotationPitch + (this.newRotationPitch - (double)this.rotationPitch) / (double)this.newPosRotationIncrements); –this.newPosRotationIncrements; this.setPosition(d3, d0, d1); this.setRotation(this.rotationYaw, this.rotationPitch); } } else { d3 = this.targetX - this.posX; d0 = this.targetY - this.posY; d1 = this.targetZ - this.posZ; d2 = d3 * d3 + d0 * d0 + d1 * d1; if (this.target != null) { this.targetX = this.target.posX; this.targetZ = this.target.posZ; double d4 = this.targetX - this.posX; double d5 = this.targetZ - this.posZ; double d6 = Math.sqrt(d4 * d4 + d5 * d5); double d7 = 0.4000000059604645D + d6 / 80.0D - 1.0D; if (d7 > 10.0D) { d7 = 10.0D; } this.targetY = this.target.boundingBox.minY + d7; } else { this.targetX += this.rand.nextGaussian() * 2.0D; this.targetZ += this.rand.nextGaussian() * 2.0D; } if (this.forceNewTarget || d2 < 100.0D || d2 > 22500.0D || this.isCollidedHorizontally || this.isCollidedVertically) { this.setNewTarget(); } d0 /= (double)MathHelper.sqrt_double(d3 * d3 + d1 * d1); f3 = 0.6F; if (d0 < (double)(-f3)) { d0 = (double)(-f3); } if (d0 > (double)f3) { d0 = (double)f3; } this.motionY += d0 * 0.10000000149011612D; this.rotationYaw = MathHelper.wrapAngleTo180_float(this.rotationYaw); double d8 = 180.0D - Math.atan2(d3, d1) * 180.0D / Math.PI; double d9 = MathHelper.wrapAngleTo180_double(d8 - (double)this.rotationYaw); if (d9 > 50.0D) { d9 = 50.0D; } if (d9 < -50.0D) { d9 = -50.0D; } Vec3 vec3 = this.worldObj.getWorldVec3Pool().getVecFromPool(this.targetX - this.posX, this.targetY - this.posY, this.targetZ - this.posZ).normalize(); Vec3 vec31 = this.worldObj.getWorldVec3Pool().getVecFromPool((double)MathHelper.sin(this.rotationYaw * (float)Math.PI / 180.0F), this.motionY, (double)(-MathHelper.cos(this.rotationYaw * (float)Math.PI / 180.0F))).normalize(); float f4 = (float)(vec31.dotProduct(vec3) + 0.5D) / 1.5F; if (f4 < 0.0F) { f4 = 0.0F; } this.randomYawVelocity *= 0.8F; float f5 = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionZ * this.motionZ) * 1.0F + 1.0F; double d10 = Math.sqrt(this.motionX * this.motionX + this.motionZ * this.motionZ) * 1.0D + 1.0D; if (d10 > 40.0D) { d10 = 40.0D; } this.randomYawVelocity = (float)((double)this.randomYawVelocity + d9 * (0.699999988079071D / d10 / (double)f5)); this.rotationYaw += this.randomYawVelocity * 0.1F; float f6 = (float)(2.0D / (d10 + 1.0D)); float f7 = 0.06F; this.moveFlying(0.0F, -1.0F, f7 * (f4 * f6 + (1.0F - f6))); if (this.slowed) { this.moveEntity(this.motionX * 0.800000011920929D, this.motionY * 0.800000011920929D, this.motionZ * 0.800000011920929D); } else { this.moveEntity(this.motionX, this.motionY, this.motionZ); } Vec3 vec32 = this.worldObj.getWorldVec3Pool().getVecFromPool(this.motionX, this.motionY, this.motionZ).normalize(); float f8 = (float)(vec32.dotProduct(vec31) + 1.0D) / 2.0F; f8 = 0.8F + 0.15F * f8; this.motionX *= (double)f8; this.motionZ *= (double)f8; this.motionY *= 0.9100000262260437D; } this.renderYawOffset = this.rotationYaw; this.dragonPartHead.width = this.dragonPartHead.height = 3.0F; this.dragonPartTail1.width = this.dragonPartTail1.height = 2.0F; this.dragonPartTail2.width = this.dragonPartTail2.height = 2.0F; this.dragonPartTail3.width = this.dragonPartTail3.height = 2.0F; this.dragonPartBody.height = 3.0F; this.dragonPartBody.width = 5.0F; this.dragonPartWing1.height = 2.0F; this.dragonPartWing1.width = 4.0F; this.dragonPartWing2.height = 3.0F; this.dragonPartWing2.width = 4.0F; f1 = (float)(this.getMovementOffsets(5, 1.0F)[1] - this.getMovementOffsets(10, 1.0F)[1]) * 10.0F / 180.0F * (float)Math.PI; f2 = MathHelper.cos(f1); float f9 = -MathHelper.sin(f1); float f10 = this.rotationYaw * (float)Math.PI / 180.0F; float f11 = MathHelper.sin(f10); float f12 = MathHelper.cos(f10); this.dragonPartBody.onUpdate(); this.dragonPartBody.setLocationAndAngles(this.posX + (double)(f11 * 0.5F), this.posY, this.posZ - (double)(f12 * 0.5F), 0.0F, 0.0F); this.dragonPartWing1.onUpdate(); this.dragonPartWing1.setLocationAndAngles(this.posX + (double)(f12 * 4.5F), this.posY + 2.0D, this.posZ + (double)(f11 * 4.5F), 0.0F, 0.0F); this.dragonPartWing2.onUpdate(); this.dragonPartWing2.setLocationAndAngles(this.posX - (double)(f12 * 4.5F), this.posY + 2.0D, this.posZ - (double)(f11 * 4.5F), 0.0F, 0.0F); if (!this.worldObj.isRemote && this.hurtTime == 0) { this.collideWithEntities(this.worldObj.getEntitiesWithinAABBExcludingEntity(this, this.dragonPartWing1.boundingBox.expand(4.0D, 2.0D, 4.0D).offset(0.0D, -2.0D, 0.0D))); this.collideWithEntities(this.worldObj.getEntitiesWithinAABBExcludingEntity(this, this.dragonPartWing2.boundingBox.expand(4.0D, 2.0D, 4.0D).offset(0.0D, -2.0D, 0.0D))); this.attackEntitiesInList(this.worldObj.getEntitiesWithinAABBExcludingEntity(this, this.dragonPartHead.boundingBox.expand(1.0D, 1.0D, 1.0D))); } double[] adouble = this.getMovementOffsets(5, 1.0F); double[] adouble1 = this.getMovementOffsets(0, 1.0F); f3 = MathHelper.sin(this.rotationYaw * (float)Math.PI / 180.0F - this.randomYawVelocity * 0.01F); float f13 = MathHelper.cos(this.rotationYaw * (float)Math.PI / 180.0F - this.randomYawVelocity * 0.01F); this.dragonPartHead.onUpdate(); this.dragonPartHead.setLocationAndAngles(this.posX + (double)(f3 * 5.5F * f2), this.posY + (adouble1[1] - adouble[1]) * 1.0D + (double)(f9 * 5.5F), this.posZ - (double)(f13 * 5.5F * f2), 0.0F, 0.0F); for (int j = 0; j < 3; ++j) { EntityIceDragonPart entitydragonpart = null; if (j == 0) { entitydragonpart = this.dragonPartTail1; } if (j == 1) { entitydragonpart = this.dragonPartTail2; } if (j == 2) { entitydragonpart = this.dragonPartTail3; } double[] adouble2 = this.getMovementOffsets(12 + j * 2, 1.0F); float f14 = this.rotationYaw * (float)Math.PI / 180.0F + this.simplifyAngle(adouble2[0] - adouble[0]) * (float)Math.PI / 180.0F * 1.0F; float f15 = MathHelper.sin(f14); float f16 = MathHelper.cos(f14); float f17 = 1.5F; float f18 = (float)(j + 1) * 2.0F; entitydragonpart.onUpdate(); entitydragonpart.setLocationAndAngles(this.posX - (double)((f11 * f17 + f15 * f18) * f2), this.posY + (adouble2[1] - adouble[1]) * 1.0D - (double)((f18 + f17) * f9) + 1.5D, this.posZ + (double)((f12 * f17 + f16 * f18) * f2), 0.0F, 0.0F); } } } private void updateDragonEnderCrystal() { if (this.healingIceCrystal != null) { if (this.healingIceCrystal.isDead) { if (!this.worldObj.isRemote) { this.attackEntityFromPart(this.dragonPartHead, DamageSource.setExplosionSource((Explosion)null), 10.0F); } this.healingIceCrystal = null; } else if (this.ticksExisted % 10 == 0 && this.getHealth() < this.getMaxHealth()) { this.setHealth(this.getHealth() + 1.0F); } } if (this.rand.nextInt(10) == 0) { float f = 32.0F; List list = this.worldObj.getEntitiesWithinAABB(EntityIceCrystal.class, this.boundingBox.expand((double)f, (double)f, (double)f)); EntityIceCrystal entityendercrystal = null; double d0 = Double.MAX_VALUE; Iterator iterator = list.iterator(); while (iterator.hasNext()) { EntityIceCrystal entityendercrystal1 = (EntityIceCrystal)iterator.next(); double d1 = entityendercrystal1.getDistanceSqToEntity(this); if (d1 < d0) { d0 = d1; entityendercrystal = entityendercrystal1; } } this.healingIceCrystal = entityendercrystal; } } private void collideWithEntities(List par1List) { double d0 = (this.dragonPartBody.boundingBox.minX + this.dragonPartBody.boundingBox.maxX) / 2.0D; double d1 = (this.dragonPartBody.boundingBox.minZ + this.dragonPartBody.boundingBox.maxZ) / 2.0D; Iterator iterator = par1List.iterator(); while (iterator.hasNext()) { Entity entity = (Entity)iterator.next(); if (entity instanceof EntityLivingBase) { double d2 = entity.posX - d0; double d3 = entity.posZ - d1; double d4 = d2 * d2 + d3 * d3; entity.addVelocity(d2 / d4 * 4.0D, 0.20000000298023224D, d3 / d4 * 4.0D); } } } private void attackEntitiesInList(List par1List) { for (int i = 0; i < par1List.size(); ++i) { Entity entity = (Entity)par1List.get(i); if (entity instanceof EntityLivingBase) { entity.attackEntityFrom(DamageSource.causeMobDamage(this), 10.0F); } } } private void setNewTarget() { this.forceNewTarget = false; if (this.rand.nextInt(2) == 0 && !this.worldObj.playerEntities.isEmpty()) { this.target = (Entity)this.worldObj.playerEntities.get(this.rand.nextInt(this.worldObj.playerEntities.size())); } else { boolean flag = false; do { this.targetX = 0.0D; this.targetY = (double)(70.0F + this.rand.nextFloat() * 50.0F); this.targetZ = 0.0D; this.targetX += (double)(this.rand.nextFloat() * 120.0F - 60.0F); this.targetZ += (double)(this.rand.nextFloat() * 120.0F - 60.0F); double d0 = this.posX - this.targetX; double d1 = this.posY - this.targetY; double d2 = this.posZ - this.targetZ; flag = d0 * d0 + d1 * d1 + d2 * d2 > 100.0D; } while (!flag); this.target = null; } } private float simplifyAngle(double par1) { return (float)MathHelper.wrapAngleTo180_double(par1); } public boolean attackEntityFromPart(EntityIceDragonPart par1EntityDragonPart, DamageSource par2DamageSource, float par3) { if (par1EntityDragonPart != this.dragonPartHead) { par3 = par3 / 4.0F + 1.0F; } float f1 = this.rotationYaw * (float)Math.PI / 180.0F; float f2 = MathHelper.sin(f1); float f3 = MathHelper.cos(f1); this.targetX = this.posX + (double)(f2 * 5.0F) + (double)((this.rand.nextFloat() - 0.5F) * 2.0F); this.targetY = this.posY + (double)(this.rand.nextFloat() * 3.0F) + 1.0D; this.targetZ = this.posZ - (double)(f3 * 5.0F) + (double)((this.rand.nextFloat() - 0.5F) * 2.0F); this.target = null; if (par2DamageSource.getEntity() instanceof EntityPlayer || par2DamageSource.isExplosion()) { this.func_82195_e(par2DamageSource, par3); } return true; } public boolean attackEntityFrom(DamageSource par1DamageSource, float par2) { return false; } protected boolean func_82195_e(DamageSource par1DamageSource, float par2) { return super.attackEntityFrom(par1DamageSource, par2); } protected void onDeathUpdate() { Minecraft mc = Minecraft.getMinecraft(); EntityPlayer player = mc.thePlayer; ++this.deathTicks; if (this.deathTicks >= 180 && this.deathTicks <= 200) { float f = (this.rand.nextFloat() - 0.5F) * 8.0F; float f1 = (this.rand.nextFloat() - 0.5F) * 4.0F; float f2 = (this.rand.nextFloat() - 0.5F) * 8.0F; this.worldObj.spawnParticle("hugeexplosion", this.posX + (double)f, this.posY + 2.0D + (double)f1, this.posZ + (double)f2, 0.0D, 0.0D, 0.0D); } int i; int j; if (!this.worldObj.isRemote) { if (this.deathTicks > 150 && this.deathTicks % 5 == 0) { i = 3600; while (i > 0) { j = EntityXPOrb.getXPSplit(i); i -= j; this.worldObj.spawnEntityInWorld(new EntityXPOrb(this.worldObj, this.posX, this.posY, this.posZ, j)); } } if (this.deathTicks == 1) { this.worldObj.playBroadcastSound(1018, (int)this.posX, (int)this.posY, (int)this.posZ, 0); } } this.moveEntity(0.0D, 0.10000000149011612D, 0.0D); this.renderYawOffset = this.rotationYaw += 20.0F; if (this.deathTicks == 200 && !this.worldObj.isRemote) { i = 7200; while (i > 0) { j = EntityXPOrb.getXPSplit(i); i -= j; this.worldObj.spawnEntityInWorld(new EntityXPOrb(this.worldObj, this.posX, this.posY, this.posZ, j)); } this.setDead(); } } protected void despawnEntity() {} public Entity[] getParts() { return this.dragonPartArray; } public boolean canBeCollidedWith() { return false; } public World func_82194_d() { return this.worldObj; } protected String getLivingSound() { return "mob.enderdragon.growl"; } protected String getHurtSound() { return "mob.enderdragon.hit"; } public String getDeathSound() { return "mob.enderdragon.death"; } protected float getSoundVolume() { return 5.0F; } }
-
Et la classe principale ?
-
Après une nuit et un peu de recul, ce qui posait problème m’a paru évident :
EntityRegistry.registerModEntity(EntityIceDragon.class, “Ice Dragon”, 250, this.instance, 80, 1, true);
J’avais mis la valeur 250 (entity id je crois ?) pour l’enregistrement des deux entités ><".
Sujet résolu donc. Merci quand même