summaryrefslogtreecommitdiff
path: root/TF2 Crates/src/main/java/tf2crates/handler/AttackHandler.java
diff options
context:
space:
mode:
authorbculkin2442 <bjculkin@mix.wvu.edu>2018-05-24 15:52:43 -0400
committerbculkin2442 <bjculkin@mix.wvu.edu>2018-05-24 15:52:43 -0400
commita11c98c6cad501e081837ec8fa2e323edaeb1ca3 (patch)
treeab97a3e81bfa3eec2ff530ec55ff4a69e48f49e3 /TF2 Crates/src/main/java/tf2crates/handler/AttackHandler.java
Initial commitmaster
Diffstat (limited to 'TF2 Crates/src/main/java/tf2crates/handler/AttackHandler.java')
-rwxr-xr-xTF2 Crates/src/main/java/tf2crates/handler/AttackHandler.java76
1 files changed, 76 insertions, 0 deletions
diff --git a/TF2 Crates/src/main/java/tf2crates/handler/AttackHandler.java b/TF2 Crates/src/main/java/tf2crates/handler/AttackHandler.java
new file mode 100755
index 0000000..0d6e2ff
--- /dev/null
+++ b/TF2 Crates/src/main/java/tf2crates/handler/AttackHandler.java
@@ -0,0 +1,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;
+ }
+ }
+ }
+} \ No newline at end of file