public static void func_76294_a(
     Random p_76294_0_,
     WeightedRandomChestContent[] p_76294_1_,
     TileEntityDispenser p_76294_2_,
     int p_76294_3_) {
   for (int var4 = 0; var4 < p_76294_3_; ++var4) {
     WeightedRandomChestContent var5 =
         (WeightedRandomChestContent) WeightedRandom.func_76274_a(p_76294_0_, p_76294_1_);
     int var6 =
         var5.field_76295_d + p_76294_0_.nextInt(var5.field_76296_e - var5.field_76295_d + 1);
     if (Item.field_77698_e[var5.field_76297_b].func_77639_j() >= var6) {
       p_76294_2_.func_70299_a(
           p_76294_0_.nextInt(p_76294_2_.func_70302_i_()),
           new ItemStack(var5.field_76297_b, var6, var5.field_76298_c));
     } else {
       for (int var7 = 0; var7 < var6; ++var7) {
         p_76294_2_.func_70299_a(
             p_76294_0_.nextInt(p_76294_2_.func_70302_i_()),
             new ItemStack(var5.field_76297_b, 1, var5.field_76298_c));
       }
     }
   }
 }
예제 #2
0
  public static List func_77513_b(Random p_77513_0_, ItemStack p_77513_1_, int p_77513_2_) {
    Item var3 = p_77513_1_.func_77973_b();
    int var4 = var3.func_77619_b();
    if (var4 <= 0) {
      return null;
    } else {
      var4 /= 2;
      var4 = 1 + p_77513_0_.nextInt((var4 >> 1) + 1) + p_77513_0_.nextInt((var4 >> 1) + 1);
      int var5 = var4 + p_77513_2_;
      float var6 = (p_77513_0_.nextFloat() + p_77513_0_.nextFloat() - 1.0F) * 0.15F;
      int var7 = (int) ((float) var5 * (1.0F + var6) + 0.5F);
      if (var7 < 1) {
        var7 = 1;
      }

      ArrayList var8 = null;
      Map var9 = func_77505_b(var7, p_77513_1_);
      if (var9 != null && !var9.isEmpty()) {
        EnchantmentData var10 =
            (EnchantmentData) WeightedRandom.func_76271_a(p_77513_0_, var9.values());
        if (var10 != null) {
          var8 = new ArrayList();
          var8.add(var10);

          for (int var11 = var7; p_77513_0_.nextInt(50) <= var11; var11 >>= 1) {
            Iterator var12 = var9.keySet().iterator();

            while (var12.hasNext()) {
              Integer var13 = (Integer) var12.next();
              boolean var14 = true;
              Iterator var15 = var8.iterator();

              while (true) {
                if (var15.hasNext()) {
                  EnchantmentData var16 = (EnchantmentData) var15.next();
                  if (var16.field_76302_b.func_77326_a(
                      Enchantment.field_77331_b[var13.intValue()])) {
                    continue;
                  }

                  var14 = false;
                }

                if (!var14) {
                  var12.remove();
                }
                break;
              }
            }

            if (!var9.isEmpty()) {
              EnchantmentData var17 =
                  (EnchantmentData) WeightedRandom.func_76271_a(p_77513_0_, var9.values());
              var8.add(var17);
            }
          }
        }
      }

      return var8;
    }
  }