Beispiel #1
0
        public static void Func_48441_a(Random par0Random, ItemStack par1ItemStack, int par2)
        {
            List <EnchantmentData> list = BuildEnchantmentList(par0Random, par1ItemStack, par2);

            if (list != null)
            {
                EnchantmentData enchantmentdata;

                for (IEnumerator <EnchantmentData> iterator = list.GetEnumerator(); iterator.MoveNext(); par1ItemStack.AddEnchantment(enchantmentdata.Enchantmentobj, enchantmentdata.EnchantmentLevel))
                {
                    enchantmentdata = iterator.Current;
                }
            }
        }
Beispiel #2
0
        /// <summary>
        /// enchants the item on the table using the specified slot; also deducts XP from player
        /// </summary>
        public override bool EnchantItem(EntityPlayer par1EntityPlayer, int par2)
        {
            ItemStack itemstack = TableInventory.GetStackInSlot(0);

            if (EnchantLevels[par2] > 0 && itemstack != null && (par1EntityPlayer.ExperienceLevel >= EnchantLevels[par2] || par1EntityPlayer.Capabilities.IsCreativeMode))
            {
                if (!WorldPointer.IsRemote)
                {
                    List <EnchantmentData> list = EnchantmentHelper.BuildEnchantmentList(Rand, itemstack, EnchantLevels[par2]);

                    if (list != null)
                    {
                        par1EntityPlayer.RemoveExperience(EnchantLevels[par2]);
                        EnchantmentData enchantmentdata;

                        for (IEnumerator <EnchantmentData> iterator = list.GetEnumerator(); iterator.MoveNext(); itemstack.AddEnchantment(enchantmentdata.Enchantmentobj, enchantmentdata.EnchantmentLevel))
                        {
                            enchantmentdata = iterator.Current;
                        }

                        OnCraftMatrixChanged(TableInventory);
                    }
                }

                return(true);
            }
            else
            {
                return(false);
            }
        }