MFF

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

    Mob attiré vers un bloc

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

      @‘Plaigon’:

      J’ai testé chez moi, tout marchait nikel. File entièrement la classe de ton entité, peut-être que le problème vient d’autre part. Essaie sinon de debug la task pour voir si le startExecuting est bien appelé…

      Ok j’essaye

      EDIT : Rien n’est appelé, pourrais tu m’envoyer tes fichier peut être que j’ai oublié quelque chose

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

        Envoie plutôt ta classe Entity, je vais comparé avec la mienne.
        As-tu également pensé à override cette méthode ?

        
        @Override
        protected boolean isAIEnabled()
        {
        return true;
        }
        
        
        1 réponse Dernière réponse Répondre Citer 0
        • D Hors-ligne
          death_xXX
          dernière édition par

          @‘Plaigon’:

          Envoie plutôt ta classe Entity, je vais comparé avec la mienne.
          As-tu également pensé à override cette méthode ?

          
          @Override
             protected boolean isAIEnabled()
             {
                 return true;
             }
          
          

          La classe de mon entité :

          package fr.clashofclan.common;
          
          import net.minecraft.block.Block;
          import net.minecraft.entity.Entity;
          import net.minecraft.entity.EntityCreature;
          import net.minecraft.entity.SharedMonsterAttributes;
          import net.minecraft.init.Blocks;
          import net.minecraft.world.World;
          import net.minecraftforge.event.entity.EntityEvent;
          
          public class Barbare extends EntityCreature{
          public Barbare(World world) {
          super(world);
          this.tasks.addTask(0, new EntityAIMoveToCustomBlock(this, 2.0D, ClashOfClan.blockTarget, 20)); //Pour bouger
          }
          
          public void applyEntityAttributes() {
          super.applyEntityAttributes();
          this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(20D);
          this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(0.8D);
          }
          
          public Entity getEntityToAttack() {
          return null;
          }
          
          @Override
          protected boolean isAIEnabled()
          {
          return true;
          }
          }
          
          

          P.S. J’ai rajouté ce que tu as dis dans ton dernier post et maintenant il ne bouge plus  :s

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

            Rajoute une tâche pour wander.

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

              @‘Plaigon’:

              Rajoute une tâche pour wander.

              Desolé je ne comprend pas  😐

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

                Alors ?

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

                  Faut pas marquer le sujet comme résolu si il n’y est pas u_u
                  Il t’a conseillé d’ajouter l’ “EntityAIWander” à la liste “tasks” de ton entitée, afin que celle-ci erre (de déplace d’elle même).

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

                    @‘AymericRed’:

                    Faut pas marquer le sujet comme résolu si il n’y est pas u_u
                    Il t’a conseillé d’ajouter l’ “EntityAIWander” à la liste “tasks” de ton entitée, afin que celle-ci erre (de déplace d’elle même).

                    1° Merci j’avais pas compris je vais essayer
                    2° j’ai pas fait exprès de le marquer en resolu o_o
                    3° je viens d’essayer et il bouge un peu une fois et apres plus rien il reste figé

                    P.S. J’arrive pas a le mettre en non resolu
                    P.S.2 maintenant l’entite bouge des que je pose le block mais il fait des tours ( il bouge en rond) et il a une vitesse affolante alors que je l’ai mis a 0.8D

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

                      File ta classe entière, on va jamais s’en sortir sinon…

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

                        @‘Plaigon’:

                        File ta classe entière, on va jamais s’en sortir sinon…

                        :::

                        package fr.clashofclan.common;
                        
                        import java.awt.Color;
                        
                        import cpw.mods.fml.common.Mod;
                        import cpw.mods.fml.common.Mod.EventHandler;
                        import cpw.mods.fml.common.Mod.Instance;
                        import cpw.mods.fml.common.SidedProxy;
                        import cpw.mods.fml.common.event.FMLInitializationEvent;
                        import cpw.mods.fml.common.event.FMLPostInitializationEvent;
                        import cpw.mods.fml.common.event.FMLPreInitializationEvent;
                        import cpw.mods.fml.common.registry.EntityRegistry;
                        import cpw.mods.fml.common.registry.GameRegistry;
                        import fr.clashofclan.proxy.CommonProxy;
                        import net.minecraft.block.Block;
                        import net.minecraft.block.material.Material;
                        import net.minecraft.creativetab.CreativeTabs;
                        
                        @Mod(modid = "clashofclan", name = "Clash Of Clan", version = "1.0.0")
                        
                        public class ClashOfClan {
                        @Instance("clashofclan")
                        public static ClashOfClan instance;
                        public static final String MODID = "clashofclan";
                        
                        @SidedProxy(clientSide = "fr.clashofclan.proxy.ClientProxy", serverSide = "fr.clashofclan.proxy.CommonProxy")
                        public static CommonProxy proxy;
                        
                        public static Block blockOr, blockElixir, blockTarget;
                        
                        @EventHandler
                        public void preInit(FMLPreInitializationEvent event)
                        {
                        blockOr = new BlockOr().setBlockName("BlockOr").setCreativeTab(CreativeTabs.tabBlock);
                        GameRegistry.registerBlock(blockOr, ItemBlockOr.class, "BlockOr");
                        blockElixir = new BlockElixir().setBlockName("BlockElixir").setCreativeTab(CreativeTabs.tabBlock);
                        GameRegistry.registerBlock(blockElixir, ItemBlockElixir.class, "BlockElixir");
                        blockTarget = new BlockTarget().setBlockName("BlockTarget").setBlockTextureName("clashofclan:BlockTarget").setCreativeTab(CreativeTabs.tabBlock);
                        GameRegistry.registerBlock(blockTarget, "BlockTarget");
                        }
                        
                        @EventHandler
                        public void init(FMLInitializationEvent event)
                        {
                        proxy.registerRender();
                        // Mob : Constructeur
                        EntityRegistry.registerGlobalEntityID(Constructeur.class, "Constructeur", EntityRegistry.findGlobalUniqueEntityId(), new Color(0, 255, 0).getRGB(), new Color(255, 0, 0).getRGB());
                        EntityRegistry.registerModEntity(Constructeur.class, "Constructeur", 420, this.instance, 40, 1, true);
                        // Mob : Barbare
                        EntityRegistry.registerGlobalEntityID(Barbare.class, "Barbare", EntityRegistry.findGlobalUniqueEntityId(), new Color(0, 255, 0).getRGB(), new Color(255, 0, 0).getRGB());
                        EntityRegistry.registerModEntity(Barbare.class, "Barbare", 421, this.instance, 40, 1, true);
                        // Mob : Archer
                        EntityRegistry.registerGlobalEntityID(Archer.class, "Archer", EntityRegistry.findGlobalUniqueEntityId(), new Color(0, 255, 0).getRGB(), new Color(255, 0, 0).getRGB());
                        EntityRegistry.registerModEntity(Archer.class, "Archer", 422, this.instance, 40, 1, true);
                        // Mob : Chevaucheurcochon
                        EntityRegistry.registerGlobalEntityID(Chevaucheurcochon.class, "Chevaucheurcochon", EntityRegistry.findGlobalUniqueEntityId(), new Color(0, 255, 0).getRGB(), new Color(255, 0, 0).getRGB());
                        EntityRegistry.registerModEntity(Chevaucheurcochon.class, "Chevaucheurcochon", 423, this.instance, 40, 1, true);
                        }
                        
                        @EventHandler
                        public void postInit(FMLPostInitializationEvent event)
                        {
                        
                        }
                        
                        }
                        
                        

                        ::::::

                        package fr.clashofclan.proxy;
                        
                        import cpw.mods.fml.client.registry.RenderingRegistry;
                        import fr.clashofclan.client.RenderArcher;
                        import fr.clashofclan.client.RenderBarbare;
                        import fr.clashofclan.client.RenderChevaucheurcochon;
                        import fr.clashofclan.client.RenderConstructeur;
                        import fr.clashofclan.common.Archer;
                        import fr.clashofclan.common.Barbare;
                        import fr.clashofclan.common.Chevaucheurcochon;
                        import fr.clashofclan.common.Constructeur;
                        import net.minecraft.client.model.ModelBiped;
                        
                        public class ClientProxy extends CommonProxy
                        {
                        @Override
                        public void registerRender()
                        {
                        System.out.println("méthode côté client");
                        RenderingRegistry.registerEntityRenderingHandler(Constructeur.class, new RenderConstructeur(new ModelBiped(), 0.5F));
                        RenderingRegistry.registerEntityRenderingHandler(Archer.class, new RenderArcher(new ModelBiped(), 0.5F));
                        RenderingRegistry.registerEntityRenderingHandler(Barbare.class, new RenderBarbare(new ModelBiped(), 0.5F));
                        RenderingRegistry.registerEntityRenderingHandler(Chevaucheurcochon.class, new RenderChevaucheurcochon(new ModelBiped(), 0.5F));
                        }
                        }
                        

                        ::::::

                        package fr.clashofclan.common;
                        
                        import net.minecraft.block.Block;
                        import net.minecraft.entity.Entity;
                        import net.minecraft.entity.EntityCreature;
                        import net.minecraft.entity.SharedMonsterAttributes;
                        import net.minecraft.entity.ai.EntityAIWander;
                        import net.minecraft.init.Blocks;
                        import net.minecraft.world.World;
                        import net.minecraftforge.event.entity.EntityEvent;
                        
                        public class Archer extends EntityCreature{
                        
                        public Archer(World world) {
                        super(world);
                        this.tasks.addTask(0, new EntityAIMoveToCustomBlock(this, 0.5D, ClashOfClan.blockTarget, 9));
                        this.tasks.addTask(1, new EntityAIWander(this, 1.0D));
                        }
                        
                        public void applyEntityAttributes() {
                        super.applyEntityAttributes();
                        this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(20D);
                        this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(0.5D);
                        }
                        
                        public Entity getEntityToAttack() {
                        return null;
                        }
                        @Override
                        protected boolean isAIEnabled()
                        {
                        return true;
                        }
                        }
                        
                        

                        ::::::

                        package fr.clashofclan.client;
                        
                        import fr.clashofclan.common.Archer;
                        import fr.clashofclan.common.ClashOfClan;
                        import net.minecraft.client.model.ModelBiped;
                        import net.minecraft.client.renderer.entity.RenderBiped;
                        import net.minecraft.entity.EntityLiving;
                        import net.minecraft.util.ResourceLocation;
                        
                        public class RenderArcher extends RenderBiped {
                        
                        public final ResourceLocation texture = new ResourceLocation(ClashOfClan.MODID, "textures/entity/Archer.png");
                        
                        public RenderArcher(ModelBiped model, float shadow)
                        {
                        super(model, shadow);
                        }
                        protected ResourceLocation getEntityTexture(EntityLiving living)
                        {
                        return this.getArcherTexture((Archer)living);
                        }
                        
                        private ResourceLocation getArcherTexture(Archer Archer)
                        {
                        return texture;
                        }
                        }
                        

                        ::::::

                        package fr.clashofclan.common;
                        
                        import net.minecraft.block.Block;
                        import net.minecraft.entity.EntityLiving;
                        import net.minecraft.entity.ai.EntityAIBase;
                        
                        public class EntityAIMoveToCustomBlock extends EntityAIBase
                        {
                        private EntityLiving livingEntity;
                        private double xPosition;
                        private double yPosition;
                        private double zPosition;
                        private double speed;
                        private Block targetBlockType;
                        private int radiusDetection;
                        
                        public EntityAIMoveToCustomBlock(EntityLiving p_i1648_1_, double p_i1648_2_, Block targetBlockType, int radiusDetection)
                        {
                        this.livingEntity = p_i1648_1_;
                        this.speed = p_i1648_2_;
                        this.targetBlockType = targetBlockType;
                        this.radiusDetection = radiusDetection;
                        this.setMutexBits(1);
                        }
                        
                        /**
                        * Returns whether the EntityAIBase should begin execution.
                        */
                        public boolean shouldExecute()
                        {
                        for(int xOffset = -radiusDetection; xOffset < radiusDetection; xOffset++)//On remonte l'axe des X
                        {
                        for(int yOffset = -radiusDetection; yOffset < radiusDetection; yOffset++)//On remonte l'axe des Y
                        {
                        for(int zOffset = -radiusDetection; zOffset < radiusDetection; zOffset++)//On remonte l'axe des Z
                        {
                        if(livingEntity.worldObj.getBlock((int)livingEntity.posX + xOffset, (int)livingEntity.posY, (int)livingEntity.posZ + zOffset) == targetBlockType)//Si le block situé à un couple spécifique de coordonnées (précédemment remontées via les for loops), correspond à ton block recherché
                        {
                        //Alors on affecte au couple de positions que l'entity va devoir suivre
                        this.xPosition = livingEntity.posX + xOffset;
                        this.yPosition = livingEntity.posY + yOffset;
                        this.zPosition = livingEntity.posZ + zOffset;
                        return true;
                        }
                        }
                        }
                        }
                        return false;
                        }
                        
                        /**
                        * Returns whether an in-progress EntityAIBase should continue executing
                        */
                        public boolean continueExecuting()
                        {
                        return !this.livingEntity.getNavigator().noPath();//On continue tant que l'entity a un PathNavigate d'instancié
                        }
                        
                        /**
                        * Execute a one shot task or start executing a continuous task
                        */
                        public void startExecuting()
                        {
                        this.livingEntity.getNavigator().tryMoveToXYZ(this.xPosition, this.yPosition, this.zPosition, this.speed);//On la fait se déplacer si shouldExecute a renvoyé true, donc si le couple de positions a forcément été reset à de bonnes valeurs
                        }
                        
                        public void resetTask()
                        {
                        super.resetTask();
                        }
                        
                        public void updateTask()
                        {
                        this.livingEntity.getNavigator().tryMoveToXYZ(this.xPosition, this.yPosition, this.zPosition, this.speed);
                        }
                        }
                        

                        ::::::

                        package fr.clashofclan.common;
                        
                        import java.util.List;
                        import net.minecraft.block.Block;
                        import net.minecraft.block.material.Material;
                        import net.minecraft.client.renderer.texture.IIconRegister;
                        import net.minecraft.creativetab.CreativeTabs;
                        import net.minecraft.item.Item;
                        import net.minecraft.item.ItemStack;
                        import net.minecraft.util.IIcon;
                        
                        public class BlockTarget extends Block
                        {
                        protected BlockTarget()
                        {
                        super(Material.rock);
                        }
                        }
                        
                        

                        :::
                        Voila je crois qu’il y a tous

                        EDIT: Finalement j’ai reussi j’ai maj les codes pour ce qui les veulent

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

                          Vous avez trouvé l’erreur(s) ?

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

                          MINECRAFT FORGE FRANCE © 2024

                          Powered by NodeBB