MFF

    Minecraft Forge France
    • Récent
    • Mots-clés
    • Populaire
    • Utilisateurs
    • Groupes
    • Forge Events
      • Automatique
      • Foncé
      • Clair
    • S'inscrire
    • Se connecter

    Animation de spawn et de mort d'une entité

    Planifier Épinglé Verrouillé Déplacé Résolu 1.7.x
    1.7.x
    74 Messages 8 Publieurs 13.0k Vues 1 Watching
    Charger plus de messages
    • Du plus ancien au plus récent
    • Du plus récent au plus ancien
    • Les plus votés
    Répondre
    • Répondre à l'aide d'un nouveau sujet
    Se connecter pour répondre
    Ce sujet a été supprimé. Seuls les utilisateurs avec les droits d'administration peuvent le voir.
    • robin4002R Hors-ligne
      robin4002 Moddeurs confirmés Rédacteurs Administrateurs
      dernière édition par

      En effet, il faudrait enregistrer la valeur du timer dans le tab nbt de l’entité pour éviter ça.

      Par contre, c’est la méthode ou la fonction onUpdate, pas l’événement onUpdate.
      Utilises les bons termes, sinon on ne peut pas se comprendre ;).

      1 réponse Dernière réponse Répondre Citer 0
      • LeBossMax2L Hors-ligne
        LeBossMax2
        dernière édition par

        Pour l’entité immobile, c’est normal : il faut que tu appelle “super.onUpdate()” pour que l’entité fonctionne normalement (il faut donc que tu le mette dans une condition qui vérifie si le timer est terminé). Pour spawn des éclaires, quel est le problème ? Si c’est que tu n’a pas accès au world, il faut que tu utilise “this.worldObj” (ou quelque chose dans ce genre).

        EDIT : J’aurais mieux fait de réactualiser l page avant de poster… 😕

        1 réponse Dernière réponse Répondre Citer 0
        • robin4002R Hors-ligne
          robin4002 Moddeurs confirmés Rédacteurs Administrateurs
          dernière édition par

          @‘LeBossMax2’:

          EDIT : J’aurais mieux fait de réactualiser l page avant de poster… 😕

          On a visiblement le même problème 😛

          1 réponse Dernière réponse Répondre Citer 0
          • jbamineJ Hors-ligne
            jbamine
            dernière édition par

            bon j’ai réussi après quelques heures ça marche parfaitement, par contre c’est possible de changer la texture du mob lors de l’animation pour qu’il soit noir?

            et j’ai pas réussi a enregistrer la valeur du timer dans la metadata, où je dois le mettre ?

            1 réponse Dernière réponse Répondre Citer 0
            • DeletedD Hors-ligne
              Deleted
              dernière édition par

              Pour changer la texture, faut faire une condition dans la méthode getEntityTexture de la classe du Render de ton mob. Faudrait faire en sorte d’avoir 2 ressource locations déclarées, et que en fonction de la valeur du timer, tu return celle que tu veux. Bien évidemment ton timer doit être déclaré comme private, et accessible via un getter. C’est plus esthétique et + caractéristique de la Programmation Orientée Objet.

              Ensuite, on ne parle pas de métadata quand il s’agit d’entity. Les métadatas ne concernent que les blocks/items. Là il faut les enregistrer dans les NBT de l’entity et ça, tu peux y arriver tout seul, c’est très facile…

              1 réponse Dernière réponse Répondre Citer 0
              • jbamineJ Hors-ligne
                jbamine
                dernière édition par

                @‘Plaigon’:

                Pour changer la texture, faut faire une condition dans la méthode getEntityTexture de la classe du Render de ton mob. Faudrait faire en sorte d’avoir 2 ressource locations déclarées, et que en fonction de la valeur du timer, tu return celle que tu veux. Bien évidemment ton timer doit être déclaré comme private, et accessible via un getter. C’est plus esthétique et + caractéristique de la Programmation Orientée Objet.

                Ensuite, on ne parle pas de métadata quand il s’agit d’entity. Les métadatas ne concernent que les blocks/items. Là il faut les enregistrer dans les NBT de l’entity et ça, tu peux y arriver tout seul, c’est très facile…

                merci j’ai réussi effectivement c’est simple merci 😉

                et par simple curiosité, il est possible d’interrompre une musique pour enclencher un son ? (dans mon cas c’est stopper la musique puis jouer le son de mort.

                EDIT: par contre je viens de créer l’animation de mort et j’ai mis la même commande de tp mais elle marche pas… (this.setPosition(this.posX, this.posY+0.2, this.posZ); )

                1 réponse Dernière réponse Répondre Citer 0
                • DeletedD Hors-ligne
                  Deleted
                  dernière édition par

                  Qu’est-ce qui ne marche pas ? Si tu l’as mis dans onUpdate, c’est normal, ce n’est plus appelé, je crois à la mort du joueur. Il faut plutôt te servir de la méthode onDeathupdate, et de la variable deathTime. prends exemple sur l’enderdragon.
                  Pour stopper le son, cela devrait t’aider : https://github.com/MinecraftForge/MinecraftForge/issues/1778

                  1 réponse Dernière réponse Répondre Citer 0
                  • jbamineJ Hors-ligne
                    jbamine
                    dernière édition par

                    @‘Plaigon’:

                    Qu’est-ce qui ne marche pas ? Si tu l’as mis dans onUpdate, c’est normal, ce n’est plus appelé, je crois à la mort du joueur. Il faut plutôt te servir de la méthode onDeathupdate, et de la variable deathTime. prends exemple sur l’enderdragon.
                    Pour stopper le son, cela devrait t’aider : https://github.com/MinecraftForge/MinecraftForge/issues/1778

                    c’est bon pour le son merci, et pour l’animation, j’ai beau littéralement copier coller l’animation de l’enderdragon, le mob ne bouge pas ( plus precisément il monte de quelques milimètres avant de retomber)

                    je viens de texter le mode serveur et ça ne marche pas, je n’arrive pas a mètre le chargement de la texture en client side

                    la classe render du mob:

                    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 net.minecraft.util.ResourceLocation texture;
                    public static void ResourceLocation()
                    {
                    if(com.mod.panda.entity.EntityPanda.textureEvent == 1)
                    {
                    texture = new ResourceLocation(References.MOD_ID + ":textures/mobs/panda1.png");
                    }
                    if(com.mod.panda.entity.EntityPanda.textureEvent == 0)
                    {
                    texture = new ResourceLocation(References.MOD_ID + ":textures/mobs/panda.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 p_110775_1_)
                    {
                    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);
                    }
                    }
                    
                    

                    et la classe de l’entité:

                    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.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.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 = 0;
                    public static int textureEvent = 0;
                    public void onDeathUpdate()
                    {
                    if (deathTick < 79)
                    {
                    ++deathTick;
                    if (deathTick > 2)
                    {
                    this.moveEntity(0.0D, 0.1D, 0.0D);
                           this.renderYawOffset = this.rotationYaw += 20.0F;
                    }
                    }
                    else
                    {
                    super.onDeathUpdate();
                    }
                    if(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(deathTick == 1)
                    {
                    Minecraft.getMinecraft().getSoundHandler().stopSounds();
                    }
                    if(deathTick == 2)
                    {
                    this.worldObj.playSoundEffect(this.posX, this.posY, this.posZ, "pandamod:death", 5.0F, 1.0F);
                    textureEvent = 1;
                    }
                    }
                    public int tick = 0;
                    public void onUpdate()
                    {
                    if(tick < 385)
                    {
                    ++tick;
                    this.setPosition(this.posX, this.posY+0.015, this.posZ);
                    this.heal(6);
                    }
                    else
                    {
                    super.onUpdate();
                    }
                    if(tick == 1)
                    {
                    this.setHealth(1F);
                    textureEvent = 1;
                    }
                    if(tick == 128)
                    {
                    this.spawnExplosionParticle();
                    this.worldObj.spawnEntityInWorld(new EntityLightningBolt(this.worldObj, this.posX, this.posY, this.posZ));
                    }
                    if(tick == 160)
                    {
                    this.spawnExplosionParticle();
                    this.worldObj.spawnEntityInWorld(new EntityLightningBolt(this.worldObj, this.posX, this.posY, this.posZ));
                    }
                    if(tick == 184)
                    {
                    this.spawnExplosionParticle();
                    this.worldObj.spawnEntityInWorld(new EntityLightningBolt(this.worldObj, this.posX, this.posY, this.posZ));
                    }
                    if(tick == 192)
                    {
                    this.spawnExplosionParticle();
                    this.worldObj.spawnEntityInWorld(new EntityLightningBolt(this.worldObj, this.posX, this.posY, this.posZ));
                    }
                    if(tick == 224)
                    {
                    this.spawnExplosionParticle();
                    this.worldObj.spawnEntityInWorld(new EntityLightningBolt(this.worldObj, this.posX, this.posY, this.posZ));
                    }
                    if(tick == 246)
                    {
                    this.spawnExplosionParticle();
                    this.worldObj.spawnEntityInWorld(new EntityLightningBolt(this.worldObj, this.posX, this.posY, this.posZ));
                    }
                    if(tick == 248)
                    {
                    this.spawnExplosionParticle();
                    this.worldObj.spawnEntityInWorld(new EntityLightningBolt(this.worldObj, this.posX, this.posY, this.posZ));
                    }
                    if(tick == 250)
                    {
                    this.spawnExplosionParticle();
                    this.worldObj.spawnEntityInWorld(new EntityLightningBolt(this.worldObj, this.posX, this.posY, this.posZ));
                    }
                    if(tick == 252)
                    {
                    this.spawnExplosionParticle();
                    this.worldObj.spawnEntityInWorld(new EntityLightningBolt(this.worldObj, this.posX, this.posY, this.posZ));
                    }
                    if(tick == 256)
                    {
                    this.spawnExplosionParticle();
                    this.worldObj.spawnEntityInWorld(new EntityLightningBolt(this.worldObj, this.posX, this.posY, this.posZ));
                    }
                    if(tick == 288)
                    {
                    this.spawnExplosionParticle();
                    this.worldObj.spawnEntityInWorld(new EntityLightningBolt(this.worldObj, this.posX, this.posY, this.posZ));
                    }
                    if(tick == 312)
                    {
                    this.spawnExplosionParticle();
                    this.worldObj.spawnEntityInWorld(new EntityLightningBolt(this.worldObj, this.posX, this.posY, this.posZ));
                    }
                    if(tick == 320)
                    {
                    this.spawnExplosionParticle();
                    this.worldObj.spawnEntityInWorld(new EntityLightningBolt(this.worldObj, this.posX, this.posY, this.posZ));
                    }
                    if(tick == 384)
                    {
                    this.setPosition(this.posX, this.posY-2, this.posZ);
                    }
                    if(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);
                               textureEvent = 0;
                    }
                    }
                    }
                    
                    1 réponse Dernière réponse Répondre Citer 0
                    • SCAREXS Hors-ligne
                      SCAREX
                      dernière édition par

                      Ton code pour le onDeathUpdate a l’air assez brouillon, mais est-ce qu’il est appelé correctement des 2 côtés ?

                      Pour le render : je comprends pas ce que tu veux faire au début car tu ne respectes pas la convention donc on sait pas si tu veux faire une sorte de constructeur, de fonction ou du code statique.

                      Site web contenant mes scripts : http://SCAREXgaming.github.io

                      Pas de demandes de support par MP ni par skype SVP.
                      Je n'accepte sur skype que l…

                      1 réponse Dernière réponse Répondre Citer 0
                      • jbamineJ Hors-ligne
                        jbamine
                        dernière édition par

                        @‘SCAREX’:

                        Ton code pour le onDeathUpdate a l’air assez brouillon, mais est-ce qu’il est appelé correctement des 2 côtés ?

                        Pour le render : je comprends pas ce que tu veux faire au début car tu ne respectes pas la convention donc on sait pas si tu veux faire une sorte de constructeur, de fonction ou du code statique.

                        tout ce qui du onDeathUpdate marche, c’est pour le changement  de texture que ça coince
                        EDIT : apparement ça bloque aussi sur le stop sound dans le onDeathUpdate

                        1 réponse Dernière réponse Répondre Citer 0
                        • SCAREXS Hors-ligne
                          SCAREX
                          dernière édition par

                          Normal, ton code ici est incompréhensible :

                          private static net.minecraft.util.ResourceLocation texture;
                          public static void ResourceLocation()
                          {
                          if(com.mod.panda.entity.EntityPanda.textureEvent == 1)
                          {
                          texture = new ResourceLocation(References.MOD_ID + ":textures/mobs/panda1.png");
                          }
                          if(com.mod.panda.entity.EntityPanda.textureEvent == 0)
                          {
                          texture = new ResourceLocation(References.MOD_ID + ":textures/mobs/panda.png");
                          }
                          }
                          

                          Site web contenant mes scripts : http://SCAREXgaming.github.io

                          Pas de demandes de support par MP ni par skype SVP.
                          Je n'accepte sur skype que l…

                          1 réponse Dernière réponse Répondre Citer 0
                          • jbamineJ Hors-ligne
                            jbamine
                            dernière édition par

                            @‘SCAREX’:

                            Normal, ton code ici est incompréhensible :

                            private static net.minecraft.util.ResourceLocation texture;
                               public static void ResourceLocation()
                               {
                                   if(com.mod.panda.entity.EntityPanda.textureEvent == 1)
                                   {
                                       texture = new ResourceLocation(References.MOD_ID + ":textures/mobs/panda1.png");
                                   }
                                   if(com.mod.panda.entity.EntityPanda.textureEvent == 0)
                                   {
                                       texture = new ResourceLocation(References.MOD_ID + ":textures/mobs/panda.png");
                                   }
                               }
                            

                            en bref j’aimerais que selon une variable dans la classe entity, ça charge une des deux textures

                            1 réponse Dernière réponse Répondre Citer 0
                            • DeletedD Hors-ligne
                              Deleted
                              dernière édition par

                              Eh bien faut faire varier le return du getEntityTexture

                              1 réponse Dernière réponse Répondre Citer 0
                              • jbamineJ Hors-ligne
                                jbamine
                                dernière édition par

                                @‘Plaigon’:

                                Eh bien faut faire varier le return du getEntityTexture

                                ok j’essaye merci

                                EDIT: bon j’y arrive pas je sais pas pourquoi mais le mob se retrouve invisible avec l’erreur

                                [18:34:56] [Client thread/ERROR]: Couldn't render entity
                                net.minecraft.util.ReportedException: Registering texture
                                at net.minecraft.client.renderer.texture.TextureManager.loadTexture(TextureManager.java:111) ~[TextureManager.class:?]
                                at net.minecraft.client.renderer.texture.TextureManager.bindTexture(TextureManager.java:45) ~[TextureManager.class:?]
                                at net.minecraft.client.renderer.entity.Render.bindTexture(Render.java:60) ~[Render.class:?]
                                at net.minecraft.client.renderer.entity.Render.bindEntityTexture(Render.java:55) ~[Render.class:?]
                                at net.minecraft.client.renderer.entity.RendererLivingEntity.renderModel(RendererLivingEntity.java:305) ~[RendererLivingEntity.class:?]
                                at net.minecraft.client.renderer.entity.RendererLivingEntity.doRender(RendererLivingEntity.java:165) [RendererLivingEntity.class:?]
                                at net.minecraft.client.renderer.entity.RenderLiving.doRender(RenderLiving.java:36) [RenderLiving.class:?]
                                at com.mod.panda.renders.RenderPanda.renderHealtBar(RenderPanda.java:62) [RenderPanda.class:?]
                                at com.mod.panda.renders.RenderPanda.doRender(RenderPanda.java:66) [RenderPanda.class:?]
                                at net.minecraft.client.renderer.entity.RenderManager.func_147939_a(RenderManager.java:300) [RenderManager.class:?]
                                at net.minecraft.client.renderer.entity.RenderManager.renderEntityStatic(RenderManager.java:278) [RenderManager.class:?]
                                at net.minecraft.client.renderer.entity.RenderManager.renderEntitySimple(RenderManager.java:251) [RenderManager.class:?]
                                at net.minecraft.client.renderer.RenderGlobal.renderEntities(RenderGlobal.java:527) [RenderGlobal.class:?]
                                at net.minecraft.client.renderer.EntityRenderer.renderWorld(EntityRenderer.java:1300) [EntityRenderer.class:?]
                                at net.minecraft.client.renderer.EntityRenderer.updateCameraAndRender(EntityRenderer.java:1087) [EntityRenderer.class:?]
                                at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:1067) [Minecraft.class:?]
                                at net.minecraft.client.Minecraft.run(Minecraft.java:962) [Minecraft.class:?]
                                at net.minecraft.client.main.Main.main(Main.java:164) [Main.class:?]
                                at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_91]
                                at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_91]
                                at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_91]
                                at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_91]
                                at net.minecraft.launchwrapper.Launch.launch(Launch.java:135) [launchwrapper-1.12.jar:?]
                                at net.minecraft.launchwrapper.Launch.main(Launch.java:28) [launchwrapper-1.12.jar:?]
                                at net.minecraftforge.gradle.GradleStartCommon.launch(Unknown Source) [start/:?]
                                at GradleStart.main(Unknown Source) [start/:?]
                                Caused by: java.lang.NullPointerException
                                at net.minecraft.client.resources.SimpleReloadableResourceManager.getResource(SimpleReloadableResourceManager.java:63) ~[SimpleReloadableResourceManager.class:?]
                                at net.minecraft.client.renderer.texture.SimpleTexture.loadTexture(SimpleTexture.java:35) ~[SimpleTexture.class:?]
                                at net.minecraft.client.renderer.texture.TextureManager.loadTexture(TextureManager.java:89) ~[TextureManager.class:?]
                                … 25 more
                                
                                1 réponse Dernière réponse Répondre Citer 0
                                • robin4002R Hors-ligne
                                  robin4002 Moddeurs confirmés Rédacteurs Administrateurs
                                  dernière édition par

                                  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);
                                  }
                                  }
                                  
                                  1 réponse Dernière réponse Répondre Citer 1
                                  • jbamineJ Hors-ligne
                                    jbamine
                                    dernière édition par

                                    @‘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

                                    1 réponse Dernière réponse Répondre Citer 0
                                    • robin4002R Hors-ligne
                                      robin4002 Moddeurs confirmés Rédacteurs Administrateurs
                                      dernière édition par

                                      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.

                                      1 réponse Dernière réponse Répondre Citer 0
                                      • jbamineJ Hors-ligne
                                        jbamine
                                        dernière édition par

                                        @‘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 ?

                                        1 réponse Dernière réponse Répondre Citer 0
                                        • robin4002R Hors-ligne
                                          robin4002 Moddeurs confirmés Rédacteurs Administrateurs
                                          dernière édition par

                                          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);
                                          }

                                          1 réponse Dernière réponse Répondre Citer 0
                                          • jbamineJ Hors-ligne
                                            jbamine
                                            dernière édition par

                                            @‘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…

                                            1 réponse Dernière réponse Répondre Citer 0
                                            • 1
                                            • 2
                                            • 3
                                            • 4
                                            • 3 / 4
                                            • Premier message
                                              Dernier message
                                            Design by Woryk
                                            ContactMentions Légales

                                            MINECRAFT FORGE FRANCE © 2024

                                            Powered by NodeBB