本文整理汇总了Java中net.minecraft.enchantment.EnchantmentHelper.getEnchantmentLevel方法的典型用法代码示例。如果您正苦于以下问题:Java EnchantmentHelper.getEnchantmentLevel方法的具体用法?Java EnchantmentHelper.getEnchantmentLevel怎么用?Java EnchantmentHelper.getEnchantmentLevel使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.minecraft.enchantment.EnchantmentHelper
的用法示例。
在下文中一共展示了EnchantmentHelper.getEnchantmentLevel方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: allowBlock
import net.minecraft.enchantment.EnchantmentHelper; //导入方法依赖的package包/类
public boolean allowBlock(ItemStack stack, IBlockState block, World world) {
float speed = BlockLauncher.getHardness(block, world);
float mult = 1 + EnchantmentHelper.getEnchantmentLevel(BlockLauncher.enchHeavy, stack) * 0.6F;
if (this.getType(stack) == 0)
return speed <= 2.2f * mult;
else if (this.getType(stack) == 2)
return speed <= 2.0f * mult;
else if (this.getType(stack) == 1)
return speed >= 2.2f / mult;
else if (this.getType(stack) == 4)
return speed <= 2.2f * mult;
else if (this.getType(stack) == 5)
return speed >= 2.2f * mult;
else if (this.getType(stack) == 3)
return block.getMaterial().getCanBurn() && block.getBlock() != Blocks.TNT;
else if (this.getType(stack) > 15)
return block.getBlock() == Blocks.TNT;
return true;
}
示例2: attackEntityWithRangedAttack
import net.minecraft.enchantment.EnchantmentHelper; //导入方法依赖的package包/类
/**
* Attack the specified entity using a ranged attack.
*/
public void attackEntityWithRangedAttack(EntityLivingBase p_82196_1_, float p_82196_2_)
{
EntityArrow entityarrow = new EntityArrow(this.worldObj, this, p_82196_1_, 1.6F, (float)(14 - this.worldObj.getDifficulty().getDifficultyId() * 4));
int i = EnchantmentHelper.getEnchantmentLevel(Enchantment.power.effectId, this.getHeldItem());
int j = EnchantmentHelper.getEnchantmentLevel(Enchantment.punch.effectId, this.getHeldItem());
entityarrow.setDamage((double)(p_82196_2_ * 2.0F) + this.rand.nextGaussian() * 0.25D + (double)((float)this.worldObj.getDifficulty().getDifficultyId() * 0.11F));
if (i > 0)
{
entityarrow.setDamage(entityarrow.getDamage() + (double)i * 0.5D + 0.5D);
}
if (j > 0)
{
entityarrow.setKnockbackStrength(j);
}
if (EnchantmentHelper.getEnchantmentLevel(Enchantment.flame.effectId, this.getHeldItem()) > 0 || this.getSkeletonType() == 1)
{
entityarrow.setFire(100);
}
this.playSound("random.bow", 1.0F, 1.0F / (this.getRNG().nextFloat() * 0.4F + 0.8F));
this.worldObj.spawnEntityInWorld(entityarrow);
}
示例3: getBestSlotMining
import net.minecraft.enchantment.EnchantmentHelper; //导入方法依赖的package包/类
private int getBestSlotMining(Block block) {
int bestSlot = -1;
float bestHardness = 1F;
for (int index = 36; index < 45; index++) {
ItemStack stack = mc.thePlayer.inventoryContainer.getSlot(index).getStack();
if (stack != null) {
float str = stack.getStrVsBlock(block);
if (str > 1F) {
int efficiencyLevel = EnchantmentHelper.getEnchantmentLevel(Enchantment.efficiency.effectId, stack);
str += (efficiencyLevel * efficiencyLevel + 1);
}
if (str > bestHardness) {
bestHardness = str;
bestSlot = index;
}
}
}
return bestSlot;
}
示例4: onPlayerInteractXP
import net.minecraft.enchantment.EnchantmentHelper; //导入方法依赖的package包/类
@SubscribeEvent
public void onPlayerInteractXP(PlayerPickupXpEvent event)
{
if (!EnchantmentHelper.getEnchantedItem(Enchantments.MENDING, event.getEntityPlayer()).isEmpty())
return;
HarshenItemStackHandler handler = HarshenUtils.getHandler(event.getEntityPlayer());
for(int o = 0; o < handler.getSlots(); o++)
if(handler.getStackInSlot(o).isItemDamaged() && EnchantmentHelper.getEnchantmentLevel(Enchantments.MENDING, handler.getStackInSlot(o)) > 0)
{
int i = Math.min(event.getOrb().xpValue * 2, (handler.getStackInSlot(o).getItemDamage()));
event.getOrb().xpValue -= i / 2;
HarshenUtils.damageFirstOccuringItem(event.getEntityPlayer(), handler.getStackInSlot(o).getItem(), - i);
break;
}
}
示例5: harvestBlock
import net.minecraft.enchantment.EnchantmentHelper; //导入方法依赖的package包/类
public void harvestBlock(World worldIn, EntityPlayer player, BlockPos pos, IBlockState state, @Nullable TileEntity te, ItemStack stack)
{
player.addStat(StatList.getBlockStats(this));
player.addExhaustion(0.005F);
if (this.canSilkHarvest() && EnchantmentHelper.getEnchantmentLevel(Enchantments.SILK_TOUCH, stack) > 0)
{
spawnAsEntity(worldIn, pos, this.getSilkTouchDrop(state));
}
else
{
if (worldIn.provider.doesWaterVaporize())
{
worldIn.setBlockToAir(pos);
return;
}
int i = EnchantmentHelper.getEnchantmentLevel(Enchantments.FORTUNE, stack);
this.dropBlockAsItem(worldIn, pos, state, i);
Material material = worldIn.getBlockState(pos.down()).getMaterial();
if (material.blocksMovement() || material.isLiquid())
{
worldIn.setBlockState(pos, Blocks.FLOWING_WATER.getDefaultState());
}
}
}
示例6: getScale
import net.minecraft.enchantment.EnchantmentHelper; //导入方法依赖的package包/类
public float getScale(ItemStack stack) {
float base = 1;
if (this.getType(stack) == 0)
base = 0.6f;
if (this.getType(stack) == 4)
base = 0.3f;
if (this.getType(stack) == 5)
base = 0.15f;
else if (this.getType(stack) == 2 || this.getType(stack) == 3)
base = 0.4f;
return base * (1 + EnchantmentHelper.getEnchantmentLevel(BlockLauncher.enchShrink, stack) * 0.33f);
}
示例7: attemptDamageItem
import net.minecraft.enchantment.EnchantmentHelper; //导入方法依赖的package包/类
/**
* Attempts to damage the ItemStack with par1 amount of damage, If the ItemStack has the Unbreaking enchantment
* there is a chance for each point of damage to be negated. Returns true if it takes more damage than
* getMaxDamage(). Returns false otherwise or if the ItemStack can't be damaged or if all points of damage are
* negated.
*/
public boolean attemptDamageItem(int amount, Random rand)
{
if (!this.isItemStackDamageable())
{
return false;
}
else
{
if (amount > 0)
{
int i = EnchantmentHelper.getEnchantmentLevel(Enchantment.unbreaking.effectId, this);
int j = 0;
for (int k = 0; i > 0 && k < amount; ++k)
{
if (EnchantmentDurability.negateDamage(this, i, rand))
{
++j;
}
}
amount -= j;
if (amount <= 0)
{
return false;
}
}
this.itemDamage += amount;
return this.itemDamage > this.getMaxDamage();
}
}
示例8: harvestBlock
import net.minecraft.enchantment.EnchantmentHelper; //导入方法依赖的package包/类
public void harvestBlock(World worldIn, EntityPlayer player, BlockPos pos, IBlockState state, @Nullable TileEntity te, @Nullable ItemStack stack)
{
player.addStat(StatList.getBlockStats(this));
player.addExhaustion(0.025F);
if (this.canSilkHarvest(worldIn, pos, state, player) && EnchantmentHelper.getEnchantmentLevel(Enchantments.SILK_TOUCH, stack) > 0)
{
java.util.List<ItemStack> items = new java.util.ArrayList<ItemStack>();
ItemStack itemstack = this.createStackedBlock(state);
if (itemstack != null)
{
items.add(itemstack);
}
net.minecraftforge.event.ForgeEventFactory.fireBlockHarvesting(items, worldIn, pos, state, 0, 1.0f, true, player);
for (ItemStack item : items)
{
spawnAsEntity(worldIn, pos, item);
}
}
else
{
harvesters.set(player);
int i = EnchantmentHelper.getEnchantmentLevel(Enchantments.FORTUNE, stack);
this.dropBlockAsItem(worldIn, pos, state, i);
harvesters.set(null);
}
}
示例9: onBlockActivated
import net.minecraft.enchantment.EnchantmentHelper; //导入方法依赖的package包/类
@Override
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, @Nullable ItemStack stack, EnumFacing side, float hitX, float hitY, float hitZ) {
if (clickHarvest && !world.isRemote) {
if (player.getHeldItemMainhand() != null) return false;
if (getAge(state) >= getMaxAge()) {
world.setBlockState(pos, this.withAge(0), 3);
int fortune = EnchantmentHelper.getEnchantmentLevel(Enchantments.FORTUNE, player.getHeldItemMainhand());
this.dropBlockAsItem(world, pos, state, fortune);
return true;
}
}
return false;
}
示例10: getMaxEnergyStored
import net.minecraft.enchantment.EnchantmentHelper; //导入方法依赖的package包/类
@Override
public int getMaxEnergyStored(ItemStack stack) {
if (!typeMap.containsKey(ItemHelper.getItemDamage(stack))) {
return 0;
}
int capacity = typeMap.get(ItemHelper.getItemDamage(stack)).capacity;
int enchant = EnchantmentHelper.getEnchantmentLevel(CoreEnchantments.holding, stack);
return capacity + capacity * enchant / 2;
}
示例11: harvestBlock
import net.minecraft.enchantment.EnchantmentHelper; //导入方法依赖的package包/类
public void harvestBlock(World worldIn, EntityPlayer player, BlockPos pos, IBlockState state, @Nullable TileEntity te, ItemStack stack)
{
if (te instanceof IWorldNameable && ((IWorldNameable)te).hasCustomName())
{
player.addStat(StatList.getBlockStats(this));
player.addExhaustion(0.005F);
if (worldIn.isRemote)
{
return;
}
int i = EnchantmentHelper.getEnchantmentLevel(Enchantments.FORTUNE, stack);
Item item = this.getItemDropped(state, worldIn.rand, i);
if (item == Items.field_190931_a)
{
return;
}
ItemStack itemstack = new ItemStack(item, this.quantityDropped(worldIn.rand));
itemstack.setStackDisplayName(((IWorldNameable)te).getName());
spawnAsEntity(worldIn, pos, itemstack);
}
else
{
super.harvestBlock(worldIn, player, pos, state, (TileEntity)null, stack);
}
}
示例12: canPlayerSilkHarvestChest
import net.minecraft.enchantment.EnchantmentHelper; //导入方法依赖的package包/类
public static boolean canPlayerSilkHarvestChest(TileEntity te, EntityPlayer player) {
if (!Mods.IRONCHESTS.isLoaded()) {
return false;
}
BlockPos pos = te.getPos();
Block block = te.getWorld() == null ? null : te.getWorld().getBlockState(pos).getBlock();
return te != null && block != null && isIronChest(block) && player != null && player.getHeldItemMainhand() != null && EnchantmentHelper.getEnchantmentLevel(Enchantments.SILK_TOUCH, player.getHeldItemMainhand()) > 0 && !player.isCreative();
}
示例13: onPlayerPickupXP
import net.minecraft.enchantment.EnchantmentHelper; //导入方法依赖的package包/类
public static void onPlayerPickupXP(PlayerPickupXpEvent event) {
EntityPlayer player = event.entityPlayer;
EntityXPOrb orb = event.orb;
if (player.worldObj.isRemote)
return;
if (!EtFuturum.enableMending)
return;
ItemStack[] stacks = new ItemStack[5];
stacks[0] = player.getCurrentEquippedItem(); // held
stacks[1] = player.getEquipmentInSlot(1); // boots
stacks[2] = player.getEquipmentInSlot(2); // leggings
stacks[3] = player.getEquipmentInSlot(3); // chestplate
stacks[4] = player.getEquipmentInSlot(4); // helmet
for (ItemStack stack : stacks)
if (stack != null && stack.getItemDamage() > 0 && EnchantmentHelper.getEnchantmentLevel(mending.effectId, stack) > 0) {
int xp = orb.xpValue;
while (xp > 0 && stack.getItemDamage() > 0) {
stack.setItemDamage(stack.getItemDamage() - 2);
xp--;
}
if (xp <= 0) {
orb.setDead();
event.setCanceled(true);
return;
}
}
}
示例14: isSlotAllowed
import net.minecraft.enchantment.EnchantmentHelper; //导入方法依赖的package包/类
public static boolean isSlotAllowed(ItemStack stack, EnumInventorySlots slotIn, EnumInventorySlots askingSlot)
{
return slotIn.isAllowed(askingSlot) || EnchantmentHelper.getEnchantmentLevel(HarshenEnchantmetns.MIXUP, stack) > 0;
}
示例15: getEnchantmentLevel
import net.minecraft.enchantment.EnchantmentHelper; //导入方法依赖的package包/类
public static int getEnchantmentLevel(int enchantID, IItemStack stack) {
return EnchantmentHelper.getEnchantmentLevel(Enchantment.getEnchantmentByID(16), stack.getStack());
}