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


Java EnchantmentHelper.getEfficiencyModifier方法代碼示例

本文整理匯總了Java中net.minecraft.enchantment.EnchantmentHelper.getEfficiencyModifier方法的典型用法代碼示例。如果您正苦於以下問題:Java EnchantmentHelper.getEfficiencyModifier方法的具體用法?Java EnchantmentHelper.getEfficiencyModifier怎麽用?Java EnchantmentHelper.getEfficiencyModifier使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在net.minecraft.enchantment.EnchantmentHelper的用法示例。


在下文中一共展示了EnchantmentHelper.getEfficiencyModifier方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: func_190777_m

import net.minecraft.enchantment.EnchantmentHelper; //導入方法依賴的package包/類
public void func_190777_m(boolean p_190777_1_)
{
    float f = 0.25F + (float)EnchantmentHelper.getEfficiencyModifier(this) * 0.05F;

    if (p_190777_1_)
    {
        f += 0.75F;
    }

    if (this.rand.nextFloat() < f)
    {
        this.getCooldownTracker().setCooldown(Items.SHIELD, 100);
        this.resetActiveHand();
        this.world.setEntityState(this, (byte)30);
    }
}
 
開發者ID:NSExceptional,項目名稱:Zombe-Modpack,代碼行數:17,代碼來源:EntityPlayer.java

示例2: doAxeStuff

import net.minecraft.enchantment.EnchantmentHelper; //導入方法依賴的package包/類
private void doAxeStuff(EntityLivingBase attacked, EntityLivingBase attacker)
{
    //Copied from EntityMob#attackEntityAsMob() L134-150 START
    if (attacked instanceof EntityPlayer)
    {
        EntityPlayer entityplayer = (EntityPlayer)attacked;
        ItemStack itemstack = attacker.getHeldItemMainhand();
        ItemStack itemstack1 = entityplayer.isHandActive() ? entityplayer.getActiveItemStack() : ItemStack.EMPTY;

        if (!itemstack.isEmpty() && !itemstack1.isEmpty() && itemstack.getItem() instanceof ItemAxe && itemstack1.getItem() == RegisterItems.wickerShield)
        {
            float f1 = 0.25F + (float)EnchantmentHelper.getEfficiencyModifier(attacker) * 0.05F;

            if (attacker.world.rand.nextFloat() < f1)
            {
            entityplayer.getCooldownTracker().setCooldown(RegisterItems.wickerShield, 100);
            attacker.world.setEntityState(entityplayer, (byte) 30);
            }
        }
    }
    //Copied from EntityMob#attackEntityAsMob() L134-150 END
}
 
開發者ID:einsteinsci,項目名稱:BetterBeginningsReborn,代碼行數:23,代碼來源:ItemWickerShield.java

示例3: breakSpeed

import net.minecraft.enchantment.EnchantmentHelper; //導入方法依賴的package包/類
@SubscribeEvent
public void breakSpeed(PlayerEvent.BreakSpeed event){
    // Check if the break speed has been modified due to water
    // prevent the modification if there is lanolin on the tool being used
    // decrement the lanolin when the block is successfully broken
    EntityPlayer player = event.getEntityPlayer();
    IBlockState state = event.getState();
    BlockPos pos = event.getPos();
    if(player.isInsideOfMaterial(Material.WATER)) {
        //Player is inside water, check for lanolin
        if(player.getHeldItemMainhand().hasTagCompound() && player.getHeldItemMainhand().getTagCompound().hasKey("lanolin")){
            // Recalculate ala EntityPlayer.getDigSpeed(), but skip the water portion
            float f = player.inventory.getStrVsBlock(state);

            if (f > 1.0F)
            {
                int i = EnchantmentHelper.getEfficiencyModifier(player);
                ItemStack itemstack = player.getHeldItemMainhand();

                if (i > 0 && !itemstack.isEmpty())
                {
                    f += (float)(i * i + 1);
                }
            }

            if (player.isPotionActive(MobEffects.HASTE))
            {
                f *= 1.0F + (float)(player.getActivePotionEffect(MobEffects.HASTE).getAmplifier() + 1) * 0.2F;
            }

            if (player.isPotionActive(MobEffects.MINING_FATIGUE))
            {
                float f1;

                switch (player.getActivePotionEffect(MobEffects.MINING_FATIGUE).getAmplifier())
                {
                    case 0:
                        f1 = 0.3F;
                        break;
                    case 1:
                        f1 = 0.09F;
                        break;
                    case 2:
                        f1 = 0.0027F;
                        break;
                    case 3:
                    default:
                        f1 = 8.1E-4F;
                }

                f *= f1;
            }
            if(f > event.getNewSpeed()){
                event.setNewSpeed(f < 0 ? 0 : f);
            }
        }
    }
}
 
