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));
  }
Beispiel #2
0
 public void #FIELD_CONTAINERANVIL_4#()
 {
     ItemStack itemstack = VAnvil.#FIELD_CONTAINERANVIL_1#(this).getItem(0);
     #FIELD_CONTAINERANVIL_5# = 0;
     int i = 0;
     byte b0 = 0;
     int j = 0;
     if(itemstack == null)
     {
         getInv("#FIELD_CONTAINERANVIL_2#").setItem(0, null);
         #FIELD_CONTAINERANVIL_5# = 0;
     }
     else
     {
         ItemStack itemstack1 = itemstack.cloneItemStack();
         ItemStack itemstack2 = VAnvil.#FIELD_CONTAINERANVIL_1#(this).getItem(1);
         Map map = EnchantmentManager.#FIELD_ENCHANTMENTMANAGER_3#(itemstack1);
         boolean flag = false;
         int k = b0 + itemstack.getRepairCost() + (itemstack2 == null ? 0 : itemstack2.getRepairCost());
         _exp = 0;
         int l;
         int i1;
         int j1;
         int k1;
         int l1;
         Iterator iterator;
         Enchantment enchantment;
         if(itemstack2 != null)
         {
             flag = itemstack2.id == Item.ENCHANTED_BOOK.id && Item.ENCHANTED_BOOK.#FIELD_ITEMENCHANTEDBOOK_2#(itemstack2).size() > 0;
             if(itemstack1.#FIELD_ITEM_6#() && Item.byId[itemstack1.id].a(itemstack, itemstack2))
             {
                 l = Math.min(itemstack1.#FIELD_ITEMSTACK_5#(), itemstack1.#FIELD_ITEMSTACK_6#() / 4);
                 if(l <= 0)
                 {
                     getInv("#FIELD_CONTAINERANVIL_2#").setItem(0, null);
                     #FIELD_CONTAINERANVIL_5# = 0;
                     return;
                 }
                 for(i1 = 0; l > 0 && i1 < itemstack2.count; ++i1)
                 {
                     j1 = itemstack1.#FIELD_ITEMSTACK_5#() - l;
                     itemstack1.setData(j1);
                     i += Math.max(1, l / 100) + map.size();
                     l = Math.min(itemstack1.#FIELD_ITEMSTACK_5#(), itemstack1.#FIELD_ITEMSTACK_6#() / 4);
                 }
                 _exp = i1;
             }
             else
             {
                 if(!flag && (itemstack1.id != itemstack2.id || !itemstack1.#FIELD_ITEM_6#()))
                 {
                     getInv("#FIELD_CONTAINERANVIL_2#").setItem(0, null);
                     #FIELD_CONTAINERANVIL_5# = 0;
                     return;
                 }
                 if(itemstack1.#FIELD_ITEM_6#() && !flag)
                 {
                     l = itemstack.#FIELD_ITEMSTACK_6#() - itemstack.#FIELD_ITEMSTACK_5#();
                     i1 = itemstack2.#FIELD_ITEMSTACK_6#() - itemstack2.#FIELD_ITEMSTACK_5#();
                     j1 = i1 + itemstack1.#FIELD_ITEMSTACK_6#() * 12 / 100;
                     int i2 = l + j1;
                     k1 = itemstack1.#FIELD_ITEMSTACK_6#() - i2;
                     if(k1 < 0)
                     {
                         k1 = 0;
                     }
                     if(k1 < itemstack1.getData())
                     {
                         itemstack1.setData(k1);
                         i += Math.max(1, j1 / 100);
                     }
                 }
                 Map map1 = EnchantmentManager.#FIELD_ENCHANTMENTMANAGER_3#(itemstack2);
                 iterator = map1.keySet().iterator();
                 while(iterator.hasNext())
                 {
                     j1 = ((Integer)iterator.next()).intValue();
                     enchantment = Enchantment.byId[j1];
                     k1 = map.containsKey(Integer.valueOf(j1)) ? ((Integer)map.get(Integer.valueOf(j1))).intValue() : 0;
                     l1 = ((Integer)map1.get(Integer.valueOf(j1))).intValue();
                     int j2;
                     if(k1 == l1)
                     {
                         ++l1;
                         j2 = l1;
                     }
                     else
                     {
                         j2 = Math.max(l1, k1);
                     }
                     l1 = j2;
                     int k2 = l1 - k1;
                     boolean flag1 = enchantment.canEnchant(itemstack);
                     if(playerFree(_player))
                     {
                         flag1 = true;
                     }
                     Iterator iterator1 = map.keySet().iterator();
                     while(iterator1.hasNext())
                     {
                         int l2 = ((Integer)iterator1.next()).intValue();
                         if(l2 != j1 && !enchantment.#FIELD_ENCHANTMENT_1#(Enchantment.byId[l2]))
                         {
                             flag1 = false;
                             i += k2;
                         }
                     }
                     if(flag1)
                     {
                         if(l1 > enchantment.getMaxLevel())
                         {
                             l1 = enchantment.getMaxLevel();
                         }
                         map.put(Integer.valueOf(j1), Integer.valueOf(l1));
                         int i3 = 0;
                         switch(enchantment.getRandomWeight())
                         {
                             case 1:
                                 i3 = 8;
                                 break;
                             case 2:
                                 i3 = 4;
                             case 3:
                             case 4:
                             case 6:
                             case 7:
                             case 8:
                             case 9:
                             default:
                                 break;
                             case 5:
                                 i3 = 2;
                                 break;
                             case 10:
                                 i3 = 1;
                         }
                         i += i3 * k2;
                     }
                 }
             }
         }
         if(_itemName != null && !_itemName.equalsIgnoreCase(itemstack.#FIELD_ITEMSTACK_7#()) && _itemName.length() > 0)
         {
             j = itemstack.#FIELD_ITEM_6#() ? 7 : itemstack.count * 5;
             i += j;
             if(itemstack.#FIELD_ITEMSTACK_8#())
             {
                 k += j / 2;
             }
             itemstack1.#FIELD_ITEMSTACK_9#(_itemName);
         }
         l = 0;
         for(iterator = map.keySet().iterator(); iterator.hasNext(); k += l + k1 * l1)
         {
             j1 = ((Integer)iterator.next()).intValue();
             enchantment = Enchantment.byId[j1];
             k1 = ((Integer)map.get(Integer.valueOf(j1))).intValue();
             l1 = 0;
             ++l;
             switch(enchantment.getRandomWeight())
             {
                 case 1:
                     l1 = 8;
                     break;
                 case 2:
                     l1 = 4;
                 case 3:
                 case 4:
                 case 6:
                 case 7:
                 case 8:
                 case 9:
                 default:
                     break;
                 case 5:
                     l1 = 2;
                     break;
                 case 10:
                     l1 = 1;
             }
             if(flag)
             {
                 l1 = Math.max(1, l1 / 2);
             }
         }
         if(flag)
         {
             k = Math.max(1, k / 2);
         }
         #FIELD_CONTAINERANVIL_5# = k + i;
         if(i <= 0)
         {
             itemstack1 = null;
         }
         if(j == i && j > 0 && #FIELD_CONTAINERANVIL_5# >= 40)
         {
             #FIELD_CONTAINERANVIL_5# = 39;
         }
         if(#FIELD_CONTAINERANVIL_5# >= 40 && !playerFree(_player))
         {
             itemstack1 = null;
         }
         if(itemstack1 != null)
         {
             i1 = itemstack1.getRepairCost();
             if(itemstack2 != null && i1 < itemstack2.getRepairCost())
             {
                 i1 = itemstack2.getRepairCost();
             }
             if(itemstack1.#FIELD_ITEMSTACK_8#())
             {
                 i1 -= 9;
             }
             if(i1 < 0)
             {
                 i1 = 0;
             }
             i1 += 2;
             itemstack1.setRepairCost(i1);
             EnchantmentManager.#FIELD_ENCHANTMENTMANAGER_4#(map, itemstack1);
         }
         getInv("#FIELD_CONTAINERANVIL_2#").setItem(0, itemstack1);
         #FIELD_CONTAINER_9#();
     }
 }