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


Java DamageSource.isUnblockable方法代碼示例

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


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

示例1: attackEntityFrom

import net.minecraft.util.DamageSource; //導入方法依賴的package包/類
@Override
public boolean attackEntityFrom(DamageSource source, float amount) {
	if (isEntityInvulnerable(source)) {
		return false;
	}
	if ((source instanceof EntityDamageSourceIndirect)) {
		for (int i = 0; i < 64; i++) {
		}
		return false;
	}
	boolean flag = super.attackEntityFrom(source, amount);
	if ((source.isUnblockable()) && (rand.nextInt(10) != 0)) {
		teleportRandomly();
	}
	return flag;
}
 
開發者ID:p455w0rd,項目名稱:EndermanEvolution,代碼行數:17,代碼來源:EntityFrienderman.java

示例2: applyArmorCalculations

import net.minecraft.util.DamageSource; //導入方法依賴的package包/類
/**
 * Reduces damage, depending on armor
 */
protected float applyArmorCalculations(DamageSource source, float damage)
{
    if (!source.isUnblockable())
    {
        int i = 25 - this.getTotalArmorValue();
        float f = damage * (float)i;
        this.damageArmor(damage);
        damage = f / 25.0F;
    }

    return damage;
}
 
開發者ID:Notoh,項目名稱:DecompiledMinecraft,代碼行數:16,代碼來源:EntityLivingBase.java

示例3: damageEntity

import net.minecraft.util.DamageSource; //導入方法依賴的package包/類
/**
 * Deals damage to the entity. If its a EntityPlayer then will take damage from the armor first and then health
 * second with the reduced value. Args: damageAmount
 */
protected void damageEntity(DamageSource damageSrc, float damageAmount)
{
    if (!this.isEntityInvulnerable(damageSrc))
    {
        if (!damageSrc.isUnblockable() && this.isBlocking() && damageAmount > 0.0F)
        {
            damageAmount = (1.0F + damageAmount) * 0.5F;
        }

        damageAmount = this.applyArmorCalculations(damageSrc, damageAmount);
        damageAmount = this.applyPotionDamageCalculations(damageSrc, damageAmount);
        float f = damageAmount;
        damageAmount = Math.max(damageAmount - this.getAbsorptionAmount(), 0.0F);
        this.setAbsorptionAmount(this.getAbsorptionAmount() - (f - damageAmount));

        if (damageAmount != 0.0F)
        {
            this.addExhaustion(damageSrc.getHungerDamage());
            float f1 = this.getHealth();
            this.setHealth(this.getHealth() - damageAmount);
            this.getCombatTracker().trackDamage(damageSrc, f1, damageAmount);

            if (damageAmount < 3.4028235E37F)
            {
                this.addStat(StatList.damageTakenStat, Math.round(damageAmount * 10.0F));
            }
        }
    }
}
 
開發者ID:Notoh,項目名稱:DecompiledMinecraft,代碼行數:34,代碼來源:EntityPlayer.java

示例4: getProperties

import net.minecraft.util.DamageSource; //導入方法依賴的package包/類
@Override
public ArmorProperties getProperties(EntityLivingBase player, ItemStack armor, DamageSource source, double damage, int slot) {
	if (source.isUnblockable()) {
		return new ISpecialArmor.ArmorProperties(0, 0.0D, 0);
	}
	double absorptionRatio = getBaseAbsorptionRatio() * getDamageAbsorptionRatio();
	int damageLimit = (int) (25 * itemManager.getEnergy(armor) / getEnergyPerDamage());
	return new ISpecialArmor.ArmorProperties(0, absorptionRatio, damageLimit);
}
 
開發者ID:Kanbe-Kotori,項目名稱:ExtraAcC,代碼行數:10,代碼來源:ItemImagEnergyArmor.java

示例5: applyArmorCalculations

import net.minecraft.util.DamageSource; //導入方法依賴的package包/類
/**
 * Reduces damage, depending on armor
 */
protected float applyArmorCalculations(DamageSource source, float damage)
{
    if (!source.isUnblockable())
    {
        this.damageArmor(damage);
        damage = CombatRules.getDamageAfterAbsorb(damage, (float)this.getTotalArmorValue(), (float)this.getEntityAttribute(SharedMonsterAttributes.ARMOR_TOUGHNESS).getAttributeValue());
    }

    return damage;
}
 
開發者ID:sudofox,項目名稱:Backmemed,代碼行數:14,代碼來源:EntityLivingBase.java

示例6: attackEntityFrom

import net.minecraft.util.DamageSource; //導入方法依賴的package包/類
/**
 * Called when the entity is attacked.
 */
public boolean attackEntityFrom(DamageSource source, float amount)
{
    if (this.isEntityInvulnerable(source))
    {
        return false;
    }
    else if (source instanceof EntityDamageSourceIndirect)
    {
        for (int i = 0; i < 64; ++i)
        {
            if (this.teleportRandomly())
            {
                return true;
            }
        }

        return false;
    }
    else
    {
        boolean flag = super.attackEntityFrom(source, amount);

        if (source.isUnblockable() && this.rand.nextInt(10) != 0)
        {
            this.teleportRandomly();
        }

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

示例7: attackEntityFrom

import net.minecraft.util.DamageSource; //導入方法依賴的package包/類
/**
 * Called when the entity is attacked.
 */
public boolean attackEntityFrom(DamageSource source, float amount)
{
    if (this.isEntityInvulnerable(source))
    {
        return false;
    }
    else
    {
        if (source.getEntity() == null || !(source.getEntity() instanceof EntityEndermite))
        {
            if (!this.worldObj.isRemote)
            {
                this.setScreaming(true);
            }

            if (source instanceof EntityDamageSource && source.getEntity() instanceof EntityPlayer)
            {
                if (source.getEntity() instanceof EntityPlayerMP && ((EntityPlayerMP)source.getEntity()).theItemInWorldManager.isCreative())
                {
                    this.setScreaming(false);
                }
                else
                {
                    this.isAggressive = true;
                }
            }

            if (source instanceof EntityDamageSourceIndirect)
            {
                this.isAggressive = false;

                for (int i = 0; i < 64; ++i)
                {
                    if (this.teleportRandomly())
                    {
                        return true;
                    }
                }

                return false;
            }
        }

        boolean flag = super.attackEntityFrom(source, amount);

        if (source.isUnblockable() && this.rand.nextInt(10) != 0)
        {
            this.teleportRandomly();
        }

        return flag;
    }
}
 
開發者ID:Notoh,項目名稱:DecompiledMinecraft,代碼行數:57,代碼來源:EntityEnderman.java

示例8: damageEntity

import net.minecraft.util.DamageSource; //導入方法依賴的package包/類
@Override
protected void damageEntity(DamageSource dmgSource, float dmg)
   {
	if (this.isEntityInvulnerable()) { return; }	// Nothing to be done here
       
       dmg = ForgeHooks.onLivingHurt(this, dmgSource, dmg);
       if (dmg <= 0) return;
       
       dmg = this.applyArmorCalculations(dmgSource, dmg);
       dmg = this.applyPotionDamageCalculations(dmgSource, dmg);
       
       if (this.hasHeavyPlatingUpgrade)
       {
       	if (!dmgSource.isUnblockable()) { dmg -= this.armorPlatingDmgReduction; }		// If it can be blocked we can defend against it
       	else if (dmgSource.isFireDamage()) { dmg -= this.armorPlatingDmgReduction; }	// Fire is usually unblockable, hm?
       }
       
       if (dmgSource.getDamageType().equals("inWall")) { dmg = 0; }		// Not suffocating in a wall
   	else if (dmgSource.getDamageType().equals("starve")) { dmg = 0; }	// Don't need to eat
       
       if (dmg <= 0) return;
       
       // Damage absorption, if we have it
       float tempDmg = dmg;
       dmg = Math.max(dmg - this.getAbsorptionAmount(), 0.0F);
       this.setAbsorptionAmount(this.getAbsorptionAmount() - (tempDmg - dmg));

       if (dmg != 0.0F)
       {
           float health = this.getHealth();
           this.setHealth(health - dmg);
           this.func_110142_aN().func_94547_a(dmgSource, health, dmg);
           this.setAbsorptionAmount(this.getAbsorptionAmount() - dmg);
       }
       // else, damage is 0. Nothing to be done here
       
       if (!this.worldObj.isRemote && this.getHealth() < this.getMaxHealth() / 3)
       {
       	// Has less than a third health left
       	if (this.hasCommunicationUpgrade && AI_Targeting.isNameOnWhitelist(this, Commands.cmdTellHealth))
       	{
       		AI_Communication.tellOwnerAboutHealth(this);
       	}
       }
   }
 
開發者ID:Domochevsky,項目名稱:minecraft-quiverbow,代碼行數:46,代碼來源:Entity_AA.java

示例9: handleArmorProtection

import net.minecraft.util.DamageSource; //導入方法依賴的package包/類
public static float handleArmorProtection(EntityPlayer player, DamageSource source, float amount, ItemStack armor, BodyPart damaged, EntityEquipmentSlot slotDamaged)
{
	if (source.isUnblockable())
	{
		return amount;
	}
	
	Item armorItem = armor.getItem();
	if (armorItem instanceof ISpecialArmor)
	{
		ISpecialArmor specialArmor = (ISpecialArmor) armorItem;
		float value = ArmorProperties.applyArmor(player, NonNullList.withSize(1, armor), source, amount);
		specialArmor.damageArmor(player, armor, source, (int) amount / 2, slotDamaged.getSlotIndex());
		return value;
	}
	else
	{
		Multimap<String, AttributeModifier> modifiers = armor.getAttributeModifiers(slotDamaged);
		float toughnessMod = 1;
		for (AttributeModifier mod : modifiers.get(SharedMonsterAttributes.ARMOR_TOUGHNESS.getName()))
		{
			if (mod.getOperation() == 0)
			{
				toughnessMod += mod.getAmount();
			}
			else
			{
				toughnessMod *= mod.getAmount();
			}
		}

		if (player instanceof EntityPlayerMP)
		{
			if (armor.attemptDamageItem((int) (amount / 2), player.world.rand, (EntityPlayerMP) player))
			{
				armor.setCount(0);
			}
		}
		
		return amount * (1 / toughnessMod);
	}
}
 
開發者ID:V0idWa1k3r,項目名稱:ExPetrum,代碼行數:43,代碼來源:PlayerManager.java


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