Java Code Examples for net.minecraftforge.event.entity.living.LivingHurtEvent#getAmount()
The following examples show how to use
net.minecraftforge.event.entity.living.LivingHurtEvent#getAmount() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ItemReinforcedDiamondArmor.java From ToroQuest with GNU General Public License v3.0 | 6 votes |
@SubscribeEvent public void postInit(LivingHurtEvent e) { DamageSource source = e.getSource(); Iterable<ItemStack> armorStacks = e.getEntityLiving().getArmorInventoryList(); // boolean hasHeavyArmor = false; float reduction = 0; for (ItemStack armorStack : armorStacks) { if (isHeavyArmor(armorStack)) { if (source.isProjectile() || source.isExplosion()) { reduction += 0.2; } } } if (reduction > 0) { float newDamage = (1 - reduction) * e.getAmount(); System.out.println("Heavy armor reduction: [" + reduction + "] IN[" + e.getAmount() + "] OUT[" + newDamage + "]"); e.setAmount(newDamage); } }
Example 2
Source File: ItemHeartUpgrade.java From Cyberware with MIT License | 6 votes |
@SubscribeEvent(priority = EventPriority.LOWEST) public void handleHurt(LivingHurtEvent event) { EntityLivingBase e = event.getEntityLiving(); if (!event.isCanceled() && CyberwareAPI.isCyberwareInstalled(e, new ItemStack(this, 1, 2))) { float damageAmount = event.getAmount(); DamageSource damageSrc = event.getSource(); damageAmount = applyArmorCalculations(e, damageSrc, damageAmount); damageAmount = applyPotionDamageCalculations(e, damageSrc, damageAmount); damageAmount = Math.max(damageAmount - e.getAbsorptionAmount(), 0.0F); damageMedkit.put(e.getEntityId(), damageAmount); timesMedkit.put(e.getEntityId(), e.ticksExisted); } }
Example 3
Source File: EntityEvents.java From patchwork-api with GNU Lesser General Public License v2.1 | 4 votes |
public static float onLivingHurt(LivingEntity entity, DamageSource src, float damage) { LivingHurtEvent event = new LivingHurtEvent(entity, src, damage); return MinecraftForge.EVENT_BUS.post(event) ? 0 : event.getAmount(); }
Example 4
Source File: ItemSwordOfPain.java From ToroQuest with GNU General Public License v3.0 | 4 votes |
private void alterDamage(LivingHurtEvent event) { float amount = event.getAmount(); event.setAmount(amount * 2); event.getSource().getTrueSource().attackEntityFrom(event.getSource(), amount / 2); }