blob: 0d6e2ffb7fe1f07f4d21fceed275f3d7f13517ab (
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
64
65
66
67
68
69
70
71
72
73
74
75
76
|
package tf2crates.handler;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraftforge.event.entity.living.LivingHurtEvent;
import tf2crates.ReferenceTC;
import tf2crates.ServerProxyTC;
import tlhpoeCore.network.MessagePlaySound;
public class AttackHandler {
public static double marketGardenerMinimumFall;
@SubscribeEvent
public void attackHandler(LivingHurtEvent event) {
Entity attackerE = event.source.getEntity();
if (attackerE != null && attackerE instanceof EntityLivingBase) {
EntityLivingBase attacker = (EntityLivingBase) attackerE;
ItemStack heldItem = attacker.getHeldItem();
if (heldItem != null && heldItem.getItem() != null) {
Item item = heldItem.getItem();
boolean playSound = false;
if (item == ServerProxyTC.equalizer) {
float per =
attacker.getHealth() / attacker.getMaxHealth();
if (per <= 0.25F) {
event.ammount += 8;
} else if (per <= 0.5F) {
event.ammount += 4;
} else if (per <= 0.75F) {
event.ammount += 2;
}
} else if (item == ServerProxyTC.marketGardener) {
if (attacker.fallDistance >= marketGardenerMinimumFall) {
event.ammount += 15;
playSound = true;
}
} else if (item == ServerProxyTC.axtinguisher) {
if (event.entityLiving.isBurning()) {
event.ammount += 8;
playSound = true;
}
} else if (item == ServerProxyTC.sharpenedVolcanoFragment) {
event.entityLiving.setFire(10);
}
if (playSound && attacker instanceof EntityPlayerMP) {
new MessagePlaySound(
ReferenceTC.ID + ":tf2crates.crit")
.sendTo((EntityPlayerMP) attacker);
}
}
}
ItemStack heldItem = event.entityLiving.getHeldItem();
if (heldItem != null && heldItem.getItem() != null) {
Item item = heldItem.getItem();
if (item == ServerProxyTC.powerJack) {
event.ammount *= 1.5;
} else if (item == ServerProxyTC.conniversKunai) {
event.ammount *= 2;
}
}
}
}
|