MFF

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

    Empêcher mon mob de m'attaquer

    Planifier Épinglé Verrouillé Déplacé Résolu 1.7.x
    1.7.10
    24 Messages 7 Publieurs 4.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.
    • M Hors-ligne
      minantcaft
      dernière édition par

      Mon mob n’attaque plu le bug et il m’attaque encore… 😞

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

        @‘robin4002’:

               this.targetTasks.addTask(3, new EntityAINearestAttackableTarget(this, EntityBug.class, 0, true, false, IMob.mobSelector));
        

        ↓↓↓

               this.targetTasks.addTask(3, new EntityAINearestAttackableTarget(this, EntityBug.class, 0, true, false, new IEntitySelector()
               {
                   public boolean isEntityApplicable(Entity entity)
                   {
                       return entity instanceof EntityBug;
                   }
               }));
        

        J’ai essayer avec mais le mob m’attaque encore et n’attaque pas les bug…

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

          Petit rappel: maintenant la classe de mon mob est la suivante:

          package com.mod.test.entity;
          
          import java.util.List;
          
          import com.mod.test.init.ItemMod;
          
          import net.minecraft.client.Minecraft;
          import net.minecraft.command.IEntitySelector;
          import net.minecraft.entity.Entity;
          import net.minecraft.entity.EntityAgeable;
          import net.minecraft.entity.EntityCreature;
          import net.minecraft.entity.EntityLiving;
          import net.minecraft.entity.SharedMonsterAttributes;
          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.EntityAIOpenDoor;
          import net.minecraft.entity.ai.EntityAIRestrictOpenDoor;
          import net.minecraft.entity.ai.EntityAISwimming;
          import net.minecraft.entity.ai.EntityAIWander;
          import net.minecraft.entity.ai.EntityAIWatchClosest;
          import net.minecraft.entity.monster.EntityCreeper;
          import net.minecraft.entity.monster.EntityMob;
          import net.minecraft.entity.monster.EntityZombie;
          import net.minecraft.entity.monster.IMob;
          import net.minecraft.entity.passive.EntityTameable;
          import net.minecraft.entity.passive.EntityVillager;
          import net.minecraft.entity.player.EntityPlayer;
          import net.minecraft.init.Items;
          import net.minecraft.item.Item;
          import net.minecraft.pathfinding.PathEntity;
          import net.minecraft.util.AxisAlignedBB;
          import net.minecraft.world.World;
          import net.minecraftforge.common.ForgeModContainer;
          
          public class EntityProgrammer extends EntityMob
          {    
              public EntityProgrammer(World world)
              {
                  super(world);
                  this.canAttackClass(EntityBug.class);
                  this.getNavigator().setBreakDoors(true);
                  this.getNavigator().setAvoidsWater(true);
                  this.tasks.addTask(1, new EntityAIAttackOnCollide(this, 5.0D, true));
                  this.tasks.addTask(4, new EntityAIOpenDoor(this, true));
                  this.tasks.addTask(5, new EntityAIMoveTowardsRestriction(this, 1.0D));
                  this.tasks.addTask(7, new EntityAIWander(this, 1.0D));
                  this.tasks.addTask(8, new EntityAIWatchClosest(this, EntityBug.class, 40.0F));
                  this.tasks.addTask(8, new EntityAILookIdle(this));
                  this.targetTasks.addTask(1, new EntityAIHurtByTarget(this, false));
                  this.targetTasks.addTask(3, new EntityAINearestAttackableTarget(this, EntityBug.class, 0, true, false, new IEntitySelector()
                          {
          
                              public boolean isEntityApplicable(Entity entity)
                              {
                                  return entity instanceof EntityBug;
                              }
                          }));
                  this.setSize(0.6F, 1.8F);
                  this.captureDrops = true;
              }
          
              protected void applyEntityAttributes()
              {
                  super.applyEntityAttributes();
                  this.getEntityAttribute(SharedMonsterAttributes.followRange).setBaseValue(40.0D);
                  this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(1.0D);
                  this.getEntityAttribute(SharedMonsterAttributes.attackDamage).setBaseValue(3.0D);
                  this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(20.0D);
              }
          
              /*public void updateEntityActionState()
              {
                  List list = worldObj.getEntitiesWithinAABB(EntityBug.class, AxisAlignedBB.getBoundingBox(posX, posY, posZ, posX + 1, posY + 1, posZ + 1).expand(16D, 4D, 16D));
                  for(int i = 0; i< list.size(); i++)
                  {
                      Entity entity = (Entity)list.get(i);
                      if(!list.isEmpty())
                      {
                          if(!(entity instanceof EntityPlayer))
                          {
                              if(!(entity instanceof EntityProgrammer))
                              {                        
                                  this.setTarget(entity);
                              }
                          }
                      }
                  }
                  super.updateEntityActionState();
              }*/
          
              public Item getDropItem()
              {
                  return null;
              }
          
              public void dropFewItems(boolean b, int looting)
              {
                  this.dropItem(ItemMod.informatical_code, 3);
                  if(this.isBurning())
                  {
                      this.dropItem(Items.cooked_beef, 2);
                  }
                  else
                  {
                      this.dropItem(Items.beef, 2);
                  }
              }
          }
          
          ```___J'essaye comme ceci:
          ```java
          package com.mod.test.entity;
          
          import java.util.List;
          
          import com.mod.test.init.ItemMod;
          
          import net.minecraft.client.Minecraft;
          import net.minecraft.command.IEntitySelector;
          import net.minecraft.entity.Entity;
          import net.minecraft.entity.EntityAgeable;
          import net.minecraft.entity.EntityCreature;
          import net.minecraft.entity.EntityLiving;
          import net.minecraft.entity.SharedMonsterAttributes;
          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.EntityAIOpenDoor;
          import net.minecraft.entity.ai.EntityAIRestrictOpenDoor;
          import net.minecraft.entity.ai.EntityAISwimming;
          import net.minecraft.entity.ai.EntityAIWander;
          import net.minecraft.entity.ai.EntityAIWatchClosest;
          import net.minecraft.entity.monster.EntityCreeper;
          import net.minecraft.entity.monster.EntityMob;
          import net.minecraft.entity.monster.EntityZombie;
          import net.minecraft.entity.monster.IMob;
          import net.minecraft.entity.passive.EntityTameable;
          import net.minecraft.entity.passive.EntityVillager;
          import net.minecraft.entity.player.EntityPlayer;
          import net.minecraft.init.Items;
          import net.minecraft.item.Item;
          import net.minecraft.pathfinding.PathEntity;
          import net.minecraft.util.AxisAlignedBB;
          import net.minecraft.world.World;
          import net.minecraftforge.common.ForgeModContainer;
          
          public class EntityProgrammer extends EntityMob
          {    
              public EntityProgrammer(World world)
              {
                  super(world);
                  this.canAttackClass(EntityBug.class);
                  this.getNavigator().setBreakDoors(true);
                  this.getNavigator().setAvoidsWater(true);
                  this.tasks.addTask(1, new EntityAIAttackOnCollide(this, 5.0D, true));
                  this.tasks.addTask(4, new EntityAIOpenDoor(this, true));
                  this.tasks.addTask(5, new EntityAIMoveTowardsRestriction(this, 1.0D));
                  this.tasks.addTask(7, new EntityAIWander(this, 1.0D));
                  this.tasks.addTask(8, new EntityAIWatchClosest(this, EntityBug.class, 40.0F));
                  this.tasks.addTask(8, new EntityAILookIdle(this));
                  this.targetTasks.addTask(1, new EntityAIHurtByTarget(this, false));
                  this.targetTasks.addTask(3, new EntityAINearestAttackableTarget(this, EntityBug.class, 0, true, false, new IEntitySelector()
                          {
          
                              public boolean isEntityApplicable(Entity entity)
                              {
                                  return entity instanceof EntityBug;
                              }
                          }));
                  this.setSize(0.6F, 1.8F);
                  this.captureDrops = true;
              }
          
              protected void applyEntityAttributes()
              {
                  super.applyEntityAttributes();
                  this.getEntityAttribute(SharedMonsterAttributes.followRange).setBaseValue(40.0D);
                  this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(1.0D);
                  this.getEntityAttribute(SharedMonsterAttributes.attackDamage).setBaseValue(3.0D);
                  this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(20.0D);
              }
          
              public void updateEntityActionState()
              {
                  List list = worldObj.getEntitiesWithinAABB(EntityBug.class, AxisAlignedBB.getBoundingBox(posX, posY, posZ, posX + 1, posY + 1, posZ + 1).expand(16D, 4D, 16D));
                  for(int i = 0; i< list.size(); i++)
                  {
                      Entity entity = (Entity)list.get(i);
                      if(!list.isEmpty())
                      {
                          if(!(entity instanceof EntityPlayer))
                          {
                              if(!(entity instanceof EntityProgrammer))
                              {                        
                                  this.setTarget(entity);
                              }
                          }
                      }
                  }
                  //super.updateEntityActionState();
              }
          
              public Item getDropItem()
              {
                  return null;
              }
          
              public void dropFewItems(boolean b, int looting)
              {
                  this.dropItem(ItemMod.informatical_code, 3);
                  if(this.isBurning())
                  {
                      this.dropItem(Items.cooked_beef, 2);
                  }
                  else
                  {
                      this.dropItem(Items.beef, 2);
                  }
              }
          }
          
          
          1 réponse Dernière réponse Répondre Citer 0
          • AymericRedA Hors-ligne
            AymericRed
            dernière édition par

            Attention aux multiples post.
            “new EntityAIHurtByTarget(this, false)” ==> “new EntityAIHurtByTarget(this, false, EntityBug.class)”

            Envoyé de mon RAINBOW LITE 4G en utilisant Tapatalk

            Si je vous ai aidé, n'oubliez pas d’être heureux, j'aiderai encore +

            AymericRed, moddeur expérimenté qui aide sur ce forum et qui peut accepter de faire un mod Forge rémunéré de temps en temps.

            Mes tutos : Table de craft, plugin NEI, plugin JEI, modifier l'overlay
            Je suis un membre apprécié et joueur, j'ai déjà obtenu 6 points de réputation.

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

              @‘minantcaft’:

              J’essaye comme ceci:

              package com.mod.test.entity;
              
              import java.util.List;
              
              import com.mod.test.init.ItemMod;
              
              import net.minecraft.client.Minecraft;
              import net.minecraft.command.IEntitySelector;
              import net.minecraft.entity.Entity;
              import net.minecraft.entity.EntityAgeable;
              import net.minecraft.entity.EntityCreature;
              import net.minecraft.entity.EntityLiving;
              import net.minecraft.entity.SharedMonsterAttributes;
              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.EntityAIOpenDoor;
              import net.minecraft.entity.ai.EntityAIRestrictOpenDoor;
              import net.minecraft.entity.ai.EntityAISwimming;
              import net.minecraft.entity.ai.EntityAIWander;
              import net.minecraft.entity.ai.EntityAIWatchClosest;
              import net.minecraft.entity.monster.EntityCreeper;
              import net.minecraft.entity.monster.EntityMob;
              import net.minecraft.entity.monster.EntityZombie;
              import net.minecraft.entity.monster.IMob;
              import net.minecraft.entity.passive.EntityTameable;
              import net.minecraft.entity.passive.EntityVillager;
              import net.minecraft.entity.player.EntityPlayer;
              import net.minecraft.init.Items;
              import net.minecraft.item.Item;
              import net.minecraft.pathfinding.PathEntity;
              import net.minecraft.util.AxisAlignedBB;
              import net.minecraft.world.World;
              import net.minecraftforge.common.ForgeModContainer;
              
              public class EntityProgrammer extends EntityMob
              {    
                  public EntityProgrammer(World world)
                  {
                      super(world);
                      this.canAttackClass(EntityBug.class);
                      this.getNavigator().setBreakDoors(true);
                      this.getNavigator().setAvoidsWater(true);
                      this.tasks.addTask(1, new EntityAIAttackOnCollide(this, 5.0D, true));
                      this.tasks.addTask(4, new EntityAIOpenDoor(this, true));
                      this.tasks.addTask(5, new EntityAIMoveTowardsRestriction(this, 1.0D));
                      this.tasks.addTask(7, new EntityAIWander(this, 1.0D));
                      this.tasks.addTask(8, new EntityAIWatchClosest(this, EntityBug.class, 40.0F));
                      this.tasks.addTask(8, new EntityAILookIdle(this));
                      this.targetTasks.addTask(1, new EntityAIHurtByTarget(this, false));
                      this.targetTasks.addTask(3, new EntityAINearestAttackableTarget(this, EntityBug.class, 0, true, false, new IEntitySelector()
                              {
              
                                  public boolean isEntityApplicable(Entity entity)
                                  {
                                      return entity instanceof EntityBug;
                                  }
                              }));
                      this.setSize(0.6F, 1.8F);
                      this.captureDrops = true;
                  }
                  
                  protected void applyEntityAttributes()
                  {
                      super.applyEntityAttributes();
                      this.getEntityAttribute(SharedMonsterAttributes.followRange).setBaseValue(40.0D);
                      this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(1.0D);
                      this.getEntityAttribute(SharedMonsterAttributes.attackDamage).setBaseValue(3.0D);
                      this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(20.0D);
                  }
                  
                  public void updateEntityActionState()
                  {
                      List list = worldObj.getEntitiesWithinAABB(EntityBug.class, AxisAlignedBB.getBoundingBox(posX, posY, posZ, posX + 1, posY + 1, posZ + 1).expand(16D, 4D, 16D));
                      for(int i = 0; i< list.size(); i++)
                      {
                          Entity entity = (Entity)list.get(i);
                          if(!list.isEmpty())
                          {
                              if(!(entity instanceof EntityPlayer))
                              {
                                  if(!(entity instanceof EntityProgrammer))
                                  {                        
                                      this.setTarget(entity);
                                  }
                              }
                          }
                      }
                      //super.updateEntityActionState();
                  }
                  
                  public Item getDropItem()
                  {
                      return null;
                  }
                  
                  public void dropFewItems(boolean b, int looting)
                  {
                      this.dropItem(ItemMod.informatical_code, 3);
                      if(this.isBurning())
                      {
                          this.dropItem(Items.cooked_beef, 2);
                      }
                      else
                      {
                          this.dropItem(Items.beef, 2);
                      }
                  }
              }
              
              

              Le mob ne bouge plus, il ne m’attaque plus mais il n’attaque pas non-plus le bug___@‘AymericRed’:

              Attention aux multiples post.
              “new EntityAIHurtByTarget(this, false)” ==> “new EntityAIHurtByTarget(this, false, EntityBug.class)”

              Envoyé de mon RAINBOW LITE 4G en utilisant Tapata

              ok il me dit que ce constructeur n’existe pas…___Le BossMax2, tu n’aurais pas une idée?

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

                Y’a quoi comme constructeurs disponibles ?

                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
                • M Hors-ligne
                  minantcaft
                  dernière édition par

                  @‘SCAREX’:

                  Y’a quoi comme constructeurs disponibles ?

                  seulement la premier je crois

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

                    T’es en quelle version ? (Moi je l’ai)

                    Envoyé de mon RAINBOW LITE 4G en utilisant Tapatalk

                    Si je vous ai aidé, n'oubliez pas d’être heureux, j'aiderai encore +

                    AymericRed, moddeur expérimenté qui aide sur ce forum et qui peut accepter de faire un mod Forge rémunéré de temps en temps.

                    Mes tutos : Table de craft, plugin NEI, plugin JEI, modifier l'overlay
                    Je suis un membre apprécié et joueur, j'ai déjà obtenu 6 points de réputation.

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

                      1.7.10 d’après la balise de version.

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

                        Ah parce qu’on voit pas sur tapatalk.
                        Alors je ne vois pas d’où vient ton problème.

                        Envoyé de mon RAINBOW LITE 4G en utilisant Tapatalk

                        Si je vous ai aidé, n'oubliez pas d’être heureux, j'aiderai encore +

                        AymericRed, moddeur expérimenté qui aide sur ce forum et qui peut accepter de faire un mod Forge rémunéré de temps en temps.

                        Mes tutos : Table de craft, plugin NEI, plugin JEI, modifier l'overlay
                        Je suis un membre apprécié et joueur, j'ai déjà obtenu 6 points de réputation.

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

                          @‘AymericRed’:

                          Ah parce qu’on voit pas sur tapatalk.
                          Alors je ne vois pas d’où vient ton problème.

                          Envoyé de mon RAINBOW LITE 4G en utilisant Tapatalk

                          A vous n’avez vraiment pas une idée? car c un peu gênant… Merci quand même d’avoir répondu aussi vite!

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

                            Sinon tu peux toujours re-créer l’IA en faisant un copier-coller en modifiant ce que tu veux

                            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
                            • M Hors-ligne
                              minantcaft
                              dernière édition par

                              @‘SCAREX’:

                              Sinon tu peux toujours re-créer l’IA en faisant un copier-coller en modifiant ce que tu veux

                              Oui mais je n’ai pas trouvé d’IA semblable dans les fichiers du jeu

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

                                Tu veux attaquer les entités comment ?

                                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
                                • MyrilandelM Hors-ligne
                                  Myrilandel
                                  dernière édition par

                                  Salut,
                                  Essaie peutêtre avec la méthode findPlayerToAttack

                                  @Override
                                  protected Entity findPlayerToAttack() {
                                      return null;
                                  }
                                  
                                  
                                  1 réponse Dernière réponse Répondre Citer 0
                                  • MinantcraftM Hors-ligne
                                    Minantcraft
                                    dernière édition par

                                    @‘Myrilandel’:

                                    Salut,
                                    Essaie peutêtre avec la méthode findPlayerToAttack

                                    @Override
                                    protected Entity findPlayerToAttack() {
                                        return null;
                                    }
                                    
                                    

                                    Un grand merci à toi! Ca fonctionne! Désolé d’avoir répondu si tard mais j’ai eu un probleme avec mon compte

                                    Minantcraft ;)

                                    >! Binary Dimension
                                    [url=https://minecraft.cu…

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

                                      Bonjour, je passerai le sujet en résolu dès que possible, j’ai contacté l’équipe minecraft forge france pour récupérer mon compte et passer ce sujet en résolu

                                      Minantcraft ;)

                                      >! Binary Dimension
                                      [url=https://minecraft.cu…

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

                                        Normalement tu as juste besoin de mettre ça

                                        @Override
                                        protected Entity findPlayerToAttack() {
                                           return null;
                                        }
                                        
                                        1 réponse Dernière réponse Répondre Citer 0
                                        • 1
                                        • 2
                                        • 1 / 2
                                        • Premier message
                                          Dernier message
                                        Design by Woryk
                                        ContactMentions Légales

                                        MINECRAFT FORGE FRANCE © 2024

                                        Powered by NodeBB