• S'inscrire
    • Se connecter
    • Recherche
    • Récent
    • Mots-clés
    • Populaire
    • Utilisateurs
    • Groupes

    Résolu Mob Aprivoisable

    1.7.x
    1.7.2
    4
    12
    1526
    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.
    • BurningCraft
      BurningCraft dernière édition par

      Bonjour Tous le monde,

      Je voudrait faire en sorte que mon mob puisse etre apprivoisable donc j’ai regarder le code du loup et j’ai reussis a faire un truc XD mais le problème c’est que le mob me semble être apprivoiser(particule qui apparaise comme si on l’avait apprivoiser) mais il ne suis pas le joueur voici le code :

      package fr.burning.lfc.tile;
      
      import cpw.mods.fml.relauncher.Side;
      import cpw.mods.fml.relauncher.SideOnly;
      import fr.burning.lfc.LaFrenchCraftMOD;
      import net.minecraft.block.BlockColored;
      import net.minecraft.client.model.ModelSheep1;
      import net.minecraft.entity.Entity;
      import net.minecraft.entity.EntityAgeable;
      import net.minecraft.entity.EntityLivingBase;
      import net.minecraft.entity.SharedMonsterAttributes;
      import net.minecraft.entity.ai.EntityAIFollowParent;
      import net.minecraft.entity.ai.EntityAIHurtByTarget;
      import net.minecraft.entity.ai.EntityAILookIdle;
      import net.minecraft.entity.ai.EntityAIMate;
      import net.minecraft.entity.ai.EntityAIOwnerHurtByTarget;
      import net.minecraft.entity.ai.EntityAIOwnerHurtTarget;
      import net.minecraft.entity.ai.EntityAIPanic;
      import net.minecraft.entity.ai.EntityAISwimming;
      import net.minecraft.entity.ai.EntityAITargetNonTamed;
      import net.minecraft.entity.ai.EntityAITempt;
      import net.minecraft.entity.ai.EntityAIWander;
      import net.minecraft.entity.ai.EntityAIWatchClosest;
      import net.minecraft.entity.passive.EntityAnimal;
      import net.minecraft.entity.passive.EntitySheep;
      import net.minecraft.entity.passive.EntityTameable;
      import net.minecraft.entity.passive.EntityWolf;
      import net.minecraft.entity.player.EntityPlayer;
      import net.minecraft.init.Items;
      import net.minecraft.item.Item;
      import net.minecraft.item.ItemFood;
      import net.minecraft.item.ItemStack;
      import net.minecraft.nbt.NBTTagCompound;
      import net.minecraft.pathfinding.PathEntity;
      import net.minecraft.util.MathHelper;
      import net.minecraft.world.World;
      
      public class EntityOurs extends EntityTameable
      {
      private int OursTimer;
      public EntityOurs(World world) {
              super(world);
      
              this.getNavigator().setAvoidsWater(true);
      
              this.setSize(1.5F, 0.9F);
      
              this.isImmuneToFire = false;
              float var2 = 0.25F;
      
              this.tasks.addTask(0, new EntityAISwimming(this));      
              this.tasks.addTask(1, new EntityAIPanic(this, 0.38F));
              this.tasks.addTask(5, new EntityAIWander(this, var2));
              this.tasks.addTask(6, new EntityAIWatchClosest(this, EntityPlayer.class, 6.0F));
              this.tasks.addTask(7, new EntityAILookIdle(this));
      
              this.setTamed(false);
      }
      public void applyEntityAttributes()
      {
       super.applyEntityAttributes();
             this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(0.3D);
             if (this.isTamed()) {
                 this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(100.0D);
             }
             else {
                 this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(8.0D); 
             }
      
      }
      public void setTamed(boolean par1)
          {
              super.setTamed(par1);
      
              if (par1)
              {
                  this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(100.0D);
              }
              else
              {
                  this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(8.0D);
              }
          }
      
      protected void updateAITick()
          {
              this.dataWatcher.updateObject(18, Float.valueOf(this.getHealth()));
          }
      
          protected void entityInit()
          {
              super.entityInit();
              this.dataWatcher.addObject(18, new Float(this.getHealth()));
              this.dataWatcher.addObject(19, new Byte((byte)0));
              this.dataWatcher.addObject(20, new Byte((byte)BlockColored.func_150032_b(1)));
          }
      
          public boolean interact(EntityPlayer par1EntityPlayer)
          {
          ItemStack itemstack = par1EntityPlayer.inventory.getCurrentItem();
      
              if (this.isTamed())
              {
                  if (itemstack != null)
                  {
                      if (itemstack.getItem() instanceof ItemFood)
                      {
                          ItemFood itemfood = (ItemFood)itemstack.getItem();
      
                          if (itemfood.isWolfsFavoriteMeat() && this.dataWatcher.getWatchableObjectFloat(18) < 20.0F)
                          {
                              if (!par1EntityPlayer.capabilities.isCreativeMode)
                              {
                                  –itemstack.stackSize;
                              }
      
                              this.heal((float)itemfood.func_150905_g(itemstack));
      
                              if (itemstack.stackSize <= 0)
                              {
                                  par1EntityPlayer.inventory.setInventorySlotContents(par1EntityPlayer.inventory.currentItem, (ItemStack)null);
                              }
      
                              return true;
                          }
                      }
                  }
      
                  if (par1EntityPlayer.getCommandSenderName().equalsIgnoreCase(this.getOwnerName()) && !this.worldObj.isRemote && !this.isBreedingItem(itemstack))
                  {
                      this.aiSit.setSitting(!this.isSitting());
                      System.out.println("sit");
                      this.isJumping = false;
                      this.setPathToEntity((PathEntity)null);
                      this.setTarget((Entity)null);
                      this.setAttackTarget((EntityLivingBase)null);
                  }
              }
              else if (itemstack != null && itemstack.getItem() == Items.apple)
              {
                  if (!par1EntityPlayer.capabilities.isCreativeMode)
                  {
                      --itemstack.stackSize;
                  }
      
                  if (itemstack.stackSize <= 0)
                  {
                      par1EntityPlayer.inventory.setInventorySlotContents(par1EntityPlayer.inventory.currentItem, (ItemStack)null);
                  }
      
                  if (!this.worldObj.isRemote)
                  {
                      if (this.rand.nextInt(3) == 0)
                      {
                          this.setTamed(true);
                          this.setPathToEntity((PathEntity)null);
                          this.setAttackTarget((EntityLivingBase)null);
                          this.aiSit.setSitting(true);
                          this.setHealth(100.0F);
                          this.setOwner(par1EntityPlayer.getCommandSenderName());
                          this.playTameEffect(true);
                          this.worldObj.setEntityState(this, (byte)7);
                      }
                      else
                      {
                          this.playTameEffect(false);
                          this.worldObj.setEntityState(this, (byte)6);
                      }
                  }
      
                  return true;
              }
      
              return super.interact(par1EntityPlayer);
          }
      
      public boolean isAIEnabled() {
              return true;
      }
      
      @SideOnly(Side.CLIENT)
      public float func_70894_j(float par1)
      {
          return this.OursTimer <= 0 ? 0.0F : (this.OursTimer >= 4 && this.OursTimer <= 36 ? 1.0F : (this.OursTimer < 4 ? ((float)this.OursTimer - par1) / 4.0F : -((float)(this.OursTimer - 40) - par1) / 4.0F));
      }
      
      @SideOnly(Side.CLIENT)
      public float func_70890_k(float par1)
      {
          if (this.OursTimer > 4 && this.OursTimer <= 36)
          {
              float f1 = ((float)(this.OursTimer - 4) - par1) / 32.0F;
              return ((float)Math.PI / 5F) + ((float)Math.PI * 7F / 100F) * MathHelper.sin(f1 * 28.7F);
          }
          else
          {
              return this.OursTimer > 0 ? ((float)Math.PI / 5F) : this.rotationPitch / (180F / (float)Math.PI);
          }
      }
      
      //drop
      protected Item getDropItemId() {
              return LaFrenchCraftMOD.Anis;
      }
      
      @Override
      public EntityAgeable createChild(EntityAgeable var1) {
      // TODO Auto-generated method stub
      return null;
      }
      }
      
      

      j’espère que quelqu’un pourra m’aider ^^

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

        Il me semble que c’est un ligne d’IA à rajouter dans le constructeur.

        1 réponse Dernière réponse Répondre Citer 0
        • BurningCraft
          BurningCraft dernière édition par

          @‘Plaigon’:

          Il me semble que c’est un ligne d’IA à rajouter dans le constructeur.

          J’ai pas trouver la quel c’est ? tu la connais ?

          Edit :

          j’ai trouver ceux la dans le code du loup mais sa ne change rien

            this.targetTasks.addTask(1, new EntityAIOwnerHurtByTarget(this));
                  this.targetTasks.addTask(2, new EntityAIOwnerHurtTarget(this));
                  this.targetTasks.addTask(3, new EntityAIHurtByTarget(this, true));
                  this.targetTasks.addTask(4, new EntityAITargetNonTamed(this, EntitySheep.class, 200, false));
          
          1 réponse Dernière réponse Répondre Citer 0
          • SCAREX
            SCAREX dernière édition par

            Est-ce que les tasks sont bien mises à jour ?

            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
            • BurningCraft
              BurningCraft dernière édition par

              @‘SCAREX’:

              Est-ce que les tasks sont bien mises à jour ?

              On fais comment pour les mètre a jour ?

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

                Il y a une fonction updateTasks je crois

                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
                • BurningCraft
                  BurningCraft dernière édition par

                  @‘SCAREX’:

                  Il y a une fonction updateTasks je crois

                  J’ai pas cette fonction mais j’ai updateAItick

                  1 réponse Dernière réponse Répondre Citer 0
                  • BurningCraft
                    BurningCraft dernière édition par

                    Me revoila j’ai reussis a le rendre apprivoisable et il me suis donc tout va bien, mais j’aimerais que le joueur reçoive un message dans le chat quand le mob est assis ^^

                    j’ai essayer mit sa dans la class du model mais le probleme c’est que sa spam le chat de message ^^ tant que le mob est assis comment faire pour que sa affiche 1 seul message ?

                     EntityOurs entityOurs = (EntityOurs)par1EntityLivingBase;
                          if (entityOurs.isSitting())
                          {
                         Minecraft.getMinecraft().thePlayer.addChatComponentMessage(new ChatComponentText("test"));
                          }
                    
                    1 réponse Dernière réponse Répondre Citer 0
                    • AymericRed
                      AymericRed dernière édition par

                      Dans EntityWolf, il y a une fonction interact() qui gère ça, t’a juste à trouver la bonne ligne.

                      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
                      • BurningCraft
                        BurningCraft dernière édition par

                        @‘AymericRed’:

                        Dans EntityWolf, il y a une fonction interact() qui gère ça, t’a juste à trouver la bonne ligne.

                        je ne voit pas la ligne :s

                        Mais Le loup n’affiche pas un message dans le chat quand le joueur l’assoie donc pourquoi chercher dans EntityWolf ^^ ?

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

                          Désolé, dans ma tête, ton entité était extends Entitywolf 😞

                          Mais ça ne change rien, dans ta classe, à la méthode interact(), rajoute ton code après ce if :

                          
                          if (par1EntityPlayer.getCommandSenderName().equalsIgnoreCase(this.getOwnerName()) && !this.worldObj.isRemote && !this.isBreedingItem(itemstack))
                          
                          

                          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
                          • BurningCraft
                            BurningCraft dernière édition par

                            @‘AymericRed’:

                            Désolé, dans ma tête, ton entité était extends Entitywolf 😞

                            Mais ça ne change rien, dans ta classe, à la méthode interact(), rajoute ton code après ce if :

                            
                            if (par1EntityPlayer.getCommandSenderName().equalsIgnoreCase(this.getOwnerName()) && !this.worldObj.isRemote && !this.isBreedingItem(itemstack))
                            
                            

                            Merci, sa marche parfaitement 🙂

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

                            MINECRAFT FORGE FRANCE © 2018

                            Powered by NodeBB