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

    Résolu Message dans le chat

    1.7.x
    1.7.2
    2
    3
    1171
    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.
    • Nolan-XX
      Nolan-XX dernière édition par robin4002

      J’avais déjà fait autrefois un sujet la dessus, ici : http://www.minecraftforgefrance.fr/showthread.php?tid=215, le problème est qu’il ne marche plus en 1.7.2.

      Erreur : The method addChatMessage(IChatComponent) in the type ICommandSender is not applicable for the arguments (String)
      Code :

      package fr.nolancraft.onche.Mobs;
      
      import java.util.List;
      
      import net.minecraft.entity.Entity;
      import net.minecraft.entity.SharedMonsterAttributes;
      import net.minecraft.entity.player.EntityPlayer;
      import net.minecraft.item.Item;
      import net.minecraft.util.DamageSource;
      import net.minecraft.world.World;
      import fr.nolancraft.onche.Data.Main;
      
      public class EntityHap extends EntityHapAgro
      {
      
          private String[] messageArray = new String[] { "première phrase", "seconde phrase", "troisième phrase", "etc …" };
      
          @SuppressWarnings("unused")
          private int angerLevel;
          @SuppressWarnings("unused")
          private int randomSoundDelay;
      
          public EntityHap(World world)
          {
              super(world);
          }
      
          public void applyEntityAttributes()
          {
              super.applyEntityAttributes();
              this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(20D);
              this.getEntityAttribute(SharedMonsterAttributes.attackDamage).setBaseValue(3D);
          }
      
          public Item getDropItem()
          {
              return Main.Hap;
          }
      
          protected void dropFewItems(boolean par1, int par2)
          {
              int j = this.rand.nextInt(2 + par2);
              int k;
      
              for (k = 0; k < j; ++k)
              {
                  this.dropItem(Main.Hap, 1);
              }
          }
      
          protected void dropRareDrop(int par1)
          {
              this.dropItem(Main.cisla, 1);
          }
      
      protected void addRandomArmor()
      {
      this.setCurrentItemOrArmor(0, null);
      }
      
      public boolean attackEntityFrom(DamageSource par1DamageSource, float par2)
      {
      if (this.isEntityInvulnerable())
      {
      return false;
      } else
      {
      Entity entity = par1DamageSource.getEntity();
      
      if (entity instanceof EntityPlayer)
      {
      @SuppressWarnings("rawtypes")
      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 EntityHap)
      {
      EntityHap entityHap = (EntityHap) entity1;
      entityHap.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 boolean interact(EntityPlayer player)
      {
      if (!this.worldObj.isRemote)
      {
      player.addChatMessage(this.messageArray[this.worldObj.rand.nextInt(this.messageArray.length)]);
      return true;
      }
      return false;
      }
      
      }
      

      Merci d’avance.

      1 réponse Dernière réponse Répondre Citer 0
      • robin4002
        robin4002 Moddeurs confirmés Rédacteurs Administrateurs dernière édition par

        player.addChatMessage(new ChatComponentText(this.messageArray[this.worldObj.rand.nextInt(this.messageArray.length)]));

        1 réponse Dernière réponse Répondre Citer 1
        • Nolan-XX
          Nolan-XX dernière édition par

          Merci a toi, ça marche.

          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