Animation de spawn et de mort d'une entité
-
Pourquoi créer une variable textureEvent alors que tu peux te servir de la valeur du timer ?
Et ta variable ne devrait pas être static. Une variable static n’a qu’une seul instance, donc si tu as plusieurs fois ton entité dans le monde elles vont partager la même valeur …package com.mod.panda.renders; import com.mod.panda.References; import com.mod.panda.entity.EntityPanda; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.client.model.ModelBase; import net.minecraft.client.renderer.entity.RenderLiving; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLiving; import net.minecraft.entity.boss.BossStatus; import net.minecraft.util.ResourceLocation; public class RenderPanda extends RenderLiving { private static ResourceLocation texture = new ResourceLocation(References.MOD_ID + ":textures/mobs/panda.png"); private static ResourceLocation texture_gen = new ResourceLocation(References.MOD_ID + ":textures/mobs/panda1.png"); public RenderPanda(ModelBase p_i1262_1_, float p_i1262_2_) { super(p_i1262_1_, p_i1262_2_); } protected ResourceLocation getEntiyTexture(EntityLiving living) { return this.getEntityTexture((EntityPanda) living); } @Override protected ResourceLocation getEntityTexture(Entity panda) { if(panda.tick < 385) { // en train de se générer return texture_gen; } return texture; } @SideOnly(Side.CLIENT) public void renderHealtBar(EntityPanda mob, double x, double y, double z, float par8, float par9) { BossStatus.setBossStatus(mob, true); super.doRender(mob, x, y, z, par8, par9); } public void doRender(Entity entity, double x, double y, double z, float par8, float par9) { this.renderHealtBar((EntityPanda)entity, x, y, z, par8, par9); } } -
@‘robin4002’:
Pourquoi créer une variable textureEvent alors que tu peux te servir de la valeur du timer ?
Et ta variable ne devrait pas être static. Une variable static n’a qu’une seul instance, donc si tu as plusieurs fois ton entité dans le monde elles vont partager la même valeur …package com.mod.panda.renders; import com.mod.panda.References; import com.mod.panda.entity.EntityPanda; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.client.model.ModelBase; import net.minecraft.client.renderer.entity.RenderLiving; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLiving; import net.minecraft.entity.boss.BossStatus; import net.minecraft.util.ResourceLocation; public class RenderPanda extends RenderLiving { private static ResourceLocation texture = new ResourceLocation(References.MOD_ID + ":textures/mobs/panda.png"); private static ResourceLocation texture_gen = new ResourceLocation(References.MOD_ID + ":textures/mobs/panda1.png"); public RenderPanda(ModelBase p_i1262_1_, float p_i1262_2_) { super(p_i1262_1_, p_i1262_2_); } protected ResourceLocation getEntiyTexture(EntityLiving living) { return this.getEntityTexture((EntityPanda) living); } @Override protected ResourceLocation getEntityTexture(Entity panda) { if(panda.tick < 385) { // en train de se générer return texture_gen; } return texture; } @SideOnly(Side.CLIENT) public void renderHealtBar(EntityPanda mob, double x, double y, double z, float par8, float par9) { BossStatus.setBossStatus(mob, true); super.doRender(mob, x, y, z, par8, par9); } public void doRender(Entity entity, double x, double y, double z, float par8, float par9) { this.renderHealtBar((EntityPanda)entity, x, y, z, par8, par9); } }merci mais je sais pas pourquoi ça veut pas marcher sans mètre la variable tick en static
-
protected ResourceLocation getEntityTexture(EntityPanda panda) { if(panda.tick < 385) { // en train de se générer return texture_gen; } return texture; }comme ça, ça devrait être bon.
-
@‘robin4002’:
protected ResourceLocation getEntityTexture(EntityPanda panda) { if(panda.tick < 385) { // en train de se générer return texture_gen; } return texture; }comme ça, ça devrait être bon.
euuh en mettant EntityPanda ça annule pas l’Overide ?
-
Tu n’as pas besoin d’avoir un override ici.
Par contre tu peux en mettre un sur cette fonction :
protected ResourceLocation getEntiyTexture(EntityLiving living)
{
return this.getEntityTexture((EntityPanda) living);
} -
@‘robin4002’:
Tu n’as pas besoin d’avoir un override ici.
Par contre tu peux en mettre un sur cette fonction :
protected ResourceLocation getEntiyTexture(EntityLiving living)
{
return this.getEntityTexture((EntityPanda) living);
}mais ducoups la classe ne détecte plus la méthode avec EntityPanda…
-
? Comment ça ? Il n’y a pas de raison pour que ça ne fonctionne pas.
-
@‘robin4002’:
? Comment ça ? Il n’y a pas de raison pour que ça ne fonctionne pas.
moi aussi je comprend pas
sur cette ligne (public class RenderPanda extends RenderLiving) sa écrit sur RenderPanda : “The type RenderPanda must implement the inherited abstract method Render.getEntityTexture(Entity)”
-
Eh bien sélectionne l’une des solutions proposées par eclipse. Ou manuellement, override la méthode abstraite Render#getEntityTexture

-
@‘Plaigon’:
Eh bien sélectionne l’une des solutions proposées par eclipse. Ou manuellement, override la méthode abstraite Render#getEntityTexture

dans les deux cas proposé par eclipse ça ne marche pas, par contre tu peut me détailler ta méthode ?
-
Donc remplaces :
protected ResourceLocation getEntiyTexture(EntityLiving living) { return this.getEntityTexture((EntityPanda) living); }par :
@Override protected ResourceLocation getEntiyTexture(Entity entity) { return this.getEntityTexture((EntityPanda) entity); } -
@‘robin4002’:
Donc remplaces :
protected ResourceLocation getEntiyTexture(EntityLiving living) { return this.getEntityTexture((EntityPanda) living); }par :
@Override protected ResourceLocation getEntiyTexture(Entity entity) { return this.getEntityTexture((EntityPanda) entity); }mais c’est pas possible là aussi, non ?
-
Si, ça devrait marcher, et si tu as copié/collé, n’oublie pas de rajouter un t au nom de la fonction à getEntityTexture, robin à juste fait une faute de frappe
-
@‘BrokenSwing’:
Si, ça devrait marcher, et si tu as copié/collé, n’oublie pas de rajouter un t au nom de la fonction à getEntityTexture, robin à juste fait une faute de frappe
XD c’etait une faute frappe mais le pire c’est que je me suis dis “cette fois si, je ne copie/colle pas” et j’ai fait moi même une faute de frappe XD : getEntityTexturez(Entity entity)
-
En fait ce n’étais même pas une faute de frappe, ce que j’ai mit était un copier/coller du code précédent x)
Et quand j’ai modifié l’argument je n’ai pas vu la faute, donc je ne l’ai pas corrigé. -
@‘robin4002’:
En fait ce n’étais même pas une faute de frappe, ce que j’ai mit était un copier/coller du code précédent x)
copier/coller’ception inverted over mega kill x)
par contre je bloque toujours sur le fait de move l’entity dans la fonction oneDeathUpdate, (peut importe ce que je met l’entité refuse de bouger elle fait que se tp de 0.01 bloc de plus avant de redescendre)
et de faire en sorte de mettre le (Minecraft.getMinecraft().getSoundHandler().stopSounds(); ) en @SideOnly(Side.CLIENT)
EDIT: ok, pour le cas du move j’ai déja une avancé, en fait le mob refuse de move tant qu’il n’est pas au sol ( il est move a la position donné puis retombe, au momment ou il touche le sol il est re-tp
-
File toute ta classe Entity
-
@‘Plaigon’:
File toute ta classe Entity
package com.mod.panda.entity; import com.mod.panda.References; import com.mod.panda.init.items; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.client.Minecraft; import net.minecraft.client.audio.PositionedSoundRecord; import net.minecraft.entity.IRangedAttackMob; import net.minecraft.entity.SharedMonsterAttributes; import net.minecraft.entity.ai.EntityAIArrowAttack; import net.minecraft.entity.ai.EntityAIAttackOnCollide; import net.minecraft.entity.ai.EntityAIHurtByTarget; import net.minecraft.entity.ai.EntityAILookIdle; import net.minecraft.entity.ai.EntityAIMoveThroughVillage; import net.minecraft.entity.ai.EntityAIMoveTowardsRestriction; import net.minecraft.entity.ai.EntityAINearestAttackableTarget; import net.minecraft.entity.ai.EntityAISwimming; import net.minecraft.entity.ai.EntityAIWander; import net.minecraft.entity.ai.EntityAIWatchClosest; import net.minecraft.entity.boss.BossStatus; import net.minecraft.entity.boss.IBossDisplayData; import net.minecraft.entity.effect.EntityLightningBolt; import net.minecraft.entity.item.EntityXPOrb; import net.minecraft.entity.monster.EntityMob; import net.minecraft.entity.passive.EntityVillager; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.potion.Potion; import net.minecraft.potion.PotionEffect; import net.minecraft.util.MathHelper; import net.minecraft.util.ResourceLocation; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import net.minecraftforge.client.event.sound.PlaySoundEvent; import net.minecraftforge.common.ForgeModContainer; public class EntityPanda extends EntityMob implements IBossDisplayData { public EntityPanda(World p_i1738_1_) { super(p_i1738_1_); isImmuneToFire = true; this.experienceValue = 200; this.getNavigator().setBreakDoors(true); this.tasks.addTask(0, new EntityAISwimming(this)); this.tasks.addTask(2, new EntityAIAttackOnCollide(this, EntityPlayer.class, 100.0D, false)); this.tasks.addTask(7, new EntityAIWander(this, 20.0D)); this.tasks.addTask(8, new EntityAIWatchClosest(this, EntityPlayer.class, 64.0F)); this.tasks.addTask(8, new EntityAILookIdle(this)); this.targetTasks.addTask(1, new EntityAIHurtByTarget(this, true)); this.targetTasks.addTask(2, new EntityAINearestAttackableTarget(this, EntityPlayer.class, 0, true)); this.setSize(0.3F, 2.2F); } protected String getHurtSound() { return References.MOD_ID + ":mob.panda.hurt"; } /*protected String getDeathSound() { return References.MOD_ID + ":mob.panda.death"; }*/ protected String getLivingSound() { return References.MOD_ID + ":mob.panda.living"; } protected void applyEntityAttributes() { super.applyEntityAttributes(); this.getEntityAttribute(SharedMonsterAttributes.followRange).setBaseValue(100.0D); this.getEntityAttribute(SharedMonsterAttributes.attackDamage).setBaseValue(100.0D); this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(2300.0D); this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(2.0D); } protected Item getDropItem() { return items.panda_leather; } protected Item getRareDropItem() { return items.panda_sword; } public int deathTick; public int tick; protected int client = 0; public void writeEntityToNBT(NBTTagCompound nbt) { super.writeEntityToNBT(nbt); nbt.setInteger("tick", tick); nbt.setInteger("deathTick", deathTick); } public void readEntityToNBT(NBTTagCompound nbt) { super.readEntityFromNBT(nbt); tick = nbt.getInteger("tick"); deathTick = nbt.getInteger("deathTick"); } public void onDeathUpdate() { if (this.deathTick < 79) { ++this.deathTick; if (this.deathTick > 2) { this.renderYawOffset = this.rotationYaw += 20.0F; } } else { super.onDeathUpdate(); } if(this.deathTick == 78) { 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); this.worldObj.playSoundEffect(this.posX, this.posY, this.posZ, "minecraft:random.explode", 5.0F, 1.0F); } /*if(this.deathTick == 1) { Minecraft.getMinecraft().getSoundHandler().stopSounds(); }*/ if(this.deathTick == 2) { this.worldObj.playSoundEffect(this.posX, this.posY, this.posZ, "pandamod:death", 5.0F, 1.0F); } } public void onUpdate() { if(this.tick < 385) { ++this.tick; this.setPosition(this.posX, this.posY+0.015, this.posZ); this.heal(6); } else { super.onUpdate(); } if(this.tick == 1) { this.setHealth(1F); } if(this.tick == 128) { this.spawnExplosionParticle(); this.worldObj.spawnEntityInWorld(new EntityLightningBolt(this.worldObj, this.posX, this.posY, this.posZ)); } if(this.tick == 160) { this.spawnExplosionParticle(); this.worldObj.spawnEntityInWorld(new EntityLightningBolt(this.worldObj, this.posX, this.posY, this.posZ)); } if(this.tick == 184) { this.spawnExplosionParticle(); this.worldObj.spawnEntityInWorld(new EntityLightningBolt(this.worldObj, this.posX, this.posY, this.posZ)); } if(this.tick == 192) { this.spawnExplosionParticle(); this.worldObj.spawnEntityInWorld(new EntityLightningBolt(this.worldObj, this.posX, this.posY, this.posZ)); } if(this.tick == 224) { this.spawnExplosionParticle(); this.worldObj.spawnEntityInWorld(new EntityLightningBolt(this.worldObj, this.posX, this.posY, this.posZ)); } if(this.tick == 246) { this.spawnExplosionParticle(); this.worldObj.spawnEntityInWorld(new EntityLightningBolt(this.worldObj, this.posX, this.posY, this.posZ)); } if(this.tick == 248) { this.spawnExplosionParticle(); this.worldObj.spawnEntityInWorld(new EntityLightningBolt(this.worldObj, this.posX, this.posY, this.posZ)); } if(this.tick == 250) { this.spawnExplosionParticle(); this.worldObj.spawnEntityInWorld(new EntityLightningBolt(this.worldObj, this.posX, this.posY, this.posZ)); } if(this.tick == 252) { this.spawnExplosionParticle(); this.worldObj.spawnEntityInWorld(new EntityLightningBolt(this.worldObj, this.posX, this.posY, this.posZ)); } if(this.tick == 256) { this.spawnExplosionParticle(); this.worldObj.spawnEntityInWorld(new EntityLightningBolt(this.worldObj, this.posX, this.posY, this.posZ)); } if(this.tick == 288) { this.spawnExplosionParticle(); this.worldObj.spawnEntityInWorld(new EntityLightningBolt(this.worldObj, this.posX, this.posY, this.posZ)); } if(this.tick == 312) { this.spawnExplosionParticle(); this.worldObj.spawnEntityInWorld(new EntityLightningBolt(this.worldObj, this.posX, this.posY, this.posZ)); } if(this.tick == 320) { this.spawnExplosionParticle(); this.worldObj.spawnEntityInWorld(new EntityLightningBolt(this.worldObj, this.posX, this.posY, this.posZ)); } if(this.tick == 384) { this.setPosition(this.posX, this.posY-2, this.posZ); } if(this.tick == 383) { this.spawnExplosionParticle(); 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); this.worldObj.playSoundEffect(this.posX, this.posY, this.posZ, "minecraft:random.explode", 5.0F, 1.0F); } } } -
Primo, ton mob ne pourra jamais être commandé par une véritable IA, tant que le getter EntityLivingBase#isAIEnabled, ne retournera pas true, or de base il est à false, faut donc que tu réécris la méthode.
Deuxièmement pour faire spawn tes éclairs, c’est la méthode World#addWeatherEffect, côté common, et non la méthode spawnEntityInWorld…
Troisèmement il ne faut pas appeler stopSounds, car ça stoppe normalement tous les sons, mais la méthode stopSound(ISound)
Et finalement debug toute ta méthode onDeathUpdate, pour voir ce qui et ce qui ne va pas…Si j’ai bien compris ce que tu souhaitais, à savoir diminuer la posY de ton mob lors de sa mort…Donc il faut mieux appeler un setPosition dans le onDeathUpdate.EDIT = j’ai oublié plusieurs choses importantes…
1)Tu dois forcément appelé un setDead à la fin de ton onDeathUpdate, sinon ton mob sera toujours considéré comme vivant…
2)Aère davantage ton code, c’est difficile à lire
3)Utilise tes notions en Java pour optimiser certaines choses, telle qu’un boucle while ou for, au choix, pour tous tes spawn de EntityLightingBolt, car là c’est un peu un gros bloc répétitif…Ou alors tu fais un switch à la limite, ça passerait même mieux
4)Et sais-tu que ton spawn final de particule au tick 383 est un peu inutile et à mon avis inobservable, du fait qu’il n’apparaîtra que durant un vingtième de tick ?? Après si je me souviens bien tu peux modifier la vélocité de ta particule sur les 3 axes grâce aux 3 derniers paramètres integer du spawnParticle, mais comme tu as mis 0 aux 3, ça m’étonnerait qu’elle reste très longtemps en l’air…Après encore une fois à toi de debug et de voir ce qu’il en est si tu mets tel ou tel chiffre.A mon avis y’a encore plein d’autres choses à dire, mais je laisserais les autres compléter

-
@‘Plaigon’:
Primo, ton mob ne pourra jamais être commandé par une véritable IA, tant que le getter EntityLivingBase#isAIEnabled, ne retournera pas true, or de base il est à false, faut donc que tu réécris la méthode.
Deuxièmement pour faire spawn tes éclairs, c’est la méthode World#addWeatherEffect, côté common, et non la méthode spawnEntityInWorld…
Troisèmement il ne faut pas appeler stopSounds, car ça stoppe normalement tous les sons, mais la méthode stopSound(ISound)
Et finalement debug toute ta méthode onDeathUpdate, pour voir ce qui et ce qui ne va pas…Si j’ai bien compris ce que tu souhaitais, à savoir diminuer la posY de ton mob lors de sa mort…Donc il faut mieux appeler un setPosition dans le onDeathUpdate.-
je ne comprend pas ce que tu veut que je fasse ?
-
a quoi bon faire ça si l’autre marche ?
-
le setposition ne marche pas aussi et quand j’utilise EXACTEMENT les même effet que l’enderdragon tout marche sauf ça
-
pour le reste je vais y travailler, par contre le spawn particle marche biens comme ça et elles apparaissent pendant plus de 20 ticks
EDIT: pour le set dead l’XP n’apparaît plus lors de la mort, je dois faire un spawnEntity ?
-