當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。