blob: 5b4f2a55b9db0c22001419c4eac16671bdd726a8 (
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
package fyresmodjam.blessings.marks;
import cpw.mods.fml.common.gameevent.TickEvent.ServerTickEvent;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.world.World;
import net.minecraftforge.event.entity.living.LivingHurtEvent;
public class VampirismMark extends Mark {
public VampirismMark() {
super("Vampirism", false);
}
@Override
public String benefit() {
return "Heal a substantial amount of the damage done to enemies";
}
@Override
public String drawback() {
return "Greatly weakened during the day and ignited in direct sunlight";
}
@Override
public float onIncomingDamage(LivingHurtEvent event, float damageMultiplier) {
Entity targetEntity = event.entity;
if (targetEntity.getBrightness(1.0F) > 0.5F && canSeeTheWorld(targetEntity.worldObj, targetEntity)) {
return damageMultiplier + 0.4F;
}
return damageMultiplier;
}
@Override
public float onOutgoingDamage(LivingHurtEvent event, float damageMultiplier) {
Entity sourceEntity = event.source.getEntity();
if (sourceEntity instanceof EntityLivingBase) {
((EntityLivingBase) sourceEntity).heal((event.ammount * damageMultiplier) * 0.25F);
boolean seeTheSky = canSeeTheWorld(sourceEntity.worldObj, sourceEntity);
if (sourceEntity.getBrightness(1.0F) > 0.5F && seeTheSky) {
return damageMultiplier - 0.4F;
}
}
return damageMultiplier;
}
@Override
public void commonTick(ServerTickEvent stev, EntityPlayer play) {
if (play.getBrightness(1.0f) > 0.5f && canSeeTheWorld(play.worldObj, play) && play.ticksExisted % 20 == 0) {
play.setFire(5);
}
}
private boolean canSeeTheWorld(World wld, Entity ent) {
return wld.canBlockSeeTheSky((int) (ent.posX), (int) (ent.posY), (int) (ent.posZ));
}
}
|