MFF

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

    [+/- Résolu]Faire lancer une boule de feu par une entité

    Planifier Épinglé Verrouillé Déplacé Résolu 1.7.x
    30 Messages 8 Publieurs 7.3k 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.
    • Thegamer9112T Hors-ligne
      Thegamer9112
      dernière édition par

      Ok merci ça fonctionne très bien!!
      ais je voulais mettre un peu plus de code dans cette entity donc j’ai essayé de faire qu’elle voit le joueur de moins loin voila le code que j’ai fait:

      
      package fr.minecraftforgefrance.mogame.common;
      
      import net.minecraft.entity.Entity;
      import net.minecraft.entity.SharedMonsterAttributes;
      import net.minecraft.entity.monster.EntityMob;
      import net.minecraft.entity.player.EntityPlayer;
      import net.minecraft.entity.projectile.EntityLargeFireball;
      import net.minecraft.util.MathHelper;
      import net.minecraft.world.World;
      
      public class EntityVlad extends EntityMob  {
         private short timerEntity;
         private int explosionStrength = 1;
         private Entity currentTarget;
      
         public EntityVlad(World world) {
             super(world);
         }
      
         public void applyEntityAttributes() {
             super.applyEntityAttributes();
             this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(20D);
             this.getEntityAttribute(SharedMonsterAttributes.attackDamage).setBaseValue(6D);
             this.getEntityAttribute(SharedMonsterAttributes.knockbackResistance).setBaseValue(1.0D);
             this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(0.8D);
         }
      
         @Override
         public void attackEntity(Entity entity, float value) {
             if (this.timerEntity == 0) {
                 double xPos = entity.posX - posX;
                 double yPos = (entity.boundingBox.minY + (entity.height / 2.0F)) - (posY + (height / 2.0F));
                 double zPos = entity.posZ - posZ;
                 float sqrt = MathHelper.sqrt_float(value) * 0.5F;
                 worldObj.playAuxSFXAtEntity((EntityPlayer) null, 1009, (int) posX, (int) posY, (int) posZ, 0);
                 EntityLargeFireball fireball = new EntityLargeFireball(worldObj, this, xPos + (rand.nextGaussian() * sqrt), yPos, zPos + (rand.nextGaussian() * sqrt));
                 fireball.posY = posY + (height / 2.0F) + 0.5D;
                 fireball.field_92057_e = explosionStrength;
                 worldObj.spawnEntityInWorld(fireball);
             }
         }
      
         protected void updateEntityActionState() {
             super.updateEntityActionState();
             timerEntity++;
             if (timerEntity == 50) {
                 timerEntity = 0;
                 float f = 1.0F;
      
                 if (this.rand.nextFloat() < 0.02F)
                 {
                     EntityPlayer entityplayer = this.worldObj.getClosestPlayerToEntity(this, (double)f);
      
                     if (entityplayer != null)
                     {
                         this.currentTarget = entityplayer;
                         this.numTicksToChaseTarget = 10 + this.rand.nextInt(20);
                     }
                     else
                     {
                         this.randomYawVelocity = (this.rand.nextFloat() - 0.5F) * 20.0F;
                     }
                 }
      
                 if (this.currentTarget != null)
                 {
                     this.faceEntity(this.currentTarget, 10.0F, (float)this.getVerticalFaceSpeed());
      
                     if (this.numTicksToChaseTarget– <= 0 || this.currentTarget.isDead || this.currentTarget.getDistanceSqToEntity(this) > (double)(f * f))
                     {
                         this.currentTarget = null;
                     }
                 }
                 else
                 {
                     if (this.rand.nextFloat() < 0.05F)
                     {
                         this.randomYawVelocity = (this.rand.nextFloat() - 0.5F) * 20.0F;
                     }
      
                     this.rotationYaw += this.randomYawVelocity;
                     this.rotationPitch = this.defaultPitch;
                 }
             }
         }
      }
      

      Mais le Problème c’est que j’ai l’impression que ça fonctionne pas  😞
      Encore une fois c’est surement du a mon manque de connaissance en modding.

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

        Je vais tester et te dire 😉

        Edit:

        ​package com.flareheat.mineventure.entity.boss;
        
        import net.minecraft.entity.Entity;
        import net.minecraft.entity.SharedMonsterAttributes;
        import net.minecraft.entity.boss.IBossDisplayData;
        import net.minecraft.entity.monster.EntityMob;
        import net.minecraft.entity.player.EntityPlayer;
        import net.minecraft.entity.projectile.EntityLargeFireball;
        import net.minecraft.util.DamageSource;
        import net.minecraft.util.MathHelper;
        import net.minecraft.world.World;
        
        public class EntityVlad extends EntityMob implements IBossDisplayData {
            private short timerEntity;
            private final int explosionStrength;
            private final double distance;
        
            public EntityVlad(World world) {
                super(world);
                timerEntity = 0;
                explosionStrength = 1;
                distance = 8D;
            }
        
            @Override
            public void applyEntityAttributes() {
                super.applyEntityAttributes();
                getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(20D);
                getEntityAttribute(SharedMonsterAttributes.attackDamage).setBaseValue(6D);
                getEntityAttribute(SharedMonsterAttributes.knockbackResistance).setBaseValue(1.0D);
                getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(0.8D);
            }
        
            @Override
            public void attackEntity(Entity entity, float value) {
                if (timerEntity == 0) {
                    final double xPos = entity.posX - posX;
                    final double yPos = (entity.boundingBox.minY + (entity.height / 2.0F)) - (posY + (height / 2.0F));
                    final double zPos = entity.posZ - posZ;
                    final float sqrt = MathHelper.sqrt_float(value) * 0.5F;
                    worldObj.playAuxSFXAtEntity((EntityPlayer) null, 1009, (int) posX, (int) posY, (int) posZ, 0);
                    final EntityLargeFireball fireball = new EntityLargeFireball(worldObj, this, xPos + (rand.nextGaussian() * sqrt), yPos, zPos + (rand.nextGaussian() * sqrt));
                    fireball.posY = posY + (height / 2.0F) + 0.5D;
                    fireball.field_92057_e = explosionStrength;
                    worldObj.spawnEntityInWorld(fireball);
                }
            }
        
            @Override
            protected void updateEntityActionState() {
                super.updateEntityActionState();
                timerEntity++;
                if (timerEntity == 50) {
                    timerEntity = 0;
                }
            }
        
            @Override
            public Entity findPlayerToAttack() {
                final EntityPlayer entityplayer = worldObj.getClosestVulnerablePlayerToEntity(this, distance);
                if (entityplayer != null) {
                    return entityplayer;
                } else {
                    return null;
                }
            }
        
            @Override
            public boolean attackEntityFrom(DamageSource damagesource, float f) {
                return super.attackEntityFrom(damagesource, f);
            }
        
            @Override
            protected boolean canDespawn() {
                return false;
            }
        
            @Override
            protected void updateArmSwingProgress() {
                super.updateArmSwingProgress();
            }
        }
        

        Si je t'ai aidé, n'hésites pas à mettre un point de réputation positif !
        Si tu m'as aidé, je n'hésiterais pas à t'en donner à mon tour !

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

          Ok je viens de tester ça fonctionne très bien mais le problème c’est que une fois qu’il nous a vu il ne nous lâche plus…
          Et je sais pas comment faire qu’il nous lâche plus tôt.

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

            je dis sa comme sa mais de base dans minecraft aucun mob te lache sauf si tu sors de son champ de vision donc a priori t’a juste a tracer et il te lachera
            sinon faut réduire son champ de vision ( je ne sais pas comment sa marche par contre )

            Tout probleme a sa solution, s'il n'y a pas de solution c'est qu'il n'y a pas de problemes

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

              Essaye ça:

              ​package com.flareheat.mineventure.entity.boss;
              
              import net.minecraft.entity.Entity;
              import net.minecraft.entity.SharedMonsterAttributes;
              import net.minecraft.entity.boss.IBossDisplayData;
              import net.minecraft.entity.monster.EntityMob;
              import net.minecraft.entity.player.EntityPlayer;
              import net.minecraft.entity.projectile.EntityLargeFireball;
              import net.minecraft.util.DamageSource;
              import net.minecraft.util.MathHelper;
              import net.minecraft.world.World;
              
              public class EntityVlad extends EntityMob implements IBossDisplayData {
                  private short timerEntity;
                  private final int explosionStrength;
                  private final double distance;
              
                  public EntityVlad(World world) {
                      super(world);
                      timerEntity = 0;
                      explosionStrength = 1;
                      distance = 8D;
                  }
              
                  @Override
                  public void applyEntityAttributes() {
                      super.applyEntityAttributes();
                      getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(20D);
                      getEntityAttribute(SharedMonsterAttributes.attackDamage).setBaseValue(6D);
                      getEntityAttribute(SharedMonsterAttributes.knockbackResistance).setBaseValue(1.0?D);
                      getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(0.8D);
                  }
              
                  @Override
                  public void attackEntity(Entity entity, float value) {
                      if (timerEntity == 0) {
                          final double xPos = entity.posX - posX;
                          final double yPos = (entity.boundingBox.minY + (entity.height / 2.0F)) - (posY + (height / 2.0F));
                          final double zPos = entity.posZ - posZ;
                          final float sqrt = MathHelper.sqrt_float(value) * 0.5F;
                          worldObj.playAuxSFXAtEntity((EntityPlayer) null, 1009, (int) posX, (int) posY, (int) posZ, 0);
                          final EntityLargeFireball fireball = new EntityLargeFireball(worldObj, this, xPos + (rand.nextGaussian() * sqrt), yPos, zPos + (rand.nextGaussian() * sqrt));
                          fireball.posY = posY + (height / 2.0F) + 0.5D;
                          fireball.field_92057_e = explosionStrength;
                          worldObj.spawnEntityInWorld(fireball);
                      }
                  }
              
                  @Override
                  protected void updateEntityActionState() {
                      super.updateEntityActionState();
                      timerEntity++;
                      if (timerEntity == 50) {
                          timerEntity = 0;
                      }
                  }
              
                  @Override
                  public Entity findPlayerToAttack() {
                      final EntityPlayer entityplayer = worldObj.getClosestVulnerablePlayerToEntity(this, distance);
                      if (entityplayer != null && canEntityBeSeen(entityplayer)) {
                          return entityplayer;
                      } else {            
                          setTarget(null);
                          return null;
                      }
                  }
              }
              

              Si je t'ai aidé, n'hésites pas à mettre un point de réputation positif !
              Si tu m'as aidé, je n'hésiterais pas à t'en donner à mon tour !

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

                Ok mais dsl je viens de comprendre mon erreur en fait ce que je voulais dire c’est qu’elle arrête de lancer des boules de feus mais il suffit de rajouter && canEntityBeSeen(entityplayer) dans la condition du timer.

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

                  donc ton problème est résolu ?

                  Tout probleme a sa solution, s'il n'y a pas de solution c'est qu'il n'y a pas de problemes

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

                    nana j’ai rien c’est bon ça fonctionne.
                    Je passe le sujet en résolu merci a tous!!

                    1 réponse Dernière réponse Répondre Citer 0
                    • isadorI Hors-ligne
                      isador Moddeurs confirmés Modérateurs
                      dernière édition par

                      EntityPlayer entityPlayer = EntityPlayer.thePlayer je crois que c’est ca

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

                        Je pense pas perso quand je n’ai pas d’argument entityplayer je met Minecraft.getMinecraft().thePlayer;

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

                          Dernier Probleme je voudrais faire lancer une entity de mon mod mais ca ne fonctionne pas.

                          
                          package fr.minecraftforgefrance.mogame.common;
                          
                          import net.minecraft.entity.Entity;
                          import net.minecraft.entity.SharedMonsterAttributes;
                          import net.minecraft.entity.monster.EntityMob;
                          import net.minecraft.entity.player.EntityPlayer;
                          import net.minecraft.entity.projectile.EntityLargeFireball;
                          import net.minecraft.util.MathHelper;
                          import net.minecraft.world.World;
                          
                          public class EntityNeige extends EntityMob
                          {
                          private short timerEntity;
                          
                          public EntityNeige(World world) {
                          super(world);
                          }
                          
                          public void applyEntityAttributes()
                          {
                          super.applyEntityAttributes();
                          this.getEntityAttribute(SharedMonsterAttributes.attackDamage).setBaseValue(6D);
                          this.getEntityAttribute(SharedMonsterAttributes.knockbackResistance).setBaseValue(1D);
                          this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(0.8D);
                          this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(20D);
                          
                          }
                          
                             @Override
                             protected void updateEntityActionState()
                             {
                                 super.updateEntityActionState();
                                 timerEntity++;
                                 if (timerEntity == 50)
                                 {
                                     timerEntity = 0;
                                 }    
                             }
                          
                             @Override
                             public void attackEntity(Entity entity, float value)
                             {
                              if ( timerEntity == 0)
                              {
                              final double xPos = entity.posX - posX;
                                     final double yPos = (entity.boundingBox.minY + (entity.height / 2.0F)) - (posY + (height / 2.0F));
                                     final double zPos = entity.posZ - posZ;
                                     final float sqrt = MathHelper.sqrt_float(value) * 0.5F;
                                     worldObj.playAuxSFXAtEntity((EntityPlayer) null, 1009, (int) posX, (int) posY, (int) posZ, 0);
                                     EntityVladAmmo entityVladAmmo = new EntityVladAmmo(worldObj,xPos + (rand.nextGaussian() * sqrt), yPos, zPos + (rand.nextGaussian() * sqrt));
                                     entityVladAmmo.posY = posY + (height / 2.0F) + 0.5D;
                                     worldObj.spawnEntityInWorld(entityVladAmmo);
                              }
                             }
                          
                          }
                          

                          et la classe de l’entity qui doit etre lance

                          
                          package fr.minecraftforgefrance.mogame.common;
                          
                          import net.minecraft.entity.EntityLivingBase;
                          import net.minecraft.entity.monster.EntityBlaze;
                          import net.minecraft.entity.projectile.EntityThrowable;
                          import net.minecraft.util.DamageSource;
                          import net.minecraft.util.MovingObjectPosition;
                          import net.minecraft.world.World;
                          
                          public class EntityVladAmmo extends EntityThrowable
                          {
                             public EntityVladAmmo(World par1World)
                             {
                                 super(par1World);
                             }
                             public EntityVladAmmo(World par1World, EntityLivingBase par2EntityLivingBase)
                             {
                                 super(par1World, par2EntityLivingBase);
                             }
                             public EntityVladAmmo(World par1World, double par2, double par4, double par6)
                             {
                                 super(par1World, par2, par4, par6);
                             }
                          
                             @Override
                             protected void onImpact(MovingObjectPosition movingObjectPosition)
                             {
                                 if (movingObjectPosition.entityHit != null)
                                 {
                                     byte damage = 1;
                          
                                     movingObjectPosition.entityHit.attackEntityFrom(DamageSource.causeThrownDamage(this, this.getThrower()), (float)damage);
                                     worldObj.newExplosion(null, movingObjectPosition.entityHit.posX, movingObjectPosition.entityHit.posY, movingObjectPosition.entityHit.posZ, 2.0F, true, true);
                                 }
                          
                                 for (int i = 0; i < 8; ++i)
                                 {
                                  this.worldObj.spawnParticle("snowballpoof", this.posX, this.posY, this.posZ, 0.0D, 0.0D, 0.0D);
                                 }
                          
                                 if (!this.worldObj.isRemote)
                                 {
                                     this.setDead();
                                 }
                             }
                          }
                          
                          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

                            Ton entité a bien un rendu ? Ton entité est bien enregistré ?

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

                              Quand tu dis enregistre tu veut dire dans ma classe principale?? Sinon je n ai pas encore fais le rendu car j avais juste le temps de tester avant de partir faire autre chose je ferai le rendu dmn et je te tiens au courant

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

                                Meeeeeuh non ca complique pas du tout d’utiliser cette interface (IRangedAttackMob), tout est déjà crée, ya juste à utiliser

                                Cette interface permet juste au mob de pas attaquer bettement au corps à corps, et il fait à la place ce qu’on lui dit de faire dans la fonction
                                (je vous file un exemple ou mon entité tirait des rafales de boules de neige)

                                
                                /**
                                
                                * Attack the specified entity using a ranged attack.
                                */
                                @Override
                                public void attackEntityWithRangedAttack(EntityLivingBase entity, float damage)
                                {
                                       if (System.currentTimeMillis() % 5000 < 2000)
                                       {
                                              EntitySnowball entitysnowball = new EntitySnowball(this.worldObj, this);
                                              double d0 = entity.posX - this.posX;
                                              double d1 = entity.posY + (double)entity.getEyeHeight() - 1 - entitysnowball.posY;
                                              double d2 = entity.posZ - this.posZ;
                                              float f1 = MathHelper.sqrt_double(d0 * d0 + d2 * d2) * 0.2F;
                                
                                              entitysnowball.setThrowableHeading(d0, d1 + (double)f1, d2, 1.6F, 12.0F);
                                              this.playSound("random.bow", 1.0F, 1.0F / (this.getRNG().nextFloat() * 0.4F + 0.8F));
                                              this.worldObj.spawnEntityInWorld(entitysnowball);
                                       }
                                }
                                
                                

                                Enfin si c’est résolu, tant mieux ^^

                                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

                                  EntityRegistry.registerModEntity(….
                                  Si tu n’enregistrer pas ton projectile il ne fonctionnera pas.

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

                                    c’est bon j’ai enregistrer et j’ai fait le render mais les entity ne lance toujours pas de projectile

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

                                      Personne n a d idée pour mon problème??

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

                                      MINECRAFT FORGE FRANCE © 2024

                                      Powered by NodeBB