• Register
    • Login
    • Search
    • Recent
    • Tags
    • Popular
    • Users
    • Groups

    Solved Mob qui loot plusieurs items avec chance random

    1.7.x
    1.7.10
    2
    3
    737
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • P
      PlayFlop_ last edited by

      Bonjour, 
      Tout est dans le titre,
      Je n’arrive pas a faire un random loot avec un certain pour-cent de chance.

      Code de mon entité:

      package fr.playflop.legitium.common.entity;
      
      import fr.playflop.legitium.common.item.ItemRegistry;
      import net.minecraft.entity.SharedMonsterAttributes;
      import net.minecraft.entity.monster.EntityMob;
      import net.minecraft.item.Item;
      import net.minecraft.world.World;
      
      public class EntityRaka extends EntityMob
      {
      public EntityRaka(World world)
      {
      super(world);
      }
      public void applyEntityAttributes()
      {
      super.applyEntityAttributes();
      this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(5D);
      this.getEntityAttribute(SharedMonsterAttributes.attackDamage).setBaseValue(6D);
      this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(0.8D);
      
      }
      public Item getDropItem()
      {
      return Items.leather;
      }
      }
      
      1 Reply Last reply Reply Quote 0
      • Dylem
        Dylem last edited by

        Voilà comment le squelette fait pour drop des os et des flèches :

        
        @Override
           protected void dropFewItems(boolean p_70628_1_, int p_70628_2_)
           {
               int j;
               int k;
        
               j = this.rand.nextInt(3 + p_70628_2_);
        
               for (k = 0; k < j; ++k)
               {
                   this.dropItem(Items.arrow, 1);
               }
        
               j = this.rand.nextInt(3 + p_70628_2_);
        
               for (k = 0; k < j; ++k)
               {
                   this.dropItem(Items.bone, 1);
               }
           }
        
        

        Si tu as d’autres questions, n’hésite pas.

        Edit : Juste pour préciser, le j = this.rand.nextInt(3 + p_70628_2_); correspond aux chances de drop aléatoires entre 0 et (3 + p_70628_2_), donc 2 drops si j = 2. La valeur de p_70628_2_ correspond au looting sur l’arme utilisée. Donc si tu veux entre 0 et 5 drops par exemple, tu remplaces 3 par 5 tout simplement.

        Si je t'ai aidé, n'hésite pas à cliquer sur le nombre vert en dessous de mon image de profil, pour me le faire savoir. Ca me motive pour continuer …

        1 Reply Last reply Reply Quote 1
        • P
          PlayFlop_ last edited by

          @‘Dylem’:

          Voilà comment le squelette fait pour drop des os et des flèches :

          
          @Override
             protected void dropFewItems(boolean p_70628_1_, int p_70628_2_)
             {
                 int j;
                 int k;
          
                 j = this.rand.nextInt(3 + p_70628_2_);
          
                 for (k = 0; k < j; ++k)
                 {
                     this.dropItem(Items.arrow, 1);
                 }
          
                 j = this.rand.nextInt(3 + p_70628_2_);
          
                 for (k = 0; k < j; ++k)
                 {
                     this.dropItem(Items.bone, 1);
                 }
             }
          
          

          Si tu as d’autres questions, n’hésite pas.

          Edit : Juste pour préciser, le j = this.rand.nextInt(3 + p_70628_2_); correspond aux chances de drop aléatoires entre 0 et (3 + p_70628_2_), donc 2 drops si j = 2. La valeur de p_70628_2_ correspond au looting sur l’arme utilisée. Donc si tu veux entre 0 et 5 drops par exemple, tu remplaces 3 par 5 tout simplement.

          Merci beaucoup, je teste ça mais je pense que c’est bien ce dont j’avais besoin ❤

          1 Reply Last reply Reply Quote 0
          • 1 / 1
          • First post
            Last post
          Design by Woryk
          Contact / Mentions Légales

          MINECRAFT FORGE FRANCE © 2018

          Powered by NodeBB