当前位置: 首页>>代码示例>>Java>>正文


Java EnchantmentHelper.addRandomEnchantment方法代码示例

本文整理汇总了Java中net.minecraft.enchantment.EnchantmentHelper.addRandomEnchantment方法的典型用法代码示例。如果您正苦于以下问题:Java EnchantmentHelper.addRandomEnchantment方法的具体用法?Java EnchantmentHelper.addRandomEnchantment怎么用?Java EnchantmentHelper.addRandomEnchantment使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在net.minecraft.enchantment.EnchantmentHelper的用法示例。


在下文中一共展示了EnchantmentHelper.addRandomEnchantment方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setEnchantmentBasedOnDifficulty

import net.minecraft.enchantment.EnchantmentHelper; //导入方法依赖的package包/类
/**
 * Enchants Entity's current equipments based on given DifficultyInstance
 */
protected void setEnchantmentBasedOnDifficulty(DifficultyInstance difficulty)
{
    float f = difficulty.getClampedAdditionalDifficulty();

    if (this.getHeldItem() != null && this.rand.nextFloat() < 0.25F * f)
    {
        EnchantmentHelper.addRandomEnchantment(this.rand, this.getHeldItem(), (int)(5.0F + f * (float)this.rand.nextInt(18)));
    }

    for (int i = 0; i < 4; ++i)
    {
        ItemStack itemstack = this.getCurrentArmor(i);

        if (itemstack != null && this.rand.nextFloat() < 0.5F * f)
        {
            EnchantmentHelper.addRandomEnchantment(this.rand, itemstack, (int)(5.0F + f * (float)this.rand.nextInt(18)));
        }
    }
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:23,代码来源:EntityLiving.java

示例2: setEnchantmentBasedOnDifficulty

import net.minecraft.enchantment.EnchantmentHelper; //导入方法依赖的package包/类
/**
 * Enchants Entity's current equipments based on given DifficultyInstance
 */
protected void setEnchantmentBasedOnDifficulty(DifficultyInstance difficulty)
{
    float f = difficulty.getClampedAdditionalDifficulty();

    if (this.getHeldItemMainhand() != null && this.rand.nextFloat() < 0.25F * f)
    {
        EnchantmentHelper.addRandomEnchantment(this.rand, this.getHeldItemMainhand(), (int)(5.0F + f * (float)this.rand.nextInt(18)), false);
    }

    for (EntityEquipmentSlot entityequipmentslot : EntityEquipmentSlot.values())
    {
        if (entityequipmentslot.getSlotType() == EntityEquipmentSlot.Type.ARMOR)
        {
            ItemStack itemstack = this.getItemStackFromSlot(entityequipmentslot);

            if (itemstack != null && this.rand.nextFloat() < 0.5F * f)
            {
                EnchantmentHelper.addRandomEnchantment(this.rand, itemstack, (int)(5.0F + f * (float)this.rand.nextInt(18)), false);
            }
        }
    }
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:26,代码来源:EntityLiving.java

示例3: createSkeleton

import net.minecraft.enchantment.EnchantmentHelper; //导入方法依赖的package包/类
private EntitySkeleton createSkeleton(DifficultyInstance p_188514_1_, EntityHorse p_188514_2_)
{
    EntitySkeleton entityskeleton = new EntitySkeleton(p_188514_2_.worldObj);
    entityskeleton.onInitialSpawn(p_188514_1_, (IEntityLivingData)null);
    entityskeleton.setPosition(p_188514_2_.posX, p_188514_2_.posY, p_188514_2_.posZ);
    entityskeleton.hurtResistantTime = 60;
    entityskeleton.enablePersistence();

    if (entityskeleton.getItemStackFromSlot(EntityEquipmentSlot.HEAD) == null)
    {
        entityskeleton.setItemStackToSlot(EntityEquipmentSlot.HEAD, new ItemStack(Items.IRON_HELMET));
    }

    EnchantmentHelper.addRandomEnchantment(entityskeleton.getRNG(), entityskeleton.getHeldItemMainhand(), (int)(5.0F + p_188514_1_.getClampedAdditionalDifficulty() * (float)entityskeleton.getRNG().nextInt(18)), false);
    EnchantmentHelper.addRandomEnchantment(entityskeleton.getRNG(), entityskeleton.getItemStackFromSlot(EntityEquipmentSlot.HEAD), (int)(5.0F + p_188514_1_.getClampedAdditionalDifficulty() * (float)entityskeleton.getRNG().nextInt(18)), false);
    entityskeleton.worldObj.spawnEntityInWorld(entityskeleton);
    return entityskeleton;
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:19,代码来源:EntityAISkeletonRiders.java

示例4: getItemStack

import net.minecraft.enchantment.EnchantmentHelper; //导入方法依赖的package包/类
public ItemStack getItemStack(Random random)
{
    ItemStack itemstack = this.returnStack.copy();

    if (this.maxDamagePercent > 0.0F)
    {
        int i = (int)(this.maxDamagePercent * (float)this.returnStack.getMaxDamage());
        int j = itemstack.getMaxDamage() - random.nextInt(random.nextInt(i) + 1);

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

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

        itemstack.setItemDamage(j);
    }

    if (this.enchantable)
    {
        EnchantmentHelper.addRandomEnchantment(random, itemstack, 30);
    }

    return itemstack;
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:30,代码来源:WeightedRandomFishable.java

示例5: modifyMerchantRecipeList

import net.minecraft.enchantment.EnchantmentHelper; //导入方法依赖的package包/类
public void modifyMerchantRecipeList(MerchantRecipeList recipeList, Random random)
{
    int i = 1;

    if (this.field_179406_b != null)
    {
        i = this.field_179406_b.getPrice(random);
    }

    ItemStack itemstack = new ItemStack(Items.emerald, i, 0);
    ItemStack itemstack1 = new ItemStack(this.field_179407_a.getItem(), 1, this.field_179407_a.getMetadata());
    itemstack1 = EnchantmentHelper.addRandomEnchantment(random, itemstack1, 5 + random.nextInt(15));
    recipeList.add(new MerchantRecipe(itemstack, itemstack1));
}
 
开发者ID:SkidJava,项目名称:BaseClient,代码行数:15,代码来源:EntityVillager.java

示例6: modifyMerchantRecipeList

import net.minecraft.enchantment.EnchantmentHelper; //导入方法依赖的package包/类
/**
 * Affects the given MerchantRecipeList to possibly add or remove MerchantRecipes.
 */
public void modifyMerchantRecipeList(MerchantRecipeList recipeList, Random random)
{
    int i = 1;

    if (this.priceInfo != null)
    {
        i = this.priceInfo.getPrice(random);
    }

    ItemStack itemstack = new ItemStack(Items.EMERALD, i, 0);
    ItemStack itemstack1 = new ItemStack(this.enchantedItemStack.getItem(), 1, this.enchantedItemStack.getMetadata());
    itemstack1 = EnchantmentHelper.addRandomEnchantment(random, itemstack1, 5 + random.nextInt(15), false);
    recipeList.add(new MerchantRecipe(itemstack, itemstack1));
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:18,代码来源:EntityVillager.java

示例7: func_190888_a

import net.minecraft.enchantment.EnchantmentHelper; //导入方法依赖的package包/类
public void func_190888_a(IMerchant p_190888_1_, MerchantRecipeList p_190888_2_, Random p_190888_3_)
{
    int i = 1;

    if (this.priceInfo != null)
    {
        i = this.priceInfo.getPrice(p_190888_3_);
    }

    ItemStack itemstack = new ItemStack(Items.EMERALD, i, 0);
    ItemStack itemstack1 = EnchantmentHelper.addRandomEnchantment(p_190888_3_, new ItemStack(this.enchantedItemStack.getItem(), 1, this.enchantedItemStack.getMetadata()), 5 + p_190888_3_.nextInt(15), false);
    p_190888_2_.add(new MerchantRecipe(itemstack, itemstack1));
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:14,代码来源:EntityVillager.java

示例8: addNewEnchantment

import net.minecraft.enchantment.EnchantmentHelper; //导入方法依赖的package包/类
private static void addNewEnchantment(ItemStack item) {
	EnchantmentHelper.addRandomEnchantment(rand, item, 1, true);
	removeDuplicateEnchantments(item);
}
 
开发者ID:ToroCraft,项目名称:NemesisSystem,代码行数:5,代码来源:NemesisUtil.java

示例9: getRandom

import net.minecraft.enchantment.EnchantmentHelper; //导入方法依赖的package包/类
public WeightedRandomChestContent getRandom(Random rand, int minChance, int maxChance, int weight)
{
    ItemStack itemstack = new ItemStack(Items.book, 1, 0);
    EnchantmentHelper.addRandomEnchantment(rand, itemstack, 30);
    return new WeightedRandomChestContent(itemstack, minChance, maxChance, weight);
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:7,代码来源:ItemEnchantedBook.java

示例10: apply

import net.minecraft.enchantment.EnchantmentHelper; //导入方法依赖的package包/类
public ItemStack apply(ItemStack stack, Random rand, LootContext context)
{
    return EnchantmentHelper.addRandomEnchantment(rand, stack, this.randomLevel.generateInt(rand), this.isTreasure);
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:5,代码来源:EnchantWithLevels.java

示例11: apply

import net.minecraft.enchantment.EnchantmentHelper; //导入方法依赖的package包/类
public ItemStack apply(ItemStack stack, Random rand, LootContext context)
{
    EnchantmentHelper.addRandomEnchantment(rand, stack, this.randomLevel.generateInt(rand), this.isTreasure);
    return stack;
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:6,代码来源:EnchantWithLevels.java


注:本文中的net.minecraft.enchantment.EnchantmentHelper.addRandomEnchantment方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。