• Register
    • Login
    • Search
    • Recent
    • Tags
    • Popular
    • Users
    • Groups

    Solved Limiter becomeAngryAt a un mob et pas un autre

    1.7.x
    1.7.2
    3
    6
    2839
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Nolan-XX
      Nolan-XX last edited by

      Salut a tous, je cherche a faire en sorte que mon mob agisse comme un PigZombie, c’est a dire qu’il n’attaque que si est attaqué, mais aussi défend ses frères.
      Problème : Mon Mob A défend le Mob B et vice-versa, je voudrais que le Mob A en aille rien a f*utre du Mob B. J’ai essayé ça sans succés

      package fr.nolancraft.onche.Mobs;
      
      import java.util.List;
      
      import net.minecraft.entity.Entity;
      import net.minecraft.entity.SharedMonsterAttributes;
      import net.minecraft.entity.monster.EntityPigZombie;
      import net.minecraft.entity.player.EntityPlayer;
      import net.minecraft.item.Item;
      import net.minecraft.util.DamageSource;
      import net.minecraft.world.World;
      import fr.nolancraft.onche.Data.Main;
      
      public class EntityNoel extends EntityPigZombie
      {
      
      @SuppressWarnings("unused")
      private int angerLevel;
      @SuppressWarnings("unused")
      private int randomSoundDelay;
      
      public EntityNoel(World world)
      {
      super(world);
      }
      
      public void applyEntityAttributes()
      {
      super.applyEntityAttributes();
      this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(20D);
      this.getEntityAttribute(SharedMonsterAttributes.attackDamage).setBaseValue(3D);
      
      }
      
      public Item getDropItem()
      {
      return Main.Hap;
      }
      
      protected void dropFewItems(boolean par1, int par2)
      {
      int j = this.rand.nextInt(2 + par2);
      int k;
      
      for (k = 0; k < j; ++k)
      {
      this.dropItem(Main.noel, 1);
      }
      
      }
      
      protected void dropRareDrop(int par1)
      {
      this.dropItem(Main.cisla, 1);
      }
      
      protected void addRandomArmor()
      {
      this.setCurrentItemOrArmor(0, null);
      }
      
      public boolean attackEntityFrom(DamageSource par1DamageSource, float par2)
         {
             if (this.isEntityInvulnerable())
             {
                 return false;
             }
             else
             {
                 Entity entity = par1DamageSource.getEntity();
      
                 if (entity instanceof EntityPlayer)
                 {
                     @SuppressWarnings("rawtypes")
      List list = this.worldObj.getEntitiesWithinAABBExcludingEntity(this, this.boundingBox.expand(32.0D, 32.0D, 32.0D));
      
                     for (int i = 0; i < list.size(); ++i)
                     {
                         Entity entity1 = (Entity)list.get(i);
      
                         if (entity1 instanceof EntityNoel)
                         {
                          EntityNoel entityNoel = (EntityNoel)entity1;
                          entityNoel.becomeAngryAt(entity);
                         }
                     }
      
                     this.becomeAngryAt(entity);
                 }
      
                 return super.attackEntityFrom(par1DamageSource, par2);
             }
         }
      
         private void becomeAngryAt(Entity par1Entity)
         {
             this.entityToAttack = par1Entity;
             this.angerLevel = 400 + this.rand.nextInt(400);
             this.randomSoundDelay = this.rand.nextInt(40);
         }
      
      }
      
      package fr.nolancraft.onche.Mobs;
      
      import java.util.List;
      
      import net.minecraft.entity.Entity;
      import net.minecraft.entity.SharedMonsterAttributes;
      import net.minecraft.entity.monster.EntityPigZombie;
      import net.minecraft.entity.player.EntityPlayer;
      import net.minecraft.item.Item;
      import net.minecraft.util.DamageSource;
      import net.minecraft.world.World;
      import fr.nolancraft.onche.Data.Main;
      
      public class EntityHap extends EntityPigZombie
      {
      
      @SuppressWarnings("unused")
      private int angerLevel;
      @SuppressWarnings("unused")
      private int randomSoundDelay;
      
      public EntityHap(World world)
      {
      super(world);
      }
      
      public void applyEntityAttributes()
      {
      super.applyEntityAttributes();
      this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(20D);
      this.getEntityAttribute(SharedMonsterAttributes.attackDamage).setBaseValue(3D);
      
      }
      
      public Item getDropItem()
      {
      return Main.Hap;
      }
      
      protected void dropFewItems(boolean par1, int par2)
      {
      int j = this.rand.nextInt(2 + par2);
      int k;
      
      for (k = 0; k < j; ++k)
      {
      this.dropItem(Main.Hap, 1);
      }
      
      }
      
      protected void dropRareDrop(int par1)
      {
      this.dropItem(Main.cisla, 1);
      }
      
      protected void addRandomArmor()
      {
      this.setCurrentItemOrArmor(0, null);
      }
      
      public boolean attackEntityFrom(DamageSource par1DamageSource, float par2)
         {
             if (this.isEntityInvulnerable())
             {
                 return false;
             }
             else
             {
                 Entity entity = par1DamageSource.getEntity();
      
                 if (entity instanceof EntityPlayer)
                 {
                     @SuppressWarnings("rawtypes")
      List list = this.worldObj.getEntitiesWithinAABBExcludingEntity(this, this.boundingBox.expand(32.0D, 32.0D, 32.0D));
      
                     for (int i = 0; i < list.size(); ++i)
                     {
                         Entity entity1 = (Entity)list.get(i);
      
                         if (entity1 instanceof EntityHap)
                         {
                          EntityHap entityHap = (EntityHap)entity1;
                          entityHap.becomeAngryAt(entity);
                         }
                     }
      
                     this.becomeAngryAt(entity);
                 }
      
                 return super.attackEntityFrom(par1DamageSource, par2);
             }
         }
      
         private void becomeAngryAt(Entity par1Entity)
         {
             this.entityToAttack = par1Entity;
             this.angerLevel = 400 + this.rand.nextInt(400);
             this.randomSoundDelay = this.rand.nextInt(40);
         }
      
      }
      

      Merci d’avance.
      Et par ailleurs, est il possible que le Mob A attaque Mob B et vice-versa ?

      1 Reply Last reply Reply Quote 0
      • Flow
        Flow last edited by

        Je pense que c’est par-ce que tu extends EntitypPigzombie au deux, ce qui fait qu’il se défende mutuellement , essaye d’extends deux entity différente pour chaque, il ne seront donc pas connecté , donc pour :

        EntityHap extends EntityHapAgressif

        et

        EntityNoel extends EntityNoelAgressif

        et remet le code du pigzombie dans les deux en modifiant à chaque fois le EntityPigZombie en Entity"NOMDUMOB"Agressif pour les deux

        Je ne fais que supposer , je ne suis pas un pro du modding désoler si ca ne marche pas et que sa te fait perdre ton temps =/


        Oui ce gif est drôle.

        1 Reply Last reply Reply Quote 1
        • Nolan-XX
          Nolan-XX last edited by

          Et bien tu supposes très bien !
          Un merci a toi.

          Tu ne pourrais pas supposer par hasard une solution a mon second problème ?

          1 Reply Last reply Reply Quote 0
          • Diangle
            Diangle last edited by

            @‘Nolan-XX’:

            Et bien tu supposes très bien !
            Un merci a toi.

            Tu ne pourrais pas supposer par hasard une solution a mon second problème ?

            Il y a un tuto je croit pour que un mob attaque un autre ^^.

            1 Reply Last reply Reply Quote 1
            • Flow
              Flow last edited by

              Voici le tuto en question ! 🙂 http://minecraftforgefrance.fr/showthread.php?tid=1053

              Oui ce gif est drôle.

              1 Reply Last reply Reply Quote 1
              • Nolan-XX
                Nolan-XX last edited by

                Parfait, merci !

                1 Reply Last reply Reply Quote 0
                • 1 / 1
                • First post
                  Last post
                Design by Woryk
                Contact / Mentions Légales

                MINECRAFT FORGE FRANCE © 2018

                Powered by NodeBB