本文整理汇总了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);
}
}