當前位置: 首頁>>代碼示例>>Java>>正文


Java EnchantmentHelper.getEnchantmentLevel方法代碼示例

本文整理匯總了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;
}
 
開發者ID:rafradek,項目名稱:Mods,代碼行數:20,代碼來源:TNTCannon.java

示例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);
}
 
開發者ID:SkidJava,項目名稱:BaseClient,代碼行數:29,代碼來源:EntitySkeleton.java

示例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;
}
 
開發者ID:SerenityEnterprises,項目名稱:SerenityCE,代碼行數:23,代碼來源:AutoTool.java

示例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;
        	}
}
 
開發者ID:kenijey,項目名稱:harshencastle,代碼行數:16,代碼來源:HandlerHarshenInventory.java

示例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());
        }
    }
}
 
開發者ID:sudofox,項目名稱:Backmemed,代碼行數:28,代碼來源:BlockIce.java

示例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);
}
 
開發者ID:rafradek,項目名稱:Mods,代碼行數:13,代碼來源:TNTCannon.java

示例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();
    }
}
 
開發者ID:Notoh,項目名稱:DecompiledMinecraft,代碼行數:40,代碼來源:ItemStack.java

示例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);
    }
}
 
開發者ID:F1r3w477,項目名稱:CustomWorldGen,代碼行數:30,代碼來源:Block.java

示例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;
}
 
開發者ID:bafomdad,項目名稱:uniquecrops,代碼行數:15,代碼來源:BlockCropsBase.java

示例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;
}
 
開發者ID:ImbaKnugel,項目名稱:Whoosh,代碼行數:12,代碼來源:ItemTransporter.java

示例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);
    }
}
 
開發者ID:sudofox,項目名稱:Backmemed,代碼行數:30,代碼來源:BlockContainer.java

示例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();
}
 
開發者ID:p455w0rd,項目名稱:EndermanEvolution,代碼行數:9,代碼來源:IronChests.java

示例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;
			}
		}
}
 
開發者ID:jm-organization,項目名稱:connor41-etfuturum2,代碼行數:30,代碼來源:ModEnchantments.java

示例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;
}
 
開發者ID:kenijey,項目名稱:harshencastle,代碼行數:5,代碼來源:HarshenUtils.java

示例15: getEnchantmentLevel

import net.minecraft.enchantment.EnchantmentHelper; //導入方法依賴的package包/類
public static int getEnchantmentLevel(int enchantID, IItemStack stack) {
	return EnchantmentHelper.getEnchantmentLevel(Enchantment.getEnchantmentByID(16), stack.getStack());
}
 
開發者ID:Moudoux,項目名稱:EMC,代碼行數:4,代碼來源:IEnchantmentHelper.java


注:本文中的net.minecraft.enchantment.EnchantmentHelper.getEnchantmentLevel方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。