当前位置: 首页>>代码示例>>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;未经允许,请勿转载。