Java 类net.minecraft.enchantment.EnchantmentData 实例源码

项目:Industrial-Foregoing    文件:EnchantmentExtractorTile.java   
@Override
protected float performWork() {
    if (WorkUtils.isDisabled(this.getBlockType())) return 0;

    if (!hasBooks() || getItem().isEmpty()) return 0;
    ItemStack enchantedItem = getItem();
    ItemStack enchantedBook = new ItemStack(Items.ENCHANTED_BOOK);
    if (ItemHandlerHelper.insertItem(outEnchanted, enchantedBook, true).isEmpty() && ItemHandlerHelper.insertItem(outItem, enchantedItem, true).isEmpty()) {
        NBTTagCompound base = (NBTTagCompound) enchantedItem.getEnchantmentTagList().get(0);
        ((ItemEnchantedBook) Items.ENCHANTED_BOOK).addEnchantment(enchantedBook, new EnchantmentData(Enchantment.getEnchantmentByID(base.getShort("id")), base.getShort("lvl")));
        enchantedItem.getEnchantmentTagList().removeTag(0);
        ItemHandlerHelper.insertItem(outEnchanted, enchantedBook, false);
        ItemHandlerHelper.insertItem(outItem, enchantedItem.copy(), false);
        inBook.getStackInSlot(0).setCount(inBook.getStackInSlot(0).getCount() - 1);
        enchantedItem.setCount(enchantedItem.getCount() - 1);
        return 500;
    }

    return 0;
}
项目:DecompiledMinecraft    文件:CreativeTabs.java   
/**
 * Adds the enchantment books from the supplied EnumEnchantmentType to the given list.
 */
public void addEnchantmentBooksToList(List<ItemStack> itemList, EnumEnchantmentType... enchantmentType)
{
    for (Enchantment enchantment : Enchantment.enchantmentsBookList)
    {
        if (enchantment != null && enchantment.type != null)
        {
            boolean flag = false;

            for (int i = 0; i < enchantmentType.length && !flag; ++i)
            {
                if (enchantment.type == enchantmentType[i])
                {
                    flag = true;
                }
            }

            if (flag)
            {
                itemList.add(Items.enchanted_book.getEnchantedItemStack(new EnchantmentData(enchantment, enchantment.getMaxLevel())));
            }
        }
    }
}
项目:BaseClient    文件:CreativeTabs.java   
/**
 * Adds the enchantment books from the supplied EnumEnchantmentType to the given list.
 */
public void addEnchantmentBooksToList(List<ItemStack> itemList, EnumEnchantmentType... enchantmentType)
{
    for (Enchantment enchantment : Enchantment.enchantmentsBookList)
    {
        if (enchantment != null && enchantment.type != null)
        {
            boolean flag = false;

            for (int i = 0; i < enchantmentType.length && !flag; ++i)
            {
                if (enchantment.type == enchantmentType[i])
                {
                    flag = true;
                }
            }

            if (flag)
            {
                itemList.add(Items.enchanted_book.getEnchantedItemStack(new EnchantmentData(enchantment, enchantment.getMaxLevel())));
            }
        }
    }
}
项目:BaseClient    文件:CreativeTabs.java   
/**
 * Adds the enchantment books from the supplied EnumEnchantmentType to the given list.
 */
public void addEnchantmentBooksToList(List<ItemStack> itemList, EnumEnchantmentType... enchantmentType)
{
    for (Enchantment enchantment : Enchantment.enchantmentsBookList)
    {
        if (enchantment != null && enchantment.type != null)
        {
            boolean flag = false;

            for (int i = 0; i < enchantmentType.length && !flag; ++i)
            {
                if (enchantment.type == enchantmentType[i])
                {
                    flag = true;
                }
            }

            if (flag)
            {
                itemList.add(Items.enchanted_book.getEnchantedItemStack(new EnchantmentData(enchantment, enchantment.getMaxLevel())));
            }
        }
    }
}
项目:Backmemed    文件:EntityVillager.java   
public void func_190888_a(IMerchant p_190888_1_, MerchantRecipeList p_190888_2_, Random p_190888_3_)
{
    Enchantment enchantment = (Enchantment)Enchantment.REGISTRY.getRandomObject(p_190888_3_);
    int i = MathHelper.getInt(p_190888_3_, enchantment.getMinLevel(), enchantment.getMaxLevel());
    ItemStack itemstack = Items.ENCHANTED_BOOK.getEnchantedItemStack(new EnchantmentData(enchantment, i));
    int j = 2 + p_190888_3_.nextInt(5 + i * 10) + 3 * i;

    if (enchantment.isTreasureEnchantment())
    {
        j *= 2;
    }

    if (j > 64)
    {
        j = 64;
    }

    p_190888_2_.add(new MerchantRecipe(new ItemStack(Items.BOOK), new ItemStack(Items.EMERALD, j), itemstack));
}
项目:Backmemed    文件:CreativeTabs.java   
/**
 * Adds the enchantment books from the supplied EnumEnchantmentType to the given list.
 */
public void addEnchantmentBooksToList(List<ItemStack> itemList, EnumEnchantmentType... enchantmentType)
{
    for (Enchantment enchantment : Enchantment.REGISTRY)
    {
        if (enchantment != null && enchantment.type != null)
        {
            boolean flag = false;

            for (int i = 0; i < enchantmentType.length && !flag; ++i)
            {
                if (enchantment.type == enchantmentType[i])
                {
                    flag = true;
                }
            }

            if (flag)
            {
                itemList.add(Items.ENCHANTED_BOOK.getEnchantedItemStack(new EnchantmentData(enchantment, enchantment.getMaxLevel())));
            }
        }
    }
}
项目:CustomWorldGen    文件:EntityVillager.java   
/**
 * Affects the given MerchantRecipeList to possibly add or remove MerchantRecipes.
 */
public void modifyMerchantRecipeList(MerchantRecipeList recipeList, Random random)
{
    Enchantment enchantment = (Enchantment)Enchantment.REGISTRY.getRandomObject(random);
    int i = MathHelper.getRandomIntegerInRange(random, enchantment.getMinLevel(), enchantment.getMaxLevel());
    ItemStack itemstack = Items.ENCHANTED_BOOK.getEnchantedItemStack(new EnchantmentData(enchantment, i));
    int j = 2 + random.nextInt(5 + i * 10) + 3 * i;

    if (enchantment.isTreasureEnchantment())
    {
        j *= 2;
    }

    if (j > 64)
    {
        j = 64;
    }

    recipeList.add(new MerchantRecipe(new ItemStack(Items.BOOK), new ItemStack(Items.EMERALD, j), itemstack));
}
项目:CustomWorldGen    文件:CreativeTabs.java   
/**
 * Adds the enchantment books from the supplied EnumEnchantmentType to the given list.
 */
@SideOnly(Side.CLIENT)
public void addEnchantmentBooksToList(List<ItemStack> itemList, EnumEnchantmentType... enchantmentType)
{
    for (Enchantment enchantment : Enchantment.REGISTRY)
    {
        if (enchantment != null && enchantment.type != null)
        {
            boolean flag = false;

            for (int i = 0; i < enchantmentType.length && !flag; ++i)
            {
                if (enchantment.type == enchantmentType[i])
                {
                    flag = true;
                }
            }

            if (flag)
            {
                itemList.add(Items.ENCHANTED_BOOK.getEnchantedItemStack(new EnchantmentData(enchantment, enchantment.getMaxLevel())));
            }
        }
    }
}
项目:MidgarCrusade    文件:TradeHandler.java   
@Override
public void manipulateTradesForVillager(EntityVillager villager, MerchantRecipeList recipeList, Random random)
{
    for (int i = 0; i < 4; i++)
    {
        switch(villager.getProfession()) 
        {
            case 0: // FARMER
                recipeList.add(new MerchantRecipe(new ItemStack(ItemRegister.COMBUSTIUM, 2), new ItemStack(Items.apple, 1)));
                break;
            case 1: // LIBRARIAN
                recipeList.add(new MerchantRecipe(new ItemStack(ItemRegister.COMBUSTIUM, 4, 15), new ItemStack(Items.paper, 1, 6)));
                recipeList.add(new MerchantRecipe(new ItemStack(ItemRegister.COMBUSTIUM, 1), Items.enchanted_book.getEnchantedItemStack(new EnchantmentData(Enchantment.flame, 1))));
                break;
            case 2: // PRIEST
                recipeList.add(new MerchantRecipe(new ItemStack(ItemRegister.COMBUSTIUM, 6), new ItemStack(Items.apple, 2), new ItemStack(Items.apple, 2)));
                break;
            case 3: // BLACKSMITH
                recipeList.add(new MerchantRecipe(new ItemStack(ItemRegister.COMBUSTIUM, 6 + random.nextInt(6)), new ItemStack(Items.apple, 5 + random.nextInt(4)), new ItemStack(Items.apple, 1)));
                recipeList.add(new MerchantRecipe(new ItemStack(ItemRegister.ETHERNIUM, 64), new ItemStack(ItemRegister.ELLAMAYNE, 1)));
                break;
            default:
                break;
        }
    }
}
项目:EnchantmentRevealer    文件:EnchantmentWorker.java   
private void testEnchantsAndAdd(int seed, Observation observation) {
    for (int i = 0; i < 3; ++i) {
        int level = observation.levels[i];

        if (level == 0) {
            tempEnchantmentData[i] = null;
            continue;
        }
        List<EnchantmentData> list = buildEnchantmentList(seed, observation, i);
        tempEnchantmentData[i] = list;
        if (!list.isEmpty()) {
            EnchantmentData data = list.get(rand.nextInt(list.size()));
            if (Enchantment.getEnchantmentByID(observation.enchants[i]) != data.enchantmentobj ||
                    observation.enchantLevels[i] != data.enchantmentLevel) {
                return;
            }
        } else {
            // Real enchant has something for this slot, but we found nothing.
            return;
        }
    }
    addCandidate(seed);
    tallyEnchants();
}
项目:EnchantmentRevealer    文件:EnchantmentWorker.java   
private void tallyEnchants() {
    for (int i = 0; i < 3; ++i) {
        ArrayList<EnchantCount> list = enchantCounts[i];
        List<EnchantmentData> enchantData = tempEnchantmentData[i];
        if (enchantData == null) {
            continue;
        }
        outer: for (EnchantmentData data : enchantData) {
            final int size = list.size();
            for (int j = 0; j < size; ++j) {
                EnchantCount pair = list.get(j);
                if (EnchantCount.equals(pair.enchant, data)) {
                    pair.count++;
                    continue outer;
                }
            }
            list.add(new EnchantCount(1, data));
        }
    }
}
项目:LightningCraft    文件:UnderworldTower.java   
public UnderworldTower(Random rand, int par2, int par3)
{
    super(rand, par2, 64, par3, 11, 25, 11);
    this.spawnMinY = 32;
    this.spawnMaxY = 180;
    ItemStack bookThor = new ItemStack(Items.ENCHANTED_BOOK), bookAura = new ItemStack(Items.ENCHANTED_BOOK);
    Items.ENCHANTED_BOOK.addEnchantment(bookThor, new EnchantmentData(LCEnchantments.handOfThor, 1));
    Items.ENCHANTED_BOOK.addEnchantment(bookAura, new EnchantmentData(LCEnchantments.elecAura, 1));
    WeightedRandomChestContent contentBookThor = new WeightedRandomChestContent(null, 0, 1, 2, 2); contentBookThor.theItemId = bookThor;
    WeightedRandomChestContent contentBookAura = new WeightedRandomChestContent(null, 0, 1, 2, 2); contentBookAura.theItemId = bookAura;

    lootChests = new LootChestGroup(nChests, minStacks, maxStacks, new WeightedRandomChestContent[]
        {new WeightedRandomChestContent(LCItems.material, Material.DEMON_BLOOD, 1, 3, 5), new WeightedRandomChestContent(Items.DIAMOND, 0, 1, 5, 20), 
        new WeightedRandomChestContent(Items.GOLD_INGOT, 0, 2, 7, 20), new WeightedRandomChestContent(Items.EMERALD, 0, 1, 3, 20), 
        new WeightedRandomChestContent(Items.FIRE_CHARGE, 0, 4, 6, 15), new WeightedRandomChestContent(Items.IRON_INGOT, 0, 3, 7, 20), 
        new WeightedRandomChestContent(LCItems.elecBoots, 0, 1, 1, 1), new WeightedRandomChestContent(LCItems.elecLegs, 0, 1, 1, 1), 
        new WeightedRandomChestContent(LCItems.elecHelm, 0, 1, 1, 1), new WeightedRandomChestContent(LCItems.elecChest, 0, 1, 1, 1),
        new WeightedRandomChestContent(LCItems.elecSword, 0, 1, 1, 1), new WeightedRandomChestContent(LCItems.ingot, Ingot.SKY, 1, 1, 1),
        new WeightedRandomChestContent(LCItems.ingot, Ingot.ELEC, 1, 5, 10), contentBookThor, contentBookAura});
}
项目:OldMods    文件:EnchantedBookRecipes.java   
public static void addEnchantmentRecipe( ItemStack[] items, EnchantmentData out, EnchantmentData in )
{
    if ( items.length > 8 )
    {
        throw new IllegalArgumentException( "8 itemstacks must be provided!" );
    }
    else if ( out == null )
    {
        throw new IllegalArgumentException( "Enchantment must be provided for output!" );
    }

    Recipe r = new Recipe();
    r.out = out;
    r.in = in;
    r.recipe = items;

    if ( items.length < 8 )
    {
        ItemStack[] newItems = new ItemStack[ 8 ];
        for ( int i = 0; i < items.length; newItems[ i ] = items[ i++ ] );
        r.recipe = newItems;
    }

    recipes.add( r );
}
项目:OldMods    文件:CraftableEnchantedBooks.java   
private void doEnchantment( Enchantment ench, int level, Item mat1, int amt1, Item mat2, int amt2, EnchantmentData start )
{
    for ( int i = 1; i <= level; ++i )
    {
        ItemStack[] items = new ItemStack[ 8 ];
        int ii = 0;
        for ( ; ii < amt1; ++ii )
        {
            items[ ii ] = new ItemStack( mat1 );
        }
        for ( ; ii < amt1 + amt2; ++ii )
        {
            items[ ii ] = new ItemStack( mat2 );
        }
        EnchantmentData out = new EnchantmentData( ench, i );
        EnchantmentData in = ( i != 1 ) ? new EnchantmentData( ench, i - 1 ) : start;
        EnchantedBookRecipes.addEnchantmentRecipe( items, out, in );
    }
}
项目:Bookshelf    文件:EnchantData.java   
@Override
public boolean equals (Object other) {

    if (!(other instanceof EnchantmentData)) {
        return false;
    }
    final EnchantmentData data = (EnchantmentData) other;
    boolean equal = false;
    if (this.enchantment.getRegistryName().equals(data.enchantment.getRegistryName())) {
        equal = true;
    }
    if (this.enchantmentLevel == data.enchantmentLevel) {
        equal = true;
    }
    return equal || super.equals(other);
}
项目:SpaceCore    文件:EnchantedBookRecipes.java   
public static void addEnchantmentRecipe( ItemStack[] items, EnchantmentData out, EnchantmentData in )
{
    if ( items.length > 8 )
    {
        throw new IllegalArgumentException( "8 itemstacks must be provided!" );
    }
    else if ( out == null )
    {
        throw new IllegalArgumentException( "Enchantment must be provided for output!" );
    }

    Recipe r = new Recipe();
    r.out = out;
    r.in = in;
    r.recipe = items;

    if ( items.length < 8 )
    {
        ItemStack[] newItems = new ItemStack[ 8 ];
        for ( int i = 0; i < items.length; newItems[ i ] = items[ i++ ] );
        r.recipe = newItems;
    }

    recipes.add( r );
}
项目:SpaceCore    文件:CraftableEnchantedBooks.java   
private static void doEnchantment( Enchantment ench, int level, Item mat1, int amt1, Item mat2, int amt2, EnchantmentData start )
{
    for ( int i = 1; i <= level; ++i )
    {
        ItemStack[] items = new ItemStack[ 8 ];
        int ii = 0;
        for ( ; ii < amt1; ++ii )
        {
            items[ ii ] = new ItemStack( mat1 );
        }
        for ( ; ii < amt1 + amt2; ++ii )
        {
            items[ ii ] = new ItemStack( mat2 );
        }
        EnchantmentData out = new EnchantmentData( ench, i );
        EnchantmentData in = ( i != 1 ) ? new EnchantmentData( ench, i - 1 ) : start;
        EnchantedBookRecipes.addEnchantmentRecipe( items, out, in );
    }
}
项目:ExpandedRailsMod    文件:EntityVillager.java   
/**
 * Affects the given MerchantRecipeList to possibly add or remove MerchantRecipes.
 */
public void modifyMerchantRecipeList(MerchantRecipeList recipeList, Random random)
{
    Enchantment enchantment = (Enchantment)Enchantment.REGISTRY.getRandomObject(random);
    int i = MathHelper.getRandomIntegerInRange(random, enchantment.getMinLevel(), enchantment.getMaxLevel());
    ItemStack itemstack = Items.ENCHANTED_BOOK.getEnchantedItemStack(new EnchantmentData(enchantment, i));
    int j = 2 + random.nextInt(5 + i * 10) + 3 * i;

    if (enchantment.isTreasureEnchantment())
    {
        j *= 2;
    }

    if (j > 64)
    {
        j = 64;
    }

    recipeList.add(new MerchantRecipe(new ItemStack(Items.BOOK), new ItemStack(Items.EMERALD, j), itemstack));
}
项目:ExpandedRailsMod    文件:CreativeTabs.java   
/**
 * Adds the enchantment books from the supplied EnumEnchantmentType to the given list.
 */
@SideOnly(Side.CLIENT)
public void addEnchantmentBooksToList(List<ItemStack> itemList, EnumEnchantmentType... enchantmentType)
{
    for (Enchantment enchantment : Enchantment.REGISTRY)
    {
        if (enchantment != null && enchantment.type != null)
        {
            boolean flag = false;

            for (int i = 0; i < enchantmentType.length && !flag; ++i)
            {
                if (enchantment.type == enchantmentType[i])
                {
                    flag = true;
                }
            }

            if (flag)
            {
                itemList.add(Items.ENCHANTED_BOOK.getEnchantedItemStack(new EnchantmentData(enchantment, enchantment.getMaxLevel())));
            }
        }
    }
}
项目:Marble    文件:WitheringHandler.java   
@SubscribeEvent
public void onEntityKill(LivingDropsEvent event){
    if(event.entityLiving instanceof EntitySkeleton){
        if(((EntitySkeleton) event.entityLiving).getSkeletonType() == 1){
            if(Math.round(Marble.rand.nextFloat() * 100) < ConfigHandler.witherOneDropChance){
                MiscHelper.drop(event, Items.enchanted_book.getEnchantedItemStack(new EnchantmentData(ConfigHandler.witheringID, 1)));
            }
        }
    }

    if(event.entityLiving instanceof EntityWither){
        if(Math.round(Marble.rand.nextInt()) < ConfigHandler.witherTwoDropChance){
            MiscHelper.drop(event, Items.enchanted_book.getEnchantedItemStack(new EnchantmentData(ConfigHandler.witheringID, 2)));
        }
    }
}
项目:RuneCraftery    文件:EnchantmentHelper.java   
public static void func_82782_a(Map p_82782_0_, ItemStack p_82782_1_) {
   NBTTagList var2 = new NBTTagList();
   Iterator var3 = p_82782_0_.keySet().iterator();

   while(var3.hasNext()) {
      int var4 = ((Integer)var3.next()).intValue();
      NBTTagCompound var5 = new NBTTagCompound();
      var5.func_74777_a("id", (short)var4);
      var5.func_74777_a("lvl", (short)((Integer)p_82782_0_.get(Integer.valueOf(var4))).intValue());
      var2.func_74742_a(var5);
      if(p_82782_1_.field_77993_c == Item.field_92105_bW.field_77779_bT) {
         Item.field_92105_bW.func_92115_a(p_82782_1_, new EnchantmentData(var4, ((Integer)p_82782_0_.get(Integer.valueOf(var4))).intValue()));
      }
   }

   if(var2.func_74745_c() > 0) {
      if(p_82782_1_.field_77993_c != Item.field_92105_bW.field_77779_bT) {
         p_82782_1_.func_77983_a("ench", var2);
      }
   } else if(p_82782_1_.func_77942_o()) {
      p_82782_1_.func_77978_p().func_82580_o("ench");
   }

}
项目:RuneCraftery    文件:EnchantmentHelper.java   
public static ItemStack func_77504_a(Random p_77504_0_, ItemStack p_77504_1_, int p_77504_2_) {
   List var3 = func_77513_b(p_77504_0_, p_77504_1_, p_77504_2_);
   boolean var4 = p_77504_1_.field_77993_c == Item.field_77760_aL.field_77779_bT;
   if(var4) {
      p_77504_1_.field_77993_c = Item.field_92105_bW.field_77779_bT;
   }

   if(var3 != null) {
      Iterator var5 = var3.iterator();

      while(var5.hasNext()) {
         EnchantmentData var6 = (EnchantmentData)var5.next();
         if(var4) {
            Item.field_92105_bW.func_92115_a(p_77504_1_, var6);
         } else {
            p_77504_1_.func_77966_a(var6.field_76302_b, var6.field_76303_c);
         }
      }
   }

   return p_77504_1_;
}
项目:RuneCraftery    文件:EnchantmentHelper.java   
public static Map func_77505_b(int p_77505_0_, ItemStack p_77505_1_) {
   Item var2 = p_77505_1_.func_77973_b();
   HashMap var3 = null;
   boolean var4 = p_77505_1_.field_77993_c == Item.field_77760_aL.field_77779_bT;
   Enchantment[] var5 = Enchantment.field_77331_b;
   int var6 = var5.length;

   for(int var7 = 0; var7 < var6; ++var7) {
      Enchantment var8 = var5[var7];
      if(var8 != null && (var8.field_77351_y.func_77557_a(var2) || var4)) {
         for(int var9 = var8.func_77319_d(); var9 <= var8.func_77325_b(); ++var9) {
            if(p_77505_0_ >= var8.func_77321_a(var9) && p_77505_0_ <= var8.func_77317_b(var9)) {
               if(var3 == null) {
                  var3 = new HashMap();
               }

               var3.put(Integer.valueOf(var8.field_77352_x), new EnchantmentData(var8, var9));
            }
         }
      }
   }

   return var3;
}
项目:RuneCraftery    文件:CreativeTabs.java   
@SideOnly(Side.CLIENT)
public void func_92116_a(List p_92116_1_, EnumEnchantmentType ... p_92116_2_) {
   Enchantment[] var3 = Enchantment.field_77331_b;
   int var4 = var3.length;

   for(int var5 = 0; var5 < var4; ++var5) {
      Enchantment var6 = var3[var5];
      if(var6 != null && var6.field_77351_y != null) {
         boolean var7 = false;

         for(int var8 = 0; var8 < p_92116_2_.length && !var7; ++var8) {
            if(var6.field_77351_y == p_92116_2_[var8]) {
               var7 = true;
            }
         }

         if(var7) {
            p_92116_1_.add(Item.field_92105_bW.func_92111_a(new EnchantmentData(var6, var6.func_77325_b())));
         }
      }
   }

}
项目:OpenModsLib    文件:VanillaEnchantLogic.java   
@Nonnull
public ItemStack enchant() {
    if (toEnchant.isEmpty())
        return ItemStack.EMPTY;

    ItemStack enchantedItem = toEnchant.copy();
    final boolean isBook = enchantedItem.getItem() == Items.BOOK;

    final List<EnchantmentData> enchantmentsToApply = getEnchantmentList(toEnchant, level, xpLevels);
    if (!enchantmentsToApply.isEmpty()) {
        if (isBook) {
            enchantedItem = new ItemStack(Items.ENCHANTED_BOOK);
        }

        for (EnchantmentData enchantment : enchantmentsToApply) {
            if (isBook) {
                ItemEnchantedBook.addEnchantment(enchantedItem, enchantment);
            } else {
                enchantedItem.addEnchantment(enchantment.enchantment, enchantment.enchantmentLevel);
            }
        }
    }

    return enchantedItem;
}
项目:DecompiledMinecraft    文件:EntityVillager.java   
public void modifyMerchantRecipeList(MerchantRecipeList recipeList, Random random)
{
    Enchantment enchantment = Enchantment.enchantmentsBookList[random.nextInt(Enchantment.enchantmentsBookList.length)];
    int i = MathHelper.getRandomIntegerInRange(random, enchantment.getMinLevel(), enchantment.getMaxLevel());
    ItemStack itemstack = Items.enchanted_book.getEnchantedItemStack(new EnchantmentData(enchantment, i));
    int j = 2 + random.nextInt(5 + i * 10) + 3 * i;

    if (j > 64)
    {
        j = 64;
    }

    recipeList.add(new MerchantRecipe(new ItemStack(Items.book), new ItemStack(Items.emerald, j), itemstack));
}
项目:DecompiledMinecraft    文件:ItemEnchantedBook.java   
/**
 * Adds an stored enchantment to an enchanted book ItemStack
 */
public void addEnchantment(ItemStack stack, EnchantmentData enchantment)
{
    NBTTagList nbttaglist = this.getEnchantments(stack);
    boolean flag = true;

    for (int i = 0; i < nbttaglist.tagCount(); ++i)
    {
        NBTTagCompound nbttagcompound = nbttaglist.getCompoundTagAt(i);

        if (nbttagcompound.getShort("id") == enchantment.enchantmentobj.effectId)
        {
            if (nbttagcompound.getShort("lvl") < enchantment.enchantmentLevel)
            {
                nbttagcompound.setShort("lvl", (short)enchantment.enchantmentLevel);
            }

            flag = false;
            break;
        }
    }

    if (flag)
    {
        NBTTagCompound nbttagcompound1 = new NBTTagCompound();
        nbttagcompound1.setShort("id", (short)enchantment.enchantmentobj.effectId);
        nbttagcompound1.setShort("lvl", (short)enchantment.enchantmentLevel);
        nbttaglist.appendTag(nbttagcompound1);
    }

    if (!stack.hasTagCompound())
    {
        stack.setTagCompound(new NBTTagCompound());
    }

    stack.getTagCompound().setTag("StoredEnchantments", nbttaglist);
}
项目:DecompiledMinecraft    文件:ItemEnchantedBook.java   
/**
 * Returns the ItemStack of an enchanted version of this item.
 */
public ItemStack getEnchantedItemStack(EnchantmentData data)
{
    ItemStack itemstack = new ItemStack(this);
    this.addEnchantment(itemstack, data);
    return itemstack;
}
项目:DecompiledMinecraft    文件:ContainerEnchantment.java   
private List<EnchantmentData> func_178148_a(ItemStack stack, int p_178148_2_, int p_178148_3_)
{
    this.rand.setSeed((long)(this.xpSeed + p_178148_2_));
    List<EnchantmentData> list = EnchantmentHelper.buildEnchantmentList(this.rand, stack, p_178148_3_);

    if (stack.getItem() == Items.book && list != null && list.size() > 1)
    {
        list.remove(this.rand.nextInt(list.size()));
    }

    return list;
}
项目:DecompiledMinecraft    文件:EntityVillager.java   
public void modifyMerchantRecipeList(MerchantRecipeList recipeList, Random random)
{
    Enchantment enchantment = Enchantment.enchantmentsBookList[random.nextInt(Enchantment.enchantmentsBookList.length)];
    int i = MathHelper.getRandomIntegerInRange(random, enchantment.getMinLevel(), enchantment.getMaxLevel());
    ItemStack itemstack = Items.enchanted_book.getEnchantedItemStack(new EnchantmentData(enchantment, i));
    int j = 2 + random.nextInt(5 + i * 10) + 3 * i;

    if (j > 64)
    {
        j = 64;
    }

    recipeList.add(new MerchantRecipe(new ItemStack(Items.book), new ItemStack(Items.emerald, j), itemstack));
}
项目:DecompiledMinecraft    文件:ItemEnchantedBook.java   
/**
 * Adds an stored enchantment to an enchanted book ItemStack
 */
public void addEnchantment(ItemStack stack, EnchantmentData enchantment)
{
    NBTTagList nbttaglist = this.getEnchantments(stack);
    boolean flag = true;

    for (int i = 0; i < nbttaglist.tagCount(); ++i)
    {
        NBTTagCompound nbttagcompound = nbttaglist.getCompoundTagAt(i);

        if (nbttagcompound.getShort("id") == enchantment.enchantmentobj.effectId)
        {
            if (nbttagcompound.getShort("lvl") < enchantment.enchantmentLevel)
            {
                nbttagcompound.setShort("lvl", (short)enchantment.enchantmentLevel);
            }

            flag = false;
            break;
        }
    }

    if (flag)
    {
        NBTTagCompound nbttagcompound1 = new NBTTagCompound();
        nbttagcompound1.setShort("id", (short)enchantment.enchantmentobj.effectId);
        nbttagcompound1.setShort("lvl", (short)enchantment.enchantmentLevel);
        nbttaglist.appendTag(nbttagcompound1);
    }

    if (!stack.hasTagCompound())
    {
        stack.setTagCompound(new NBTTagCompound());
    }

    stack.getTagCompound().setTag("StoredEnchantments", nbttaglist);
}
项目:DecompiledMinecraft    文件:ItemEnchantedBook.java   
/**
 * Returns the ItemStack of an enchanted version of this item.
 */
public ItemStack getEnchantedItemStack(EnchantmentData data)
{
    ItemStack itemstack = new ItemStack(this);
    this.addEnchantment(itemstack, data);
    return itemstack;
}
项目:DecompiledMinecraft    文件:ItemEnchantedBook.java   
public void getAll(Enchantment enchantment, List<ItemStack> list)
{
    for (int i = enchantment.getMinLevel(); i <= enchantment.getMaxLevel(); ++i)
    {
        list.add(this.getEnchantedItemStack(new EnchantmentData(enchantment, i)));
    }
}
项目:DecompiledMinecraft    文件:ContainerEnchantment.java   
private List<EnchantmentData> func_178148_a(ItemStack stack, int p_178148_2_, int p_178148_3_)
{
    this.rand.setSeed((long)(this.xpSeed + p_178148_2_));
    List<EnchantmentData> list = EnchantmentHelper.buildEnchantmentList(this.rand, stack, p_178148_3_);

    if (stack.getItem() == Items.book && list != null && list.size() > 1)
    {
        list.remove(this.rand.nextInt(list.size()));
    }

    return list;
}
项目:VirtualTool    文件:VirtualEnchantingTable.java   
private List<EnchantmentData> getEnchantmentList(net.minecraft.item.ItemStack stack, int p_178148_2_, int p_178148_3_) {
    this.rand.setSeed((long) (this.xpSeed + p_178148_2_));
    List<EnchantmentData> list = EnchantmentHelper.buildEnchantmentList(this.rand, stack, p_178148_3_, false);

    if (stack.getItem() == Items.BOOK && list.size() > 1) {
        list.remove(this.rand.nextInt(list.size()));
    }

    return list;
}
项目:BaseClient    文件:EntityVillager.java   
public void modifyMerchantRecipeList(MerchantRecipeList recipeList, Random random)
{
    Enchantment enchantment = Enchantment.enchantmentsBookList[random.nextInt(Enchantment.enchantmentsBookList.length)];
    int i = MathHelper.getRandomIntegerInRange(random, enchantment.getMinLevel(), enchantment.getMaxLevel());
    ItemStack itemstack = Items.enchanted_book.getEnchantedItemStack(new EnchantmentData(enchantment, i));
    int j = 2 + random.nextInt(5 + i * 10) + 3 * i;

    if (j > 64)
    {
        j = 64;
    }

    recipeList.add(new MerchantRecipe(new ItemStack(Items.book), new ItemStack(Items.emerald, j), itemstack));
}
项目:BaseClient    文件:ItemEnchantedBook.java   
/**
 * Adds an stored enchantment to an enchanted book ItemStack
 */
public void addEnchantment(ItemStack stack, EnchantmentData enchantment)
{
    NBTTagList nbttaglist = this.getEnchantments(stack);
    boolean flag = true;

    for (int i = 0; i < nbttaglist.tagCount(); ++i)
    {
        NBTTagCompound nbttagcompound = nbttaglist.getCompoundTagAt(i);

        if (nbttagcompound.getShort("id") == enchantment.enchantmentobj.effectId)
        {
            if (nbttagcompound.getShort("lvl") < enchantment.enchantmentLevel)
            {
                nbttagcompound.setShort("lvl", (short)enchantment.enchantmentLevel);
            }

            flag = false;
            break;
        }
    }

    if (flag)
    {
        NBTTagCompound nbttagcompound1 = new NBTTagCompound();
        nbttagcompound1.setShort("id", (short)enchantment.enchantmentobj.effectId);
        nbttagcompound1.setShort("lvl", (short)enchantment.enchantmentLevel);
        nbttaglist.appendTag(nbttagcompound1);
    }

    if (!stack.hasTagCompound())
    {
        stack.setTagCompound(new NBTTagCompound());
    }

    stack.getTagCompound().setTag("StoredEnchantments", nbttaglist);
}
项目:BaseClient    文件:ItemEnchantedBook.java   
/**
 * Returns the ItemStack of an enchanted version of this item.
 */
public ItemStack getEnchantedItemStack(EnchantmentData data)
{
    ItemStack itemstack = new ItemStack(this);
    this.addEnchantment(itemstack, data);
    return itemstack;
}
项目:BaseClient    文件:ItemEnchantedBook.java   
public void getAll(Enchantment enchantment, List<ItemStack> list)
{
    for (int i = enchantment.getMinLevel(); i <= enchantment.getMaxLevel(); ++i)
    {
        list.add(this.getEnchantedItemStack(new EnchantmentData(enchantment, i)));
    }
}
项目:BaseClient    文件:ContainerEnchantment.java   
private List<EnchantmentData> func_178148_a(ItemStack stack, int p_178148_2_, int p_178148_3_)
{
    this.rand.setSeed((long)(this.xpSeed + p_178148_2_));
    List<EnchantmentData> list = EnchantmentHelper.buildEnchantmentList(this.rand, stack, p_178148_3_);

    if (stack.getItem() == Items.book && list != null && list.size() > 1)
    {
        list.remove(this.rand.nextInt(list.size()));
    }

    return list;
}