diff --git a/src/main/java/WayofTime/bloodmagic/livingArmour/upgrade/LivingArmourUpgradeFallProtect.java b/src/main/java/WayofTime/bloodmagic/livingArmour/upgrade/LivingArmourUpgradeFallProtect.java index 56971eb9..66b48fdc 100644 --- a/src/main/java/WayofTime/bloodmagic/livingArmour/upgrade/LivingArmourUpgradeFallProtect.java +++ b/src/main/java/WayofTime/bloodmagic/livingArmour/upgrade/LivingArmourUpgradeFallProtect.java @@ -8,19 +8,15 @@ import net.minecraft.util.DamageSource; public class LivingArmourUpgradeFallProtect extends LivingArmourUpgrade { public static final int[] costs = new int[]{2, 5, 9, 15, 25}; - public static final double[] protectionLevel = new double[]{0.2, 0.4, 0.6, 0.8, 1}; + public static final float[] protectionLevel = new float[]{0.2F, 0.4F, 0.6F, 0.8F, 1F}; public LivingArmourUpgradeFallProtect(int level) { super(level); } - @Override - public double getArmourProtection(EntityLivingBase wearer, DamageSource source) { - if (source.equals(DamageSource.FALL)) { - return protectionLevel[this.level]; - } - - return 0; + + public float getDamageMultiplier() { + return 1 - protectionLevel[this.level]; } @Override diff --git a/src/main/java/WayofTime/bloodmagic/util/handler/event/LivingArmourHandler.java b/src/main/java/WayofTime/bloodmagic/util/handler/event/LivingArmourHandler.java index daa87642..81b60284 100644 --- a/src/main/java/WayofTime/bloodmagic/util/handler/event/LivingArmourHandler.java +++ b/src/main/java/WayofTime/bloodmagic/util/handler/event/LivingArmourHandler.java @@ -11,6 +11,7 @@ import WayofTime.bloodmagic.livingArmour.downgrade.LivingArmourUpgradeQuenched; import WayofTime.bloodmagic.livingArmour.downgrade.LivingArmourUpgradeSlowHeal; import WayofTime.bloodmagic.livingArmour.downgrade.LivingArmourUpgradeStormTrooper; import WayofTime.bloodmagic.livingArmour.tracker.StatTrackerArrowShot; +import WayofTime.bloodmagic.livingArmour.tracker.StatTrackerFallProtect; import WayofTime.bloodmagic.livingArmour.tracker.StatTrackerGrimReaperSprint; import WayofTime.bloodmagic.livingArmour.tracker.StatTrackerJump; import WayofTime.bloodmagic.livingArmour.upgrade.*; @@ -32,6 +33,7 @@ import net.minecraftforge.event.entity.EntityJoinWorldEvent; import net.minecraftforge.event.entity.ProjectileImpactEvent; import net.minecraftforge.event.entity.living.LivingDeathEvent; import net.minecraftforge.event.entity.living.LivingEvent; +import net.minecraftforge.event.entity.living.LivingFallEvent; import net.minecraftforge.event.entity.living.LivingHealEvent; import net.minecraftforge.event.entity.player.ArrowLooseEvent; import net.minecraftforge.event.entity.player.PlayerEvent; @@ -374,8 +376,32 @@ public class LivingArmourHandler } } } - } + } + // Applies: Softfall + @SubscribeEvent + public static void onPlayerFall(LivingFallEvent event) { + if (event.getEntityLiving() instanceof EntityPlayer) + { + EntityPlayer player = (EntityPlayer) event.getEntityLiving(); + if (LivingArmour.hasFullSet(player)) + { + + ItemStack chestStack = player.getItemStackFromSlot(EntityEquipmentSlot.CHEST); + LivingArmour armour = ItemLivingArmour.getLivingArmour(chestStack); + if (armour != null) + { + StatTrackerFallProtect.incrementCounter(armour, event.getDamageMultiplier() * (event.getDistance() - 3)); + LivingArmourUpgrade upgrade = ItemLivingArmour.getUpgrade(BloodMagic.MODID + ".upgrade.fallProtect", chestStack); + if (upgrade instanceof LivingArmourUpgradeFallProtect) { + LivingArmourUpgradeFallProtect fallUpgrade = (LivingArmourUpgradeFallProtect) upgrade; + event.setDamageMultiplier(event.getDamageMultiplier() * fallUpgrade.getDamageMultiplier()); + } + } + } + } + } + // Applies: Arrow Shot @SubscribeEvent public static void onProjectileImpact(ProjectileImpactEvent.Arrow event)