Java Code Examples for net.minecraftforge.event.entity.living.LivingHurtEvent#setAmount()

The following examples show how to use net.minecraftforge.event.entity.living.LivingHurtEvent#setAmount() . 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 vote down vote up
@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: EssentialsMissingHandler.java    From Cyberware with MIT License 6 votes vote down vote up
@SubscribeEvent
public void handleMissingSkin(LivingHurtEvent event)
{
	EntityLivingBase e = event.getEntityLiving();
	
	if (CyberwareAPI.hasCapability(e))
	{
		ICyberwareUserData cyberware = CyberwareAPI.getCapability(e);
		
		if (!cyberware.hasEssential(EnumSlot.SKIN))
		{
	
			if (!event.getSource().isUnblockable() || event.getSource() == DamageSource.fall)
			{
				event.setAmount(event.getAmount() * 3F);
			}
		}
	}
}
 
Example 3
Source File: ItemBoneUpgrade.java    From Cyberware with MIT License 5 votes vote down vote up
@SubscribeEvent
public void handleFallDamage(LivingHurtEvent event)
{
	EntityLivingBase e = event.getEntityLiving();
	
	if (CyberwareAPI.isCyberwareInstalled(e, new ItemStack(this, 1, 1)))
	{

		if (event.getSource() == DamageSource.fall)
		{
			event.setAmount(event.getAmount() * .3333F);
		}
		
	}
}
 
Example 4
Source File: ItemSwordOfPain.java    From ToroQuest with GNU General Public License v3.0 4 votes vote down vote up
private void alterDamage(LivingHurtEvent event) {
	float amount = event.getAmount();
	event.setAmount(amount * 2);
	event.getSource().getTrueSource().attackEntityFrom(event.getSource(), amount / 2);
}