MFF

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

    Et le comportement des mobs

    Planifier Épinglé Verrouillé Déplacé Sans suite
    1.6.2
    15 Messages 4 Publieurs 4.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.
    • Superloup10S Hors-ligne
      Superloup10 Modérateurs
      dernière édition par

      Salut, je voudrais savoir si s’est possible de faire un mob qui détruit tous les blocs sur son passage, si oui, quel type de code devrais-je mettre?
      Autre question, je voudrais savoir comment monter un mob sans selle, car à chaque fois, que j’ai essayé, en mettant les codes du cochon, je ne pouvais pas monter le mob.

      Cordialement,

      Superloup10

      Si vous souhaitez me faire un don, il vous suffit de cliquer sur le bouton situé en dessous.

      Je suis un membre apprécié et joueur, j'ai déjà obtenu 17 points de réputation.

      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

        Ha mince, je t’es laissé un vent à ton mp, je l’avais lu, mais j’avais pas le temps de faire des tests, et au final j’ai oublié, désolé :x

        Pour le mob qui détruit tout sur son passage, tu peux regarder le bonhomme de neige, il pose des blocs, pour la destruction c’est un peu le même principe, sauf que tu fais des setBlockToAir(x, y, z)

        Pour monter un animal, je sais pas.

        1 réponse Dernière réponse Répondre Citer 0
        • Superloup10S Hors-ligne
          Superloup10 Modérateurs
          dernière édition par

          Ok, mais c’est possible de détruire de tout blocs autres que de l’obsidienne via une condition ou il y a une méthode plus simple?

          Si vous souhaitez me faire un don, il vous suffit de cliquer sur le bouton situé en dessous.

          Je suis un membre apprécié et joueur, j'ai déjà obtenu 17 points de réputation.

          1 réponse Dernière réponse Répondre Citer 0
          • elias54E Hors-ligne
            elias54 Administrateurs
            dernière édition par

            Pour qu’il détruise les blocks, il suffit de mettre la fonction que robin t’a montré. Et si tu veux un truc + joli quand le mob détruit un block, ajoutes ça en dessous de world.setBlockToAir :

            
            Block block;
            
            block = /*TaClassePrincipale.LeBlock ou */ Block.grass /*par exemple*/
            
            FMLClientHandler.instance().getClient().effectRenderer.addBlockDestroyEffects(xTile, yTile, zTile, block.blockID & 0xff, Block.stone.blockID >> 8 & 0xff);
            FMLClientHandler.instance().getClient().sndManager.playSound(block.stepSound.getBreakSound(), (float)posX+ 0.5F, (float)posY + 0.5F, (float)posZ + 0.5F, (block.stepSound.getVolume() + 1.0F) / 2.0F, block.stepSound.getPitch() * 0.8F);
            
            

            Et pour que ton mob puisse chevaucher un autre mob, il suffit d’ajouter ce code :

            
            public boolean interact(EntityPlayer player)
            {
            player.mountEntity(this);
            }
            
            

            Ces codes sont à mettre dans l’entity !

            Mon site | GitHub

            1 réponse Dernière réponse Répondre Citer 0
            • Superloup10S Hors-ligne
              Superloup10 Modérateurs
              dernière édition par

              J’ai ```java
              interact(EntityPlayer player)

              Si vous souhaitez me faire un don, il vous suffit de cliquer sur le bouton situé en dessous.

              Je suis un membre apprécié et joueur, j'ai déjà obtenu 17 points de réputation.

              1 réponse Dernière réponse Répondre Citer 0
              • elias54E Hors-ligne
                elias54 Administrateurs
                dernière édition par

                Ajoutes return true pardon. ^^

                Mon site | GitHub

                1 réponse Dernière réponse Répondre Citer 0
                • Superloup10S Hors-ligne
                  Superloup10 Modérateurs
                  dernière édition par

                  Bon, j’ai du fail quelque part, voici la classe de mon mob:

                  package ere_geologique.common.entity;
                  
                  import java.util.List;
                  
                  import cpw.mods.fml.client.FMLClientHandler;
                  
                  import net.minecraft.block.Block;
                  import net.minecraft.entity.Entity;
                  import net.minecraft.entity.EntityAgeable;
                  import net.minecraft.entity.SharedMonsterAttributes;
                  import net.minecraft.entity.monster.EntityMob;
                  import net.minecraft.entity.player.EntityPlayer;
                  import net.minecraft.item.ItemStack;
                  import net.minecraft.util.DamageSource;
                  import net.minecraft.util.MathHelper;
                  import net.minecraft.world.World;
                  import ere_geologique.common.block.EGBlockList;
                  
                  public class Triceratops extends EntityMob
                  {
                  private int angerLevel;
                  private int randomSoundDelay;
                  
                  public Triceratops(World world)
                  {
                  super(world);
                  this.setSize(1.0F, 1.0F);
                  }
                  
                  protected void applyEntityAttributes()
                  {
                  super.applyEntityAttributes();
                  this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setAttribute(40D);
                  this.getEntityAttribute(SharedMonsterAttributes.followRange).setAttribute(40.0D);
                  this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setAttribute(0.69);
                  this.getEntityAttribute(SharedMonsterAttributes.attackDamage).setAttribute(10.0D);
                  }
                  
                  public void onLivingUpdate()
                  {
                  super.onLivingUpdate();
                  
                  int i = MathHelper.floor_double(this.posX);
                  int j = MathHelper.floor_double(this.posZ);
                  for (i = 0; i < 4; ++i)
                  {
                  j = MathHelper.floor_double(this.posX + (double)((float)(i % 2 * 2 - 1) * 0.25F));
                  int k = MathHelper.floor_double(this.posY);
                  int l = MathHelper.floor_double(this.posZ + (double)((float)(i / 2 % 2 * 2 - 1) * 0.25F));
                  this.worldObj.setBlockToAir(j, k, l);
                  Block block;
                  
                  block = Block.grass;
                  
                  FMLClientHandler.instance().getClient().effectRenderer.addBlockDestroyEffects(j, k, l, block.blockID & 0xff, Block.stone.blockID >> 8 & 0xff);
                  FMLClientHandler.instance().getClient().sndManager.playSound(block.stepSound.getBreakSound(), (float)posX+ 0.5F, (float)posY + 0.5F, (float)posZ + 0.5F, (block.stepSound.getVolume() + 1.0F) / 2.0F, block.stepSound.getPitch() * 0.8F);
                  }
                  }
                  
                  public boolean interact(EntityPlayer player)
                  {
                  player.mountEntity(this);
                  return true;
                  }
                  
                  protected Entity findPlayerToAttack()
                  {
                  return this.angerLevel == 0 ? null : super.findPlayerToAttack();
                  }
                  
                  public boolean attackEntityFrom(DamageSource par1DamageSource, float par2)
                  {
                  if (this.isEntityInvulnerable())
                  {
                  return false;
                  }
                  else
                  {
                  Entity entity = par1DamageSource.getEntity();
                  
                  if (entity instanceof EntityPlayer)
                  {
                  List list = this.worldObj.getEntitiesWithinAABBExcludingEntity(this, this.boundingBox.expand(32.0D, 32.0D, 32.0D));
                  
                  for (int i = 0; i < list.size(); ++i)
                  {
                  Entity entity1 = (Entity)list.get(i);
                  
                  if (entity1 instanceof Triceratops)
                  {
                  Triceratops triceratops = (Triceratops)entity1;
                  triceratops.becomeAngryAt(entity);
                  }
                  }
                  
                  this.becomeAngryAt(entity);
                  }
                  
                  return super.attackEntityFrom(par1DamageSource, par2);
                  }
                  }
                  
                  private void becomeAngryAt(Entity par1Entity)
                  {
                  this.entityToAttack = par1Entity;
                  this.angerLevel = 400 + this.rand.nextInt(400);
                  this.randomSoundDelay = this.rand.nextInt(40);
                  }
                  
                  public Triceratops spawnBabyAnimal(EntityAgeable entityageable)
                  {
                  return new Triceratops(this.worldObj);
                  }
                  
                  public boolean isBreedingItem(ItemStack itemstack)
                  {
                  return itemstack != null && itemstack.itemID == EGBlockList.Sapling.blockID;
                  }
                  
                  public Triceratops createChild(EntityAgeable par1EntityAgeable)
                  {
                  return this.spawnBabyAnimal(par1EntityAgeable);
                  }
                  }
                  

                  Si vous souhaitez me faire un don, il vous suffit de cliquer sur le bouton situé en dessous.

                  Je suis un membre apprécié et joueur, j'ai déjà obtenu 17 points de réputation.

                  1 réponse Dernière réponse Répondre Citer 0
                  • elias54E Hors-ligne
                    elias54 Administrateurs
                    dernière édition par

                    Détaille-moi ton problème.

                    Mon site | GitHub

                    1 réponse Dernière réponse Répondre Citer 0
                    • Superloup10S Hors-ligne
                      Superloup10 Modérateurs
                      dernière édition par

                      Tout simplement mon mob ne détruit pas les blocs, même lorsqu’il me target après avoir reçus un dégât.

                      Au passage, le mob n’est pas dirigeable actuellement.

                      Si vous souhaitez me faire un don, il vous suffit de cliquer sur le bouton situé en dessous.

                      Je suis un membre apprécié et joueur, j'ai déjà obtenu 17 points de réputation.

                      1 réponse Dernière réponse Répondre Citer 0
                      • elias54E Hors-ligne
                        elias54 Administrateurs
                        dernière édition par

                        C’est simple, tu as mis le système de destruction de blocks dans onLivingUpdate()… Le jeu risquerai de laguer… Car il va tenter 60 fois par seconde de casser un block… (une class est lue 60 fois par secondes en Java) Mets le code dans une méthode approprié comme :

                        
                        public void onUpdate()
                        {
                        super.onUpdate();
                        }
                        
                        

                        ou :

                        
                        public void updateEntityActionState()
                        {
                        super.updateEntityActionState();
                        }
                        
                        

                        Mon site | GitHub

                        1 réponse Dernière réponse Répondre Citer 0
                        • Superloup10S Hors-ligne
                          Superloup10 Modérateurs
                          dernière édition par

                          Voici la class du mob tel quel est actuellement:

                          package ere_geologique.common.entity;
                          
                          import java.util.List;
                          
                          import cpw.mods.fml.client.FMLClientHandler;
                          
                          import net.minecraft.block.Block;
                          import net.minecraft.entity.Entity;
                          import net.minecraft.entity.EntityAgeable;
                          import net.minecraft.entity.SharedMonsterAttributes;
                          import net.minecraft.entity.monster.EntityMob;
                          import net.minecraft.entity.player.EntityPlayer;
                          import net.minecraft.item.ItemStack;
                          import net.minecraft.util.DamageSource;
                          import net.minecraft.util.MathHelper;
                          import net.minecraft.world.World;
                          import ere_geologique.common.block.EGBlockList;
                          
                          public class Triceratops extends EntityMob
                          {
                          private int angerLevel;
                          private int randomSoundDelay;
                          
                          public Triceratops(World world)
                          {
                          super(world);
                          this.setSize(1.0F, 1.0F);
                          }
                          
                          protected void applyEntityAttributes()
                          {
                          super.applyEntityAttributes();
                          this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setAttribute(40D);
                          this.getEntityAttribute(SharedMonsterAttributes.followRange).setAttribute(40.0D);
                          this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setAttribute(0.69);
                          this.getEntityAttribute(SharedMonsterAttributes.attackDamage).setAttribute(10.0D);
                          }
                          
                          public void updateEntityActionState()
                          {
                          super.updateEntityActionState();
                          
                          int i = MathHelper.floor_double(this.posX);
                          int j = MathHelper.floor_double(this.posZ);
                          for (i = 0; i < 4; ++i)
                          {
                          j = MathHelper.floor_double(this.posX + (double)((float)(i % 2 * 2 - 1) * 0.25F));
                          int k = MathHelper.floor_double(this.posY);
                          int l = MathHelper.floor_double(this.posZ + (double)((float)(i / 2 % 2 * 2 - 1) * 0.25F));
                          this.worldObj.setBlockToAir(j, k, l);
                          // Block block;
                          
                          // block = Block.grass;
                          
                          // FMLClientHandler.instance().getClient().effectRenderer.addBlockDestroyEffects(j, k, l, block.blockID & 0xff, Block.stone.blockID >> 8 & 0xff);
                          // FMLClientHandler.instance().getClient().sndManager.playSound(block.stepSound.getBreakSound(), (float)posX+ 0.5F, (float)posY + 0.5F, (float)posZ + 0.5F, (block.stepSound.getVolume() + 1.0F) / 2.0F, block.stepSound.getPitch() * 0.8F);
                          }
                          }
                          
                          public boolean interact(EntityPlayer player)
                          {
                          player.mountEntity(this);
                          return true;
                          }
                          
                          protected Entity findPlayerToAttack()
                          {
                          return this.angerLevel == 0 ? null : super.findPlayerToAttack();
                          }
                          
                          public boolean attackEntityFrom(DamageSource par1DamageSource, float par2)
                          {
                          if (this.isEntityInvulnerable())
                          {
                          return false;
                          }
                          else
                          {
                          Entity entity = par1DamageSource.getEntity();
                          
                          if (entity instanceof EntityPlayer)
                          {
                          List list = this.worldObj.getEntitiesWithinAABBExcludingEntity(this, this.boundingBox.expand(32.0D, 32.0D, 32.0D));
                          
                          for (int i = 0; i < list.size(); ++i)
                          {
                          Entity entity1 = (Entity)list.get(i);
                          
                          if (entity1 instanceof Triceratops)
                          {
                          Triceratops triceratops = (Triceratops)entity1;
                          triceratops.becomeAngryAt(entity);
                          }
                          }
                          
                          this.becomeAngryAt(entity);
                          }
                          
                          return super.attackEntityFrom(par1DamageSource, par2);
                          }
                          }
                          
                          private void becomeAngryAt(Entity par1Entity)
                          {
                          this.entityToAttack = par1Entity;
                          this.angerLevel = 400 + this.rand.nextInt(400);
                          this.randomSoundDelay = this.rand.nextInt(40);
                          }
                          
                          public Triceratops spawnBabyAnimal(EntityAgeable entityageable)
                          {
                          return new Triceratops(this.worldObj);
                          }
                          
                          public boolean isBreedingItem(ItemStack itemstack)
                          {
                          return itemstack != null && itemstack.itemID == EGBlockList.Sapling.blockID;
                          }
                          
                          public Triceratops createChild(EntityAgeable par1EntityAgeable)
                          {
                          return this.spawnBabyAnimal(par1EntityAgeable);
                          }
                          }
                          

                          J’ai beau avoir changé le onLivingUpdate, ça ne change rien pour le mob, il ne détruit toujours pas les blocs.

                          Et il ne peut pas être dirigé, non plus.

                          Si vous souhaitez me faire un don, il vous suffit de cliquer sur le bouton situé en dessous.

                          Je suis un membre apprécié et joueur, j'ai déjà obtenu 17 points de réputation.

                          1 réponse Dernière réponse Répondre Citer 0
                          • elias54E Hors-ligne
                            elias54 Administrateurs
                            dernière édition par

                            Dans ce cas je ne vois pas… Sinon, pour ça :
                            @‘Superloup10’:

                            Et il ne peut pas être dirigé, non plus.

                            C’est un peu + compliqué. Je compte faire un tuto prochainement. En ce moment nous sommes en préparation pour organiser le forum lors de la 1.7. (Et ainsi réfléchir sur différentes idées.)

                            Mon site | GitHub

                            1 réponse Dernière réponse Répondre Citer 0
                            • Superloup10S Hors-ligne
                              Superloup10 Modérateurs
                              dernière édition par

                              Ok, de mon coté, je vais refaire le model de mon mob, pour voir si ça change quelque chose, sinon, j’irais regarder du coté des ogres de MoCreatures.

                              Si vous souhaitez me faire un don, il vous suffit de cliquer sur le bouton situé en dessous.

                              Je suis un membre apprécié et joueur, j'ai déjà obtenu 17 points de réputation.

                              1 réponse Dernière réponse Répondre Citer 0
                              • jglrxavpokJ Hors-ligne
                                jglrxavpok Modérateurs
                                dernière édition par

                                “Car il va tenter 60 fois par seconde de casser un block… (une class est lue 60 fois par secondes en Java)” Ouah! Cette aberration!
                                C’est Minecraft qui va ESSAYER de passer par CETTE METHODE 60 fois par secondes.

                                Sinon, as-tu vérifié si les IA de Minecraft ne repassent pas par dessus les méthodes “update” ?

                                Modérateur sur MFF. 
                                Mon Github: http://github.com/jglrxavpok
                                Mon compte Steam si vous voulez jouer à CS:GO ou TF2 avec moi: https://steamcommunity.com/id/jglrxavpok/

                                1 réponse Dernière réponse Répondre Citer 0
                                • Superloup10S Hors-ligne
                                  Superloup10 Modérateurs
                                  dernière édition par

                                  J’ai pas mis d’IA de Minecraft dans mon mob, donc je doute que ça vienne de là.

                                  Si vous souhaitez me faire un don, il vous suffit de cliquer sur le bouton situé en dessous.

                                  Je suis un membre apprécié et joueur, j'ai déjà obtenu 17 points de réputation.

                                  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