summaryrefslogtreecommitdiff
path: root/YWD/src/main/java/fyresmodjam/blessings/standard/NinjaBlessing.java
blob: b4f66e638190453d3070f122ade95149c1f88eaa (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
39
40
package fyresmodjam.blessings.standard;

import cpw.mods.fml.common.gameevent.TickEvent.ServerTickEvent;
import fyresmodjam.blessings.Blessing;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionEffect;
import net.minecraftforge.event.entity.living.LivingHurtEvent;

public class NinjaBlessing extends StandardBlessing {
	public NinjaBlessing() {
		super("Ninja", false);
	}

	@Override
	public String description() {
		return "- Go invisible while sneaking\n- Attacks on enemies with full health deal 2x damage";
	}

	@Override
	public void commonTick(ServerTickEvent stev, EntityPlayer player) {
		if (player.isSneaking()) {
			PotionEffect e = player.getActivePotionEffect(Potion.invisibility);

			if (e == null || player.getActivePotionEffect(Potion.invisibility).getDuration() < 10) {
				player.addPotionEffect(new PotionEffect(Potion.invisibility.id, 10, 1, false));
			}
		}
	}

	@Override
	public float onOutgoingDamage(LivingHurtEvent event, float damageMultiplier) {
		if (event.entityLiving != null && event.source.getEntity().isSneaking()
				&& event.entityLiving.getHealth() == event.entityLiving.getMaxHealth()) {
			return damageMultiplier + 1.0F;
		}

		return damageMultiplier;
	}
}