コード例 #1
0
 private static void b(MerchantRecipeList merchantrecipelist, Item item, Random random, float f) {
   if (random.nextFloat() < f) {
     int k = c(item, random);
     ItemStack itemstack;
     ItemStack itemstack1;
     if (k < 0) {
       itemstack = new ItemStack(Items.EMERALD, 1, 0);
       itemstack1 = new ItemStack(item, -k, 0);
     } else {
       itemstack = new ItemStack(Items.EMERALD, k, 0);
       itemstack1 = new ItemStack(item, 1, 0);
     }
     merchantrecipelist.add(new MerchantRecipe(itemstack, itemstack1));
   }
 }
コード例 #2
0
 private static void a(MerchantRecipeList merchantrecipelist, Item item, Random random, float f) {
   if (random.nextFloat() < f)
     merchantrecipelist.add(new MerchantRecipe(a(item, random), Items.EMERALD));
 }
コード例 #3
0
  private void t(int k) {
    if (bu != null) bA = MathHelper.c(bu.size()) * 0.2F;
    else bA = 0.0F;
    MerchantRecipeList merchantrecipelist = new MerchantRecipeList();
    switch (getProfession()) {
      case 0: // '\0'
        a(merchantrecipelist, Items.WHEAT, random, p(0.9F));
        a(merchantrecipelist, Item.getItemOf(Blocks.WOOL), random, p(0.5F));
        a(merchantrecipelist, Items.RAW_CHICKEN, random, p(0.5F));
        a(merchantrecipelist, Items.COOKED_FISH, random, p(0.4F));
        b(merchantrecipelist, Items.BREAD, random, p(0.9F));
        b(merchantrecipelist, Items.MELON, random, p(0.3F));
        b(merchantrecipelist, Items.APPLE, random, p(0.3F));
        b(merchantrecipelist, Items.COOKIE, random, p(0.3F));
        b(merchantrecipelist, Items.SHEARS, random, p(0.3F));
        b(merchantrecipelist, Items.FLINT_AND_STEEL, random, p(0.3F));
        b(merchantrecipelist, Items.COOKED_CHICKEN, random, p(0.3F));
        b(merchantrecipelist, Items.ARROW, random, p(0.5F));
        if (random.nextFloat() < p(0.5F))
          merchantrecipelist.add(
              new MerchantRecipe(
                  new ItemStack(Blocks.GRAVEL, 10),
                  new ItemStack(Items.EMERALD),
                  new ItemStack(Items.FLINT, 4 + random.nextInt(2), 0)));
        break;

      case 4: // '\004'
        a(merchantrecipelist, Items.COAL, random, p(0.7F));
        a(merchantrecipelist, Items.PORK, random, p(0.5F));
        a(merchantrecipelist, Items.RAW_BEEF, random, p(0.5F));
        b(merchantrecipelist, Items.SADDLE, random, p(0.1F));
        b(merchantrecipelist, Items.LEATHER_CHESTPLATE, random, p(0.3F));
        b(merchantrecipelist, Items.LEATHER_BOOTS, random, p(0.3F));
        b(merchantrecipelist, Items.LEATHER_HELMET, random, p(0.3F));
        b(merchantrecipelist, Items.LEATHER_LEGGINGS, random, p(0.3F));
        b(merchantrecipelist, Items.GRILLED_PORK, random, p(0.3F));
        b(merchantrecipelist, Items.COOKED_BEEF, random, p(0.3F));
        break;

      case 3: // '\003'
        a(merchantrecipelist, Items.COAL, random, p(0.7F));
        a(merchantrecipelist, Items.IRON_INGOT, random, p(0.5F));
        a(merchantrecipelist, Items.GOLD_INGOT, random, p(0.5F));
        a(merchantrecipelist, Items.DIAMOND, random, p(0.5F));
        b(merchantrecipelist, Items.IRON_SWORD, random, p(0.5F));
        b(merchantrecipelist, Items.DIAMOND_SWORD, random, p(0.5F));
        b(merchantrecipelist, Items.IRON_AXE, random, p(0.3F));
        b(merchantrecipelist, Items.DIAMOND_AXE, random, p(0.3F));
        b(merchantrecipelist, Items.IRON_PICKAXE, random, p(0.5F));
        b(merchantrecipelist, Items.DIAMOND_PICKAXE, random, p(0.5F));
        b(merchantrecipelist, Items.IRON_SPADE, random, p(0.2F));
        b(merchantrecipelist, Items.DIAMOND_SPADE, random, p(0.2F));
        b(merchantrecipelist, Items.IRON_HOE, random, p(0.2F));
        b(merchantrecipelist, Items.DIAMOND_HOE, random, p(0.2F));
        b(merchantrecipelist, Items.IRON_BOOTS, random, p(0.2F));
        b(merchantrecipelist, Items.DIAMOND_BOOTS, random, p(0.2F));
        b(merchantrecipelist, Items.IRON_HELMET, random, p(0.2F));
        b(merchantrecipelist, Items.DIAMOND_HELMET, random, p(0.2F));
        b(merchantrecipelist, Items.IRON_CHESTPLATE, random, p(0.2F));
        b(merchantrecipelist, Items.DIAMOND_CHESTPLATE, random, p(0.2F));
        b(merchantrecipelist, Items.IRON_LEGGINGS, random, p(0.2F));
        b(merchantrecipelist, Items.DIAMOND_LEGGINGS, random, p(0.2F));
        b(merchantrecipelist, Items.CHAINMAIL_BOOTS, random, p(0.1F));
        b(merchantrecipelist, Items.CHAINMAIL_HELMET, random, p(0.1F));
        b(merchantrecipelist, Items.CHAINMAIL_CHESTPLATE, random, p(0.1F));
        b(merchantrecipelist, Items.CHAINMAIL_LEGGINGS, random, p(0.1F));
        break;

      case 1: // '\001'
        a(merchantrecipelist, Items.PAPER, random, p(0.8F));
        a(merchantrecipelist, Items.BOOK, random, p(0.8F));
        a(merchantrecipelist, Items.WRITTEN_BOOK, random, p(0.3F));
        b(merchantrecipelist, Item.getItemOf(Blocks.BOOKSHELF), random, p(0.8F));
        b(merchantrecipelist, Item.getItemOf(Blocks.GLASS), random, p(0.2F));
        b(merchantrecipelist, Items.COMPASS, random, p(0.2F));
        b(merchantrecipelist, Items.WATCH, random, p(0.2F));
        if (random.nextFloat() < p(0.07F)) {
          Enchantment enchantment = Enchantment.c[random.nextInt(Enchantment.c.length)];
          int i1 =
              MathHelper.nextInt(random, enchantment.getStartLevel(), enchantment.getMaxLevel());
          ItemStack itemstack = Items.ENCHANTED_BOOK.a(new EnchantmentInstance(enchantment, i1));
          int k1 = 2 + random.nextInt(5 + i1 * 10) + 3 * i1;
          merchantrecipelist.add(
              new MerchantRecipe(
                  new ItemStack(Items.BOOK), new ItemStack(Items.EMERALD, k1), itemstack));
        }
        break;

      case 2: // '\002'
        b(merchantrecipelist, Items.EYE_OF_ENDER, random, p(0.3F));
        b(merchantrecipelist, Items.EXP_BOTTLE, random, p(0.2F));
        b(merchantrecipelist, Items.REDSTONE, random, p(0.4F));
        b(merchantrecipelist, Item.getItemOf(Blocks.GLOWSTONE), random, p(0.3F));
        Item aitem[] = {
          Items.IRON_SWORD,
          Items.DIAMOND_SWORD,
          Items.IRON_CHESTPLATE,
          Items.DIAMOND_CHESTPLATE,
          Items.IRON_AXE,
          Items.DIAMOND_AXE,
          Items.IRON_PICKAXE,
          Items.DIAMOND_PICKAXE
        };
        Item aitem1[] = aitem;
        int j1 = aitem1.length;
        for (int l1 = 0; l1 < j1; l1++) {
          Item item = aitem1[l1];
          if (random.nextFloat() < p(0.05F))
            merchantrecipelist.add(
                new MerchantRecipe(
                    new ItemStack(item, 1, 0),
                    new ItemStack(Items.EMERALD, 2 + random.nextInt(3), 0),
                    EnchantmentManager.a(
                        random, new ItemStack(item, 1, 0), 5 + random.nextInt(15))));
        }

        break;
    }
    if (merchantrecipelist.isEmpty()) a(merchantrecipelist, Items.GOLD_INGOT, random, 1.0F);
    Collections.shuffle(merchantrecipelist);
    if (bu == null) bu = new MerchantRecipeList();
    for (int l = 0; l < k && l < merchantrecipelist.size(); l++)
      bu.a((MerchantRecipe) merchantrecipelist.get(l));
  }