本文整理匯總了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;
}
示例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;
}
示例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));
}
}
}
}
示例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);
}
示例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;
}
示例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;
}
}
示例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;
}
}
示例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);
}
}
}
示例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);
}
}