本文整理匯總了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)));
}
}
}
示例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);
}
}
}
}
示例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;
}
示例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;
}
示例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));
}
示例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));
}
示例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));
}
示例8: addNewEnchantment
import net.minecraft.enchantment.EnchantmentHelper; //導入方法依賴的package包/類
private static void addNewEnchantment(ItemStack item) {
EnchantmentHelper.addRandomEnchantment(rand, item, 1, true);
removeDuplicateEnchantments(item);
}
示例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);
}
示例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);
}
示例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;
}