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

      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