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

    Solved Problème de box key

    1.7.x
    1.7.10
    4
    8
    1128
    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.
    • leo01418
      leo01418 last edited by

      Bonjour a tous il a pas si longtemps j’avais posté un sujet pour la box key  
      le vola à propos ^^:
      http://www.minecraftforgefrance.fr/showthread.php?tid=3012
      il à pas si longtemps j’ai éssayé de rajouté des item dans le tableau sa marche sa mais un item sur je sais pas combiend j’ai pas d’item
      Voila mon code 
      :::

      import java.util.Random;
      import net.minecraft.item.ItemStack;
      
      import com.google.common.collect.Table;
      
      import cpw.mods.fml.relauncher.Side;
      import cpw.mods.fml.relauncher.SideOnly;
      import ed.enderdeath.mod.common.enderdeath;
      import net.minecraft.block.Block;
      import net.minecraft.block.material.Material;
      import net.minecraft.creativetab.CreativeTabs;
      import net.minecraft.enchantment.Enchantment;
      import net.minecraft.entity.player.EntityPlayer;
      import net.minecraft.init.Items;
      import net.minecraft.item.Item;
      import net.minecraft.item.ItemStack;
      import net.minecraft.util.EnumFacing;
      import net.minecraft.world.World;
      
      public class BoxKey extends Block
      {
      
      private Item[] Tableau;
      
      public BoxKey() {
      super(Material.rock);
      this.setBlockTextureName(enderdeath.MODID + ":EnderBox");
      this.setBlockName("BoxKey");
      this.setCreativeTab(CreativeTabs.tabBlock);
      }
      
      public boolean onBlockActivated(World p_149727_1_, int p_149727_2_, int p_149727_3_, int p_149727_4_, EntityPlayer p_149727_5_, int p_149727_6_, float p_149727_7_, float p_149727_8_, float p_149727_9_)
        {
      /*Quand tu click droit avec l'item en question*/
      if(p_149727_5_.getHeldItem() != null && p_149727_5_.getHeldItem().getItem() == enderdeath.DeathKey) {
      
      /*Le Random + le tableau*/
                     Random rand = new Random();
                     p_149727_5_.inventory.decrStackSize(p_149727_5_.inventory.currentItem, 1);
                     ItemStack[] prices = new ItemStack[]{new ItemStack(enderdeath.DarkaniteBoots), new ItemStack(enderdeath.DarkaniteHelmet), new ItemStack(enderdeath.DarkaniteChestplate), new ItemStack(enderdeath.DarkaniteLeggings), new ItemStack(enderdeath.GreatNuggetEnderite), new ItemStack(enderdeath.BowGreetWood),new ItemStack(enderdeath.SwordDarkanite),new ItemStack(enderdeath.ObsiRenforced,50),new ItemStack(enderdeath.BaieOfRainbow,3),new ItemStack(enderdeath.BaieCake,25),new ItemStack(enderdeath.SwordRoyalite), new ItemStack(enderdeath.AntiAFK,64), new ItemStack(enderdeath.SwordRobber)};
                     {
                      prices[0].addEnchantment(Enchantment.protection, 4);
                      prices[0].addEnchantment(Enchantment.unbreaking, 3);
                      prices[1].addEnchantment(Enchantment.protection, 4);
                      prices[1].addEnchantment(Enchantment.unbreaking, 3);
                      prices[2].addEnchantment(Enchantment.protection, 4);
                      prices[2].addEnchantment(Enchantment.unbreaking, 3);
                      prices[3].addEnchantment(Enchantment.protection, 4);
                      prices[3].addEnchantment(Enchantment.unbreaking, 3);
                      prices[5].addEnchantment(Enchantment.power, 4);
                      prices[5].addEnchantment(Enchantment.infinity, 1);
                      prices[6].addEnchantment(Enchantment.sharpness, 4);
                      prices[6].addEnchantment(Enchantment.fireAspect, 1);
                      prices[10].addEnchantment(Enchantment.sharpness, 4);
                      prices[10].addEnchantment(Enchantment.knockback, 2);
                        prices[12].addEnchantment(Enchantment.sharpness, 5);
                     }
                     ItemStack price = prices[rand.nextInt(prices.length)]; 
                     p_149727_5_.inventory.addItemStackToInventory(price);
         }
            return true;
        }
      
      /*Pour des particule*/
      @SideOnly(Side.CLIENT)
          public void randomDisplayTick(World p_149734_1_, int p_149734_2_, int p_149734_3_, int p_149734_4_, Random p_149734_5_)
          {
              for (int l = 0; l < 5; ++l)
              {
                  double d6 = (double)((float)p_149734_2_ + p_149734_5_.nextFloat());
                  double d1 = (double)((float)p_149734_3_ + p_149734_5_.nextFloat());
                  d6 = (double)((float)p_149734_4_ + p_149734_5_.nextFloat());
                  double d3 = 0.0D;
                  double d4 = 0.0D;
                  double d5 = 0.0D;
                  int i1 = p_149734_5_.nextInt(2) * 2 - 1;
                  int j1 = p_149734_5_.nextInt(2) * 2 - 1;
                  d3 = ((double)p_149734_5_.nextFloat() - 0.5D) * 0.2D;
                  d4 = ((double)p_149734_5_.nextFloat() - 0.5D) * 0.2D;
                  d5 = ((double)p_149734_5_.nextFloat() - 0.5D) * 0.2D;
                  double d2 = (double)p_149734_4_ + 0.5D + 0.25D * (double)j1;
                  d5 = (double)(p_149734_5_.nextFloat() * 1.0F * (float)j1);
                  double d0 = (double)p_149734_2_ + 0.5D + 0.25D * (double)i1;
                  d3 = (double)(p_149734_5_.nextFloat() * 1.0F * (float)i1);
                  p_149734_1_.spawnParticle("portal", d0, d1, d2, d3, d4, d5);
              }
          }
      }
      

      :::

      Voila ma signature

      1 Reply Last reply Reply Quote 0
      • robin4002
        robin4002 Moddeurs confirmés Rédacteurs Administrateurs last edited by

        Salut,
        Il faut s’exprimer plus clairement car là je n’ai rien comprit …

        1 Reply Last reply Reply Quote 0
        • leo01418
          leo01418 last edited by

          Excuse 
          Au faite ce qui ce passe c’est que quand je fait click droit avec la key sa me donne  les item aléatoirement mais des fois sa ne me donne aucun item

          Voila ma signature

          1 Reply Last reply Reply Quote 0
          • robin4002
            robin4002 Moddeurs confirmés Rédacteurs Administrateurs last edited by

            Étrange, pourtant ça ne devrait pas  :s

            1 Reply Last reply Reply Quote 0
            • Deleted
              Deleted last edited by

              Print la variable price pour vérifier à chaque interaction ce qu’elle te donne et donc analyser les cas où rien n’est droppé.
              Essaie aussi de mettre ton code uniquement côté server. Je ne sais pas si ça peut faire quelque chose, mais ça ne te coûte rien de le faire…

              1 Reply Last reply Reply Quote 0
              • leo01418
                leo01418 last edited by

                Je vais essaye du côté serveur sinon j’ai sytem out le price et quand sa me fait un item vide sa le compte comme si sa donné un item

                Voila ma signature

                1 Reply Last reply Reply Quote 0
                • AymericRed
                  AymericRed last edited by

                  Je pense que ça doit étre un problème que j’avais déjà eu, le stack de ton array peut-être le mémé que celui de ton inventaire et si tu le détruire ça détruira aussi celui de larray donc il faut que tu mettes price = lestaxkdetonarray.copy()

                  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 Reply Last reply Reply Quote 0
                  • leo01418
                    leo01418 last edited by

                    Réglé Merci beaucoup

                    Voila ma signature

                    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