開發者ID:SirLyle,項目名稱:Lanolin,代碼行數:59,代碼來源:EventHandlerCommon.java

示例4: getToolDigEfficiency

import net.minecraft.enchantment.EnchantmentHelper; //導入方法依賴的package包/類
/**
 * Block hardness will be further counted in net/minecraft/block/Block.getPlayerRelativeBlockHardness
 */
public float getToolDigEfficiency(Block p_180471_1_)
{
    float f = this.inventory.getStrVsBlock(p_180471_1_);

    if (f > 1.0F)
    {
        int i = EnchantmentHelper.getEfficiencyModifier(this);
        ItemStack itemstack = this.inventory.getCurrentItem();

        if (i > 0 && itemstack != null)
        {
            f += (float)(i * i + 1);
        }
    }

    if (this.isPotionActive(Potion.digSpeed))
    {
        f *= 1.0F + (float)(this.getActivePotionEffect(Potion.digSpeed).getAmplifier() + 1) * 0.2F;
    }

    if (this.isPotionActive(Potion.digSlowdown))
    {
        float f1 = 1.0F;

        switch (this.getActivePotionEffect(Potion.digSlowdown).getAmplifier())
        {
            case 0:
                f1 = 0.3F;
                break;

            case 1:
                f1 = 0.09F;
                break;

            case 2:
                f1 = 0.0027F;
                break;

            case 3:
            default:
                f1 = 8.1E-4F;
        }

        f *= f1;
    }

    if (this.isInsideOfMaterial(Material.water) && !EnchantmentHelper.getAquaAffinityModifier(this))
    {
        f /= 5.0F;
    }

    if (!this.onGround)
    {
        f /= 5.0F;
    }

    return f;
}
 
開發者ID:Notoh,項目名稱:DecompiledMinecraft,代碼行數:62,代碼來源:EntityPlayer.java

示例5: getDigSpeed

import net.minecraft.enchantment.EnchantmentHelper; //導入方法依賴的package包/類
public float getDigSpeed(IBlockState state)
{
    float f = this.inventory.getStrVsBlock(state);

    if (f > 1.0F)
    {
        int i = EnchantmentHelper.getEfficiencyModifier(this);
        ItemStack itemstack = this.getHeldItemMainhand();

        if (i > 0 && !itemstack.func_190926_b())
        {
            f += (float)(i * i + 1);
        }
    }

    if (this.isPotionActive(MobEffects.HASTE))
    {
        f *= 1.0F + (float)(this.getActivePotionEffect(MobEffects.HASTE).getAmplifier() + 1) * 0.2F;
    }

    if (this.isPotionActive(MobEffects.MINING_FATIGUE))
    {
        float f1;

        switch (this.getActivePotionEffect(MobEffects.MINING_FATIGUE).getAmplifier())
        {
            case 0:
                f1 = 0.3F;
                break;

            case 1:
                f1 = 0.09F;
                break;

            case 2:
                f1 = 0.0027F;
                break;

            case 3:
            default:
                f1 = 8.1E-4F;
        }

        f *= f1;
    }

    if (this.isInsideOfMaterial(Material.WATER) && !EnchantmentHelper.getAquaAffinityModifier(this))
    {
        f /= 5.0F;
    }

    if (!this.onGround)
    {
        f /= 5.0F;
    }

    return f;
}
 
開發者ID:NSExceptional,項目名稱:Zombe-Modpack,代碼行數:59,代碼來源:EntityPlayer.java

示例6: attackEntityAsMob

import net.minecraft.enchantment.EnchantmentHelper; //導入方法依賴的package包/類
public boolean attackEntityAsMob(Entity entityIn)
{
    float f = (float)this.getEntityAttribute(SharedMonsterAttributes.ATTACK_DAMAGE).getAttributeValue();
    int i = 0;

    if (entityIn instanceof EntityLivingBase)
    {
        f += EnchantmentHelper.getModifierForCreature(this.getHeldItemMainhand(), ((EntityLivingBase)entityIn).getCreatureAttribute());
        i += EnchantmentHelper.getKnockbackModifier(this);
    }

    boolean flag = entityIn.attackEntityFrom(DamageSource.causeMobDamage(this), f);

    if (flag)
    {
        if (i > 0 && entityIn instanceof EntityLivingBase)
        {
            ((EntityLivingBase)entityIn).knockBack(this, (float)i * 0.5F, (double)MathHelper.sin(this.rotationYaw * 0.017453292F), (double)(-MathHelper.cos(this.rotationYaw * 0.017453292F)));
            this.motionX *= 0.6D;
            this.motionZ *= 0.6D;
        }

        int j = EnchantmentHelper.getFireAspectModifier(this);

        if (j > 0)
        {
            entityIn.setFire(j * 4);
        }

        if (entityIn instanceof EntityPlayer)
        {
            EntityPlayer entityplayer = (EntityPlayer)entityIn;
            ItemStack itemstack = this.getHeldItemMainhand();
            ItemStack itemstack1 = entityplayer.isHandActive() ? entityplayer.getActiveItemStack() : ItemStack.field_190927_a;

            if (!itemstack.func_190926_b() && !itemstack1.func_190926_b() && itemstack.getItem() instanceof ItemAxe && itemstack1.getItem() == Items.SHIELD)
            {
                float f1 = 0.25F + (float)EnchantmentHelper.getEfficiencyModifier(this) * 0.05F;

                if (this.rand.nextFloat() < f1)
                {
                    entityplayer.getCooldownTracker().setCooldown(Items.SHIELD, 100);
                    this.world.setEntityState(entityplayer, (byte)30);
                }
            }
        }

        this.applyEnchantments(this, entityIn);
    }

    return flag;
}
 
開發者ID:sudofox,項目名稱:Backmemed,代碼行數:53,代碼來源:EntityMob.java

示例7: attackEntityAsMob

import net.minecraft.enchantment.EnchantmentHelper; //導入方法依賴的package包/類
@Override
public boolean attackEntityAsMob(Entity entityIn) {
	float f = (float) this.getEntityAttribute(SharedMonsterAttributes.ATTACK_DAMAGE).getBaseValue();
	int i = 0;

	if (entityIn instanceof EntityLivingBase) {
		f += EnchantmentHelper.getModifierForCreature(this.getHeldItemMainhand(),
				((EntityLivingBase) entityIn).getCreatureAttribute());
		i += EnchantmentHelper.getKnockbackModifier(this);
	}

	boolean flag = entityIn.attackEntityFrom(DamageSource.causeMobDamage(this), f);

	if (flag) {
		if (i > 0 && entityIn instanceof EntityLivingBase) {
			((EntityLivingBase) entityIn).knockBack(this, i * 0.5F, MathHelper.sin(this.rotationYaw * 0.017453292F),
					(-MathHelper.cos(this.rotationYaw * 0.017453292F)));
			this.motionX *= 0.6D;
			this.motionZ *= 0.6D;
		}

		int j = EnchantmentHelper.getFireAspectModifier(this);

		if (j > 0)
			entityIn.setFire(j * 4);

		if (entityIn instanceof EntityPlayer) {
			EntityPlayer entityplayer = (EntityPlayer) entityIn;
			ItemStack itemstack = this.getHeldItemMainhand();
			ItemStack itemstack1 = entityplayer.isHandActive() ? entityplayer.getActiveItemStack() : null;

			if (!itemstack.isEmpty() && itemstack1 != null && itemstack.getItem() instanceof ItemAxe
					&& itemstack1.getItem() == Items.SHIELD) {
				float f1 = 0.25F + EnchantmentHelper.getEfficiencyModifier(this) * 0.05F;

				if (this.rand.nextFloat() < f1) {
					entityplayer.getCooldownTracker().setCooldown(Items.SHIELD, 100);
					this.world.setEntityState(entityplayer, (byte) 30);
				}
			}
		}

		this.applyEnchantments(this, entityIn);
	}

	return flag;
}
 
開發者ID:rafradek,項目名稱:Mods,代碼行數:48,代碼來源:EntityTF2Character.java

示例8: attackEntityAsMob

import net.minecraft.enchantment.EnchantmentHelper; //導入方法依賴的package包/類
@Override
public boolean attackEntityAsMob(Entity entityIn) {
	float f = (float) this.getEntityAttribute(SharedMonsterAttributes.ATTACK_DAMAGE).getAttributeValue();
	int i = 0;

	if (entityIn instanceof EntityLivingBase) {
		f += EnchantmentHelper.getModifierForCreature(this.getHeldItemMainhand(),
				((EntityLivingBase) entityIn).getCreatureAttribute());
		i += EnchantmentHelper.getKnockbackModifier(this);
	}

	boolean flag = entityIn.attackEntityFrom(DamageSource.causeMobDamage(this), f);

	if (flag) {
		if (i > 0 && entityIn instanceof EntityLivingBase) {
			((EntityLivingBase) entityIn).knockBack(this, i * 0.5F, MathHelper.sin(this.rotationYaw * 0.017453292F),
					(-MathHelper.cos(this.rotationYaw * 0.017453292F)));
			this.motionX *= 0.6D;
			this.motionZ *= 0.6D;
		}

		int j = EnchantmentHelper.getFireAspectModifier(this);

		if (j > 0)
			entityIn.setFire(j * 4);

		if (entityIn instanceof EntityPlayer) {
			EntityPlayer entityplayer = (EntityPlayer) entityIn;
			ItemStack itemstack = this.getHeldItemMainhand();
			ItemStack itemstack1 = entityplayer.isHandActive() ? entityplayer.getActiveItemStack() : null;

			if (!itemstack.isEmpty() && itemstack1 != null && itemstack.getItem() instanceof ItemAxe
					&& itemstack1.getItem() == Items.SHIELD) {
				float f1 = 0.25F + EnchantmentHelper.getEfficiencyModifier(this) * 0.05F;

				if (this.rand.nextFloat() < f1) {
					entityplayer.getCooldownTracker().setCooldown(Items.SHIELD, 100);
					this.world.setEntityState(entityplayer, (byte) 30);
				}
			}
		}

		this.applyEnchantments(this, entityIn);

		if (entityIn instanceof EntityLivingBase && ((EntityLivingBase) entityIn).getHealth() <= 0)
			if (entityIn instanceof EntityBuilding)
				this.playSound(TF2Sounds.MOB_SAXTON_DESTROY, 2.2F, 1f);
			else
				this.playSound(TF2Sounds.MOB_SAXTON_KILL, 2.2F, 1f);
	}

	return flag;
}
 
開發者ID:rafradek,項目名稱:Mods,代碼行數:54,代碼來源:EntitySaxtonHale.java

示例9: getDigSpeed

import net.minecraft.enchantment.EnchantmentHelper; //導入方法依賴的package包/類
public float getDigSpeed(IBlockState state, BlockPos pos)
{
    float f = this.inventory.getStrVsBlock(state);

    if (f > 1.0F)
    {
        int i = EnchantmentHelper.getEfficiencyModifier(this);
        ItemStack itemstack = this.getHeldItemMainhand();

        if (i > 0 && itemstack != null)
        {
            f += (float)(i * i + 1);
        }
    }

    if (this.isPotionActive(MobEffects.HASTE))
    {
        f *= 1.0F + (float)(this.getActivePotionEffect(MobEffects.HASTE).getAmplifier() + 1) * 0.2F;
    }

    if (this.isPotionActive(MobEffects.MINING_FATIGUE))
    {
        float f1;

        switch (this.getActivePotionEffect(MobEffects.MINING_FATIGUE).getAmplifier())
        {
            case 0:
                f1 = 0.3F;
                break;
            case 1:
                f1 = 0.09F;
                break;
            case 2:
                f1 = 0.0027F;
                break;
            case 3:
            default:
                f1 = 8.1E-4F;
        }

        f *= f1;
    }

    if (this.isInsideOfMaterial(Material.WATER) && !EnchantmentHelper.getAquaAffinityModifier(this))
    {
        f /= 5.0F;
    }

    if (!this.onGround)
    {
        f /= 5.0F;
    }

    f = net.minecraftforge.event.ForgeEventFactory.getBreakSpeed(this, state, f, pos);
    return (f < 0 ? 0 : f);
}
 
開發者ID:F1r3w477,項目名稱:CustomWorldGen,代碼行數:57,代碼來源:EntityPlayer.java

示例10: attackEntityAsMob

import net.minecraft.enchantment.EnchantmentHelper; //導入方法依賴的package包/類
public boolean attackEntityAsMob(Entity entityIn)
{
    float f = (float)this.getEntityAttribute(SharedMonsterAttributes.ATTACK_DAMAGE).getAttributeValue();
    int i = 0;

    if (entityIn instanceof EntityLivingBase)
    {
        f += EnchantmentHelper.getModifierForCreature(this.getHeldItemMainhand(), ((EntityLivingBase)entityIn).getCreatureAttribute());
        i += EnchantmentHelper.getKnockbackModifier(this);
    }

    boolean flag = entityIn.attackEntityFrom(DamageSource.causeMobDamage(this), f);

    if (flag)
    {
        if (i > 0 && entityIn instanceof EntityLivingBase)
        {
            ((EntityLivingBase)entityIn).knockBack(this, (float)i * 0.5F, (double)MathHelper.sin(this.rotationYaw * 0.017453292F), (double)(-MathHelper.cos(this.rotationYaw * 0.017453292F)));
            this.motionX *= 0.6D;
            this.motionZ *= 0.6D;
        }

        int j = EnchantmentHelper.getFireAspectModifier(this);

        if (j > 0)
        {
            entityIn.setFire(j * 4);
        }

        if (entityIn instanceof EntityPlayer)
        {
            EntityPlayer entityplayer = (EntityPlayer)entityIn;
            ItemStack itemstack = this.getHeldItemMainhand();
            ItemStack itemstack1 = entityplayer.isHandActive() ? entityplayer.getActiveItemStack() : null;

            if (itemstack != null && itemstack1 != null && itemstack.getItem() instanceof ItemAxe && itemstack1.getItem() == Items.SHIELD)
            {
                float f1 = 0.25F + (float)EnchantmentHelper.getEfficiencyModifier(this) * 0.05F;

                if (this.rand.nextFloat() < f1)
                {
                    entityplayer.getCooldownTracker().setCooldown(Items.SHIELD, 100);
                    this.worldObj.setEntityState(entityplayer, (byte)30);
                }
            }
        }

        this.applyEnchantments(this, entityIn);
    }

    return flag;
}
 
開發者ID:F1r3w477,項目名稱:CustomWorldGen,代碼行數:53,代碼來源:EntityMob.java


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