summaryrefslogtreecommitdiff
path: root/src/main/java/fyresmodjam/blessings/standard/LonerBlessing.java
blob: ac52ec5c3e1354c51e9f0d3733fff6aca5f8beab (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package fyresmodjam.blessings.standard;

import fyresmodjam.blessings.Blessing;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraftforge.event.entity.living.LivingHurtEvent;

public class LonerBlessing extends Blessing {

	@Override
	public String name() {
		return "Loner";
	}

	@Override
	public String description() {
		return "Do higher damage the lower your health is";
	}

	@Override
	public float onOutgoingDamage(LivingHurtEvent event,
			float damageMultiplier) {
		Entity trueSource = event.getSource().getTrueSource();

		if (trueSource instanceof EntityLivingBase) {
			EntityLivingBase livingSource = (EntityLivingBase) trueSource;

			float healthRatio = livingSource.getHealth()
					/ livingSource.getMaxHealth();

			float scaleFactor = 1.0F - healthRatio;

			return damageMultiplier + 0.35F * scaleFactor;
		}

		return damageMultiplier;
	}
}