本文整理汇总了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;
}