예제 #1
0
  public BiomeMeta a(EnumCreatureType enumcreaturetype, int i, int j, int k) {
    List list = this.L().getMobsFor(enumcreaturetype, i, j, k);

    return list != null && !list.isEmpty()
        ? (BiomeMeta) WeightedRandom.a(this.random, (Collection) list)
        : null;
  }
예제 #2
0
  public static List b(Random random, ItemStack itemstack, int i) {
    Item item = itemstack.getItem();
    int j = item.c();

    if (j <= 0) {
      return null;
    } else {
      j /= 2;
      j = 1 + random.nextInt((j >> 1) + 1) + random.nextInt((j >> 1) + 1);
      int k = j + i;
      float f = (random.nextFloat() + random.nextFloat() - 1.0F) * 0.15F;
      int l = (int) ((float) k * (1.0F + f) + 0.5F);

      if (l < 1) {
        l = 1;
      }

      ArrayList arraylist = null;
      Map map = b(l, itemstack);

      if (map != null && !map.isEmpty()) {
        EnchantmentInstance enchantmentinstance =
            (EnchantmentInstance) WeightedRandom.a(random, map.values());

        if (enchantmentinstance != null) {
          arraylist = new ArrayList();
          arraylist.add(enchantmentinstance);

          for (int i1 = l; random.nextInt(50) <= i1; i1 >>= 1) {
            Iterator iterator = map.keySet().iterator();

            while (iterator.hasNext()) {
              Integer integer = (Integer) iterator.next();
              boolean flag = true;
              Iterator iterator1 = arraylist.iterator();

              while (true) {
                if (iterator1.hasNext()) {
                  EnchantmentInstance enchantmentinstance1 = (EnchantmentInstance) iterator1.next();

                  if (enchantmentinstance1.enchantment.a(Enchantment.byId[integer.intValue()])) {
                    continue;
                  }

                  flag = false;
                }

                if (!flag) {
                  iterator.remove();
                }
                break;
              }
            }

            if (!map.isEmpty()) {
              EnchantmentInstance enchantmentinstance2 =
                  (EnchantmentInstance) WeightedRandom.a(random, map.values());

              arraylist.add(enchantmentinstance2);
            }
          }
        }
      }

      return arraylist;
    }
  }