當前位置: 首頁>>代碼示例>>Java>>正文


Java Item.getItemEnchantability方法代碼示例

本文整理匯總了Java中net.minecraft.item.Item.getItemEnchantability方法的典型用法代碼示例。如果您正苦於以下問題:Java Item.getItemEnchantability方法的具體用法?Java Item.getItemEnchantability怎麽用?Java Item.getItemEnchantability使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在net.minecraft.item.Item的用法示例。


在下文中一共展示了Item.getItemEnchantability方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: calcItemStackEnchantability

import net.minecraft.item.Item; //導入方法依賴的package包/類
/**
 * Returns the enchantability of itemstack, it's uses a singular formula for each index (2nd parameter: 0, 1 and 2),
 * cutting to the max enchantability power of the table (3rd parameter)
 */
public static int calcItemStackEnchantability(Random p_77514_0_, int p_77514_1_, int p_77514_2_, ItemStack p_77514_3_)
{
    Item item = p_77514_3_.getItem();
    int i = item.getItemEnchantability();

    if (i <= 0)
    {
        return 0;
    }
    else
    {
        if (p_77514_2_ > 15)
        {
            p_77514_2_ = 15;
        }

        int j = p_77514_0_.nextInt(8) + 1 + (p_77514_2_ >> 1) + p_77514_0_.nextInt(p_77514_2_ + 1);
        return p_77514_1_ == 0 ? Math.max(j / 3, 1) : (p_77514_1_ == 1 ? j * 2 / 3 + 1 : Math.max(j, p_77514_2_ * 2));
    }
}
 
開發者ID:Notoh,項目名稱:DecompiledMinecraft,代碼行數:25,代碼來源:EnchantmentHelper.java

示例2: calcItemStackEnchantability

import net.minecraft.item.Item; //導入方法依賴的package包/類
/**
 * Returns the enchantability of itemstack, using a separate calculation for each enchantNum (0, 1 or 2), cutting to
 * the max enchantability power of the table, which is locked to a max of 15.
 */
public static int calcItemStackEnchantability(Random rand, int enchantNum, int power, ItemStack stack)
{
    Item item = stack.getItem();
    int i = item.getItemEnchantability();

    if (i <= 0)
    {
        return 0;
    }
    else
    {
        if (power > 15)
        {
            power = 15;
        }

        int j = rand.nextInt(8) + 1 + (power >> 1) + rand.nextInt(power + 1);
        return enchantNum == 0 ? Math.max(j / 3, 1) : (enchantNum == 1 ? j * 2 / 3 + 1 : Math.max(j, power * 2));
    }
}
 
開發者ID:sudofox,項目名稱:Backmemed,代碼行數:25,代碼來源:EnchantmentHelper.java

示例3: calcItemStackEnchantability

import net.minecraft.item.Item; //導入方法依賴的package包/類
/**
 * Returns the enchantability of itemstack, using a separate calculation for each enchantNum (0, 1 or 2), cutting to
 * the max enchantability power of the table, which is locked to a max of 15.
 */
public static int calcItemStackEnchantability(Random rand, int enchantNum, int power, ItemStack stack)
{
    Item item = stack.getItem();
    int i = item.getItemEnchantability(stack);

    if (i <= 0)
    {
        return 0;
    }
    else
    {
        if (power > 15)
        {
            power = 15;
        }

        int j = rand.nextInt(8) + 1 + (power >> 1) + rand.nextInt(power + 1);
        return enchantNum == 0 ? Math.max(j / 3, 1) : (enchantNum == 1 ? j * 2 / 3 + 1 : Math.max(j, power * 2));
    }
}
 
開發者ID:F1r3w477,項目名稱:CustomWorldGen,代碼行數:25,代碼來源:EnchantmentHelper.java

示例4: buildEnchantmentList

import net.minecraft.item.Item; //導入方法依賴的package包/類
public static List<EnchantmentData> buildEnchantmentList(Random randomIn, ItemStack itemStackIn, int p_77513_2_, boolean allowTreasure)
{
    List<EnchantmentData> list = Lists.<EnchantmentData>newArrayList();
    Item item = itemStackIn.getItem();
    int i = item.getItemEnchantability();

    if (i <= 0)
    {
        return list;
    }
    else
    {
        p_77513_2_ = p_77513_2_ + 1 + randomIn.nextInt(i / 4 + 1) + randomIn.nextInt(i / 4 + 1);
        float f = (randomIn.nextFloat() + randomIn.nextFloat() - 1.0F) * 0.15F;
        p_77513_2_ = MathHelper.clamp(Math.round((float)p_77513_2_ + (float)p_77513_2_ * f), 1, Integer.MAX_VALUE);
        List<EnchantmentData> list1 = getEnchantmentDatas(p_77513_2_, itemStackIn, allowTreasure);

        if (!list1.isEmpty())
        {
            list.add(WeightedRandom.getRandomItem(randomIn, list1));

            while (randomIn.nextInt(50) <= p_77513_2_)
            {
                removeIncompatible(list1, (EnchantmentData)Util.getLastElement(list));

                if (list1.isEmpty())
                {
                    break;
                }

                list.add(WeightedRandom.getRandomItem(randomIn, list1));
                p_77513_2_ /= 2;
            }
        }

        return list;
    }
}
 
開發者ID:sudofox,項目名稱:Backmemed,代碼行數:39,代碼來源:EnchantmentHelper.java

示例5: buildEnchantmentList

import net.minecraft.item.Item; //導入方法依賴的package包/類
public static List<EnchantmentData> buildEnchantmentList(Random randomIn, ItemStack itemStackIn, int p_77513_2_, boolean allowTreasure)
{
    List<EnchantmentData> list = Lists.<EnchantmentData>newArrayList();
    Item item = itemStackIn.getItem();
    int i = item.getItemEnchantability(itemStackIn);

    if (i <= 0)
    {
        return list;
    }
    else
    {
        p_77513_2_ = p_77513_2_ + 1 + randomIn.nextInt(i / 4 + 1) + randomIn.nextInt(i / 4 + 1);
        float f = (randomIn.nextFloat() + randomIn.nextFloat() - 1.0F) * 0.15F;
        p_77513_2_ = MathHelper.clamp_int(Math.round((float)p_77513_2_ + (float)p_77513_2_ * f), 1, Integer.MAX_VALUE);
        List<EnchantmentData> list1 = getEnchantmentDatas(p_77513_2_, itemStackIn, allowTreasure);

        if (!list1.isEmpty())
        {
            list.add(WeightedRandom.getRandomItem(randomIn, list1));

            while (randomIn.nextInt(50) <= p_77513_2_)
            {
                removeIncompatible(list1, (EnchantmentData)Util.getLastElement(list));

                if (list1.isEmpty())
                {
                    break;
                }

                list.add(WeightedRandom.getRandomItem(randomIn, list1));
                p_77513_2_ /= 2;
            }
        }

        return list;
    }
}
 
開發者ID:F1r3w477,項目名稱:CustomWorldGen,代碼行數:39,代碼來源:EnchantmentHelper.java

示例6: buildEnchantmentList

import net.minecraft.item.Item; //導入方法依賴的package包/類
public static List<EnchantmentData> buildEnchantmentList(Random randomIn, ItemStack itemStackIn, int p_77513_2_)
{
    Item item = itemStackIn.getItem();
    int i = item.getItemEnchantability();

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

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

        List<EnchantmentData> list = null;
        Map<Integer, EnchantmentData> map = mapEnchantmentData(k, itemStackIn);

        if (map != null && !map.isEmpty())
        {
            EnchantmentData enchantmentdata = (EnchantmentData)WeightedRandom.getRandomItem(randomIn, map.values());

            if (enchantmentdata != null)
            {
                list = Lists.<EnchantmentData>newArrayList();
                list.add(enchantmentdata);

                for (int l = k; randomIn.nextInt(50) <= l; l >>= 1)
                {
                    Iterator<Integer> iterator = map.keySet().iterator();

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

                        for (EnchantmentData enchantmentdata1 : list)
                        {
                            if (!enchantmentdata1.enchantmentobj.canApplyTogether(Enchantment.getEnchantmentById(integer.intValue())))
                            {
                                flag = false;
                                break;
                            }
                        }

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

                    if (!map.isEmpty())
                    {
                        EnchantmentData enchantmentdata2 = (EnchantmentData)WeightedRandom.getRandomItem(randomIn, map.values());
                        list.add(enchantmentdata2);
                    }
                }
            }
        }

        return list;
    }
}
 
開發者ID:Notoh,項目名稱:DecompiledMinecraft,代碼行數:71,代碼來源:EnchantmentHelper.java


注:本文中的net.minecraft.item.Item.getItemEnchantability方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。