MFF

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

    Mob qui traverse le sol

    Planifier Épinglé Verrouillé Déplacé Résolu 1.7.x
    1.7.10
    19 Messages 5 Publieurs 2.9k 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.
    • robin4002R Hors-ligne
      robin4002 Moddeurs confirmés Rédacteurs Administrateurs
      dernière édition par

      Tu bloques sur quoi ?

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

        Bah comment faire pour que le mob suivent le joueur il ne me manque que ça après je me débrouille mais bon sans ça pas de vente serveur = pas de revenue = je l’ai ou je pense la machine coûtant très cher =p

        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

          Dans la classe du loup il y a tout ce qu’il te faut non ?

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

            Bah oui et non on va dire que j’ai tout test ou presque j’ai copié cette fonction :

             public boolean interact(EntityPlayer p_70085_1_)
                {
                    ItemStack var2 = p_70085_1_.inventory.getCurrentItem();
            
                    if (this.isTamed())
                    {
                        if (var2 != null)
                        {
                            if (var2.getItem() instanceof ItemFood)
                            {
                                ItemFood var3 = (ItemFood)var2.getItem();
            
                                if (var3.isWolfsFavoriteMeat() && this.dataWatcher.getWatchableObjectFloat(18) < 20.0F)
                                {
                                    if (!p_70085_1_.capabilities.isCreativeMode)
                                    {
                                        –var2.stackSize;
                                    }
            
                                    this.heal((float)var3.func_150905_g(var2));
            
                                    if (var2.stackSize <= 0)
                                    {
                                        p_70085_1_.inventory.setInventorySlotContents(p_70085_1_.inventory.currentItem, (ItemStack)null);
                                    }
            
                                    return true;
                                }
                            }
                            else if (var2.getItem() == Items.dye)
                            {
                                int var4 = BlockColored.func_150032_b(var2.getItemDamage());
            
                                if (var4 != this.getCollarColor())
                                {
                                    this.setCollarColor(var4);
            
                                    if (!p_70085_1_.capabilities.isCreativeMode && --var2.stackSize <= 0)
                                    {
                                        p_70085_1_.inventory.setInventorySlotContents(p_70085_1_.inventory.currentItem, (ItemStack)null);
                                    }
            
                                    return true;
                                }
                            }
                        }
            
                        if (this.func_152114_e(p_70085_1_) && !this.worldObj.isClient && !this.isBreedingItem(var2))
                        {
                            this.aiSit.setSitting(!this.isSitting());
                            this.isJumping = false;
                            this.setPathToEntity((PathEntity)null);
                            this.setTarget((Entity)null);
                            this.setAttackTarget((EntityLivingBase)null);
                        }
                    }
                    else if (var2 != null && var2.getItem() == Items.bone && !this.isAngry())
                    {
                        if (!p_70085_1_.capabilities.isCreativeMode)
                        {
                            --var2.stackSize;
                        }
            
                        if (var2.stackSize <= 0)
                        {
                            p_70085_1_.inventory.setInventorySlotContents(p_70085_1_.inventory.currentItem, (ItemStack)null);
                        }
            
                        if (!this.worldObj.isClient)
                        {
                            if (this.rand.nextInt(3) == 0)
                            {
                                this.setTamed(true);
                                this.setPathToEntity((PathEntity)null);
                                this.setAttackTarget((EntityLivingBase)null);
                                this.aiSit.setSitting(true);
                                this.setHealth(20.0F);
                                this.func_152115_b(p_70085_1_.getUniqueID().toString());
                                this.playTameEffect(true);
                                this.worldObj.setEntityState(this, (byte)7);
                            }
                            else
                            {
                                this.playTameEffect(false);
                                this.worldObj.setEntityState(this, (byte)6);
                            }
                        }
            
                        return true;
                    }
            
                    return super.interact(p_70085_1_);
                }
            
            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

              Ce n’est pas dans interact que c’est géré. interact c’est pour adopter l’entité/la nourrir/faire qu’elle s’assoie. C’est plutôt dans la fonction update.

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

                Non il me semble qu’il y a une AI dédiée à ça

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

                  package fr.Mosca421.Mobs;
                  
                  import cpw.mods.fml.common.registry.GameRegistry;
                  import net.minecraft.block.BlockColored;
                  import net.minecraft.client.Minecraft;
                  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.EntityAIFollowOwner;
                  import net.minecraft.entity.monster.EntityMob;
                  import net.minecraft.entity.passive.EntityTameable;
                  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.pathfinding.PathEntity;
                  import net.minecraft.world.World;
                  
                  public class MobKurby extends EntityTameable {
                  
                      private float field_70926_e;
                      private float field_70924_f;
                  
                  public MobKurby (World world)
                  {
                  super(world);
                  this.setSize(0.7F, 0.7F);
                          this.tasks.addTask(5, new EntityAIFollowOwner(this, 1.0D, 10.0F, 2.0F));
                  
                  }
                  public void applyEntityAttributes(EntityPlayer player)
                  {
                  super.applyEntityAttributes();
                  this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(5000D);
                          this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(1D);
                      }
                  
                      public boolean isAIEnabled()
                      {
                          return true;
                      }
                  
                  @Override
                      public boolean isEntityInvulnerable()
                      {
                          return true;
                      }
                      protected boolean canDespawn()
                      {
                          return false;
                      }
                      public boolean interact(EntityPlayer player)
                      {
                           this.setTamed(true);
                           this.setPathToEntity((PathEntity)null);
                           this.setAttackTarget((EntityLivingBase)null);
                           this.func_152115_b(player.getUniqueID().toString());
                           this.worldObj.setEntityState(this, (byte)7);
                  
                  return true;
                      }
                  
                      public void onUpdate(EntityPlayer player)
                      {
                          super.onUpdate();
                          if (this.func_70922_bv())
                          {
                              this.field_70926_e += (1.0F - this.field_70926_e) * 0.4F;
                          }
                          else
                          {
                              this.field_70926_e += (0.0F - this.field_70926_e) * 0.4F;
                          }
                  
                          if (this.func_70922_bv())
                          {
                              this.numTicksToChaseTarget = 10;
                          }
                      }
                  
                  @Override
                  public EntityAgeable createChild(EntityAgeable p_90011_1_) {
                  
                  return null;
                  }
                  public boolean func_70922_bv()
                     {
                         return this.dataWatcher.getWatchableObjectByte(19) == 1;
                     }
                  public void setTamed(boolean p_70903_1_)
                     {
                         super.setTamed(p_70903_1_);
                  
                     }
                  }
                  
                  

                  En tout cas ça marche plus ou moins comme ça 😃

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

                    J’ai juste une petite demande mais comment je peux faire pour lorsque le joueur pose l’oeuf le kirby soit direct adopter par celui qui l’a poser
                    Et comment faire pour que celui qui la poser lorsque qu’il interact avec lui il le recup mais que lui pas d’autre personne
                    J’ai vite fais bricoler ça :

                        public boolean interact(EntityPlayer player)
                        {
                    
                        if (adopt == 0)
                        {
                             this.setTamed(true);
                             this.setPathToEntity((PathEntity)null);
                             this.setAttackTarget((EntityLivingBase)null);
                             this.func_152115_b(player.getUniqueID().toString());
                             this.worldObj.setEntityState(this, (byte)7);
                    
                        }
                        if (adopt == 1 && isTamed() && player()){
                        this.setDead();
                        player.inventory.addItemStackToInventory(new ItemStack(Items.spawn_egg, 1, 23));
                        }
                            adopt = 1;
                    return true;
                        }
                    
                    1 réponse Dernière réponse Répondre Citer 0
                    • FolganskyF Hors-ligne
                      Folgansky Correcteurs
                      dernière édition par

                      Sujet ici Monture custom

                      Récupérer l’UUID du joueur, le stocker dans la monture et n’autorise le mountEntity que si les UUID correspondent

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

                        Alors j’ai fais un peux comme tu as dis :
                        [15:08:17] [Server thread/INFO] [STDOUT]: [fr.Mosca421.Mobs.MobKurby:interact:78]: 1  ae45ff8b-f50f-371e-b691-661c04edb569
                        [15:08:17] [Server thread/INFO] [STDOUT]: [fr.Mosca421.Mobs.MobKurby:interact:79]: 2  ae45ff8b-f50f-371e-b691-661c04edb569

                         public boolean interact(EntityPlayer player)
                            {
                            if (adopt == 0)
                            {
                                 this.setTamed(true);
                                 this.setPathToEntity((PathEntity)null);
                                 this.setAttackTarget((EntityLivingBase)null);
                                 this.func_152115_b(player.getUniqueID().toString());
                                 this.worldObj.setEntityState(this, (byte)7);
                            }
                            String uiid = func_152113_b();
                            String uuid = player.getGameProfile().getId().toString();
                            System.out.println("1  "+uiid);
                            System.out.println("2  "+uuid);
                            if (adopt == 1 && isTamed() && uuid == uiid){
                            this.setDead();
                            player.inventory.addItemStackToInventory(new ItemStack(Items.spawn_egg, 1, 23));
                            }
                                adopt = 1;
                        return true;
                            }
                        

                        Mais ici     if (adopt == 1 && isTamed() && uuid == uiid){
                        Si je dis != je ramasse mais sinon == je ramasse pas pourtant c’est égal non ?

                        1 réponse Dernière réponse Répondre Citer 0
                        • FolganskyF Hors-ligne
                          Folgansky Correcteurs
                          dernière édition par

                          Tu devrais regarder plus généralement le post.

                          Notamment les passages sur les datawatchers, leur enregistrement dans l’event au moment où l’entité est créée.

                          public void handleConstruction(EntityConstructing event)
                          […]
                           else if(event.entity instanceof EntityBaignoire)
                                 {
                                     DataWatcher dw = event.entity.getDataWatcher();
                                     dw.addObject(31, "id");
                                 }
                          

                          Au final dans ta condition tu devrais avoir qqch comme:

                          player.getUniqueID().toString().equals(this.getDataWatcher().getWatchableObjectString(31)    //le 31 est en exemple
                          

                          Edit:
                          J’utilise un item pour faire spawn mes entités, par exemple, dans la méthode onItemUse:

                           else if (metadata == 9)
                              {
                                  EntityBaignoire e = new EntityBaignoire(world);
                                  if(!world.isRemote)
                                  {
                                      e.setPosition(x, y + 1.0F, z);
                                      world.spawnEntityInWorld(e);
                                      stack.stackSize–;
                                      e.getDataWatcher().updateObject(31, player.getGameProfile().getId().toString());
                                  }
                                      return true;
                              }
                          
                          1 réponse Dernière réponse Répondre Citer 0
                          • M Hors-ligne
                            mosca421
                            dernière édition par

                            Je ne comprends pas les datawatcher =/ comment ça fonctionne ? a quoi ils servent ?

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

                              http://www.minecraftforge.net/wiki/Datawatcher

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

                                Okey ça marche en multi mais j’ai un petit bug : quand mon perso 1 adopte et l’enleve ça marche mais quand le perso 1 adopte et le perso deux essaye de le viré ça le vire pour perso 2 mais pas pour perso 1

                                    public boolean interact(EntityPlayer player)
                                    {
                                    DataWatcher dw = this.getDataWatcher();
                                    if (adopt == 0)
                                    {
                                
                                         this.setTamed(true);
                                         this.setPathToEntity((PathEntity)null);
                                         this.setAttackTarget((EntityLivingBase)null);
                                         this.func_152115_b(player.getUniqueID().toString());
                                         this.worldObj.setEntityState(this, (byte)7);
                                         dw.addObject(31, func_152113_b());
                                    }
                                    boolean uiid = player.getUniqueID().toString().equals(this.getDataWatcher().getWatchableObjectString(31));
                                    String uuid = player.getGameProfile().getId().toString();
                                    System.out.println("1  "+uiid);
                                    System.out.println("2  "+uuid);
                                    if (adopt == 1 && player.getUniqueID().toString().equals(this.getDataWatcher().getWatchableObjectString(31)) == true){
                                    this.setDead();
                                    player.inventory.addItemStackToInventory(new ItemStack(Items.spawn_egg, 1, 23));
                                    }
                                        adopt = 1;
                                return true;
                                    }
                                
                                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