diff --git a/changelog.txt b/changelog.txt index 746a5724..62fd0bc6 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,3 +1,10 @@ +------------------------------------------------------ +Version 2.0.0-17 +------------------------------------------------------ +- Added Living Armour Upgrades + - Solar Powered + - Grim Reaper's Sprint + ------------------------------------------------------ Version 2.0.0-16 ------------------------------------------------------ diff --git a/src/main/java/WayofTime/bloodmagic/api/livingArmour/LivingArmourUpgrade.java b/src/main/java/WayofTime/bloodmagic/api/livingArmour/LivingArmourUpgrade.java index 79c0ba83..587a22d1 100644 --- a/src/main/java/WayofTime/bloodmagic/api/livingArmour/LivingArmourUpgrade.java +++ b/src/main/java/WayofTime/bloodmagic/api/livingArmour/LivingArmourUpgrade.java @@ -1,5 +1,6 @@ package WayofTime.bloodmagic.api.livingArmour; +import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.ai.attributes.AttributeModifier; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.nbt.NBTTagCompound; @@ -39,7 +40,7 @@ public abstract class LivingArmourUpgrade * * @return 0 for no damage blocked, 1 for full damage blocked */ - public double getArmourProtection(DamageSource source) + public double getArmourProtection(EntityLivingBase wearer, DamageSource source) { return 0; } diff --git a/src/main/java/WayofTime/bloodmagic/item/armour/ItemLivingArmour.java b/src/main/java/WayofTime/bloodmagic/item/armour/ItemLivingArmour.java index 69a1f34a..03af02aa 100644 --- a/src/main/java/WayofTime/bloodmagic/item/armour/ItemLivingArmour.java +++ b/src/main/java/WayofTime/bloodmagic/item/armour/ItemLivingArmour.java @@ -104,7 +104,7 @@ public class ItemLivingArmour extends ItemArmor implements ISpecialArmor, IRevea for (Entry entry : armour.upgradeMap.entrySet()) { LivingArmourUpgrade upgrade = entry.getValue(); - remainder *= (1 - upgrade.getArmourProtection(source)); + remainder *= (1 - upgrade.getArmourProtection(player, source)); /* * Just as a side note, if one upgrade provides * upgrade.getArmourProtection(source) = 0.5, the @@ -320,7 +320,8 @@ public class ItemLivingArmour extends ItemArmor implements ISpecialArmor, IRevea } @Override - public boolean showIngamePopups(ItemStack stack, EntityLivingBase entityLivingBase) { + public boolean showIngamePopups(ItemStack stack, EntityLivingBase entityLivingBase) + { stack = NBTHelper.checkNBT(stack); LivingArmour armor = getLivingArmour(stack); diff --git a/src/main/java/WayofTime/bloodmagic/livingArmour/tracker/StatTrackerGrimReaperSprint.java b/src/main/java/WayofTime/bloodmagic/livingArmour/tracker/StatTrackerGrimReaperSprint.java index 48669e11..e249c0f6 100644 --- a/src/main/java/WayofTime/bloodmagic/livingArmour/tracker/StatTrackerGrimReaperSprint.java +++ b/src/main/java/WayofTime/bloodmagic/livingArmour/tracker/StatTrackerGrimReaperSprint.java @@ -18,7 +18,7 @@ public class StatTrackerGrimReaperSprint extends StatTracker public int totalDeaths = 0; public static HashMap changeMap = new HashMap(); - public static int[] deathsRequired = new int[] { 3, 5, 6, 7, 8, 9, 10, 11, 12, 13 }; //TODO: Modify + public static int[] deathsRequired = new int[] { 6, 10, 15, 25, 50, 70, 90, 120, 150, 200 }; //TODO: Modify public static void incrementCounter(LivingArmour armour) { diff --git a/src/main/java/WayofTime/bloodmagic/livingArmour/tracker/StatTrackerSolarPowered.java b/src/main/java/WayofTime/bloodmagic/livingArmour/tracker/StatTrackerSolarPowered.java new file mode 100644 index 00000000..be801474 --- /dev/null +++ b/src/main/java/WayofTime/bloodmagic/livingArmour/tracker/StatTrackerSolarPowered.java @@ -0,0 +1,88 @@ +package WayofTime.bloodmagic.livingArmour.tracker; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.world.World; +import WayofTime.bloodmagic.api.Constants; +import WayofTime.bloodmagic.api.livingArmour.LivingArmourUpgrade; +import WayofTime.bloodmagic.api.livingArmour.StatTracker; +import WayofTime.bloodmagic.livingArmour.LivingArmour; +import WayofTime.bloodmagic.livingArmour.upgrade.LivingArmourUpgradeSolarPowered; + +public class StatTrackerSolarPowered extends StatTracker +{ + public double totalHealthGenned = 0; + + public static HashMap changeMap = new HashMap(); + public static int[] healthedRequired = new int[] { 70, 150, 300, 500, 700, 1400, 2400, 4000, 7000, 9000 }; + + public static void incrementCounter(LivingArmour armour, double health) + { + changeMap.put(armour, changeMap.containsKey(armour) ? changeMap.get(armour) + health : health); + } + + @Override + public String getUniqueIdentifier() + { + return Constants.Mod.MODID + ".tracker.solarPowered"; + } + + @Override + public void resetTracker() + { + this.totalHealthGenned = 0; + } + + @Override + public void readFromNBT(NBTTagCompound tag) + { + totalHealthGenned = tag.getDouble(Constants.Mod.MODID + ".tracker.solarPowered"); + } + + @Override + public void writeToNBT(NBTTagCompound tag) + { + tag.setDouble(Constants.Mod.MODID + ".tracker.solarPowered", totalHealthGenned); + } + + @Override + public boolean onTick(World world, EntityPlayer player, LivingArmour livingArmour) + { + if (changeMap.containsKey(livingArmour)) + { + double change = Math.abs(changeMap.get(livingArmour)); + if (change > 0) + { + totalHealthGenned += Math.abs(changeMap.get(livingArmour)); + + changeMap.put(livingArmour, 0d); + + this.markDirty(); + + return true; + } + } + + return false; + } + + @Override + public List getUpgrades() + { + List upgradeList = new ArrayList(); + + for (int i = 0; i < 10; i++) + { + if (totalHealthGenned >= healthedRequired[i]) + { + upgradeList.add(new LivingArmourUpgradeSolarPowered(i)); + } + } + + return upgradeList; + } +} diff --git a/src/main/java/WayofTime/bloodmagic/livingArmour/upgrade/LivingArmourUpgradeGrimReaperSprint.java b/src/main/java/WayofTime/bloodmagic/livingArmour/upgrade/LivingArmourUpgradeGrimReaperSprint.java index 0b3a055f..33cea2ef 100644 --- a/src/main/java/WayofTime/bloodmagic/livingArmour/upgrade/LivingArmourUpgradeGrimReaperSprint.java +++ b/src/main/java/WayofTime/bloodmagic/livingArmour/upgrade/LivingArmourUpgradeGrimReaperSprint.java @@ -12,7 +12,7 @@ import WayofTime.bloodmagic.util.helper.TextHelper; public class LivingArmourUpgradeGrimReaperSprint extends LivingArmourUpgrade { public static final int[] costs = new int[] { 20, 50, 130, 270, 450, 580, 700, 800, 900, 1000 }; - public static final int[] rebirthDelay = new int[] { 20 * 60 * 60, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; + public static final int[] rebirthDelay = new int[] { 20 * 60 * 60, 20 * 60 * 50, 20 * 60 * 45, 20 * 60 * 40, 20 * 60 * 30, 20 * 60 * 25, 20 * 60 * 15, 20 * 60 * 10, 20 * 60 * 5, 20 * 60 }; public int deathTimer = 0; diff --git a/src/main/java/WayofTime/bloodmagic/livingArmour/upgrade/LivingArmourUpgradePhysicalProtect.java b/src/main/java/WayofTime/bloodmagic/livingArmour/upgrade/LivingArmourUpgradePhysicalProtect.java index 787d63c3..2444031b 100644 --- a/src/main/java/WayofTime/bloodmagic/livingArmour/upgrade/LivingArmourUpgradePhysicalProtect.java +++ b/src/main/java/WayofTime/bloodmagic/livingArmour/upgrade/LivingArmourUpgradePhysicalProtect.java @@ -1,5 +1,6 @@ package WayofTime.bloodmagic.livingArmour.upgrade; +import net.minecraft.entity.EntityLivingBase; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.DamageSource; import WayofTime.bloodmagic.api.Constants; @@ -15,7 +16,8 @@ public class LivingArmourUpgradePhysicalProtect extends LivingArmourUpgrade super(level); } - public double getArmourProtection(DamageSource source) + @Override + public double getArmourProtection(EntityLivingBase wearer, DamageSource source) { if (source.getEntity() != null) { diff --git a/src/main/java/WayofTime/bloodmagic/livingArmour/upgrade/LivingArmourUpgradeSolarPowered.java b/src/main/java/WayofTime/bloodmagic/livingArmour/upgrade/LivingArmourUpgradeSolarPowered.java new file mode 100644 index 00000000..c291f849 --- /dev/null +++ b/src/main/java/WayofTime/bloodmagic/livingArmour/upgrade/LivingArmourUpgradeSolarPowered.java @@ -0,0 +1,93 @@ +package WayofTime.bloodmagic.livingArmour.upgrade; + +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.potion.Potion; +import net.minecraft.potion.PotionEffect; +import net.minecraft.util.DamageSource; +import net.minecraft.world.World; +import WayofTime.bloodmagic.api.Constants; +import WayofTime.bloodmagic.api.livingArmour.ILivingArmour; +import WayofTime.bloodmagic.api.livingArmour.LivingArmourUpgrade; + +public class LivingArmourUpgradeSolarPowered extends LivingArmourUpgrade +{ + public static final int[] costs = new int[] { 5, 12, 20, 35, 49, 78, 110, 160, 215, 320 }; + public static final int[] regenCooldown = new int[] { 200, 180, 160, 120, 100, 80, 40, 20, 10, 10 }; + public static final int[] fireResistCooldown = new int[] { 1, 1, 60 * 60, 50 * 60, 40 * 60, 35 * 60, 30 * 60, 25 * 60, 20 * 60, 10 * 60 }; + public static final int[] fireResistTime = new int[] { 0, 0, 15 * 60, 20 * 60, 30 * 60, 35 * 60, 40 * 60, 50 * 60, 60 * 60, 100 * 60 }; + public static final double[] protectionLevel = new double[] { 0.02, 0.04, 0.06, 0.08, 0.10, 0.13, 0.16, 0.19, 0.22, 0.25 }; + + public int counter = 0; + + public LivingArmourUpgradeSolarPowered(int level) + { + super(level); + } + + @Override + public double getArmourProtection(EntityLivingBase wearer, DamageSource source) + { + if (wearer.worldObj.canSeeSky(wearer.getPosition()) || wearer.worldObj.provider.isDaytime()) + { + return protectionLevel[this.level]; + } + + return 0; + } + + @Override + public void onTick(World world, EntityPlayer player, ILivingArmour livingArmour) + { + counter++; + if (world.canSeeSky(player.getPosition()) || world.provider.isDaytime()) + { + if (counter % regenCooldown[this.level] == 0 && player.getHealth() < player.getMaxHealth()) + { + player.heal(1); + } + + if (fireResistTime[this.level] != 0 && counter % fireResistCooldown[this.level] == 0) + { + player.addPotionEffect(new PotionEffect(Potion.fireResistance.id, fireResistTime[this.level], 0, false, false)); + } + } + } + + @Override + public String getUniqueIdentifier() + { + return Constants.Mod.MODID + ".upgrade.solarPowered"; + } + + @Override + public int getMaxTier() + { + return 10; // Set to here until I can add more upgrades to it. + } + + @Override + public int getCostOfUpgrade() + { + return costs[this.level]; + } + + @Override + public void writeToNBT(NBTTagCompound tag) + { + tag.setInteger(Constants.Mod.MODID + ".tracker.solarPowered", counter); + } + + @Override + public void readFromNBT(NBTTagCompound tag) + { + counter = tag.getInteger(Constants.Mod.MODID + ".tracker.solarPowered"); + } + + @Override + public String getUnlocalizedName() + { + return tooltipBase + "solarPowered"; + } +} \ No newline at end of file diff --git a/src/main/java/WayofTime/bloodmagic/registry/ModArmourTrackers.java b/src/main/java/WayofTime/bloodmagic/registry/ModArmourTrackers.java index a3971dff..ada009ec 100644 --- a/src/main/java/WayofTime/bloodmagic/registry/ModArmourTrackers.java +++ b/src/main/java/WayofTime/bloodmagic/registry/ModArmourTrackers.java @@ -11,7 +11,20 @@ import WayofTime.bloodmagic.livingArmour.tracker.StatTrackerMovement; import WayofTime.bloodmagic.livingArmour.tracker.StatTrackerPhysicalProtect; import WayofTime.bloodmagic.livingArmour.tracker.StatTrackerPoison; import WayofTime.bloodmagic.livingArmour.tracker.StatTrackerSelfSacrifice; -import WayofTime.bloodmagic.livingArmour.upgrade.*; +import WayofTime.bloodmagic.livingArmour.tracker.StatTrackerSolarPowered; +import WayofTime.bloodmagic.livingArmour.upgrade.LivingArmourUpgradeArrowShot; +import WayofTime.bloodmagic.livingArmour.upgrade.LivingArmourUpgradeDigging; +import WayofTime.bloodmagic.livingArmour.upgrade.LivingArmourUpgradeGrimReaperSprint; +import WayofTime.bloodmagic.livingArmour.upgrade.LivingArmourUpgradeHealthboost; +import WayofTime.bloodmagic.livingArmour.upgrade.LivingArmourUpgradeKnockbackResist; +import WayofTime.bloodmagic.livingArmour.upgrade.LivingArmourUpgradeMeleeDamage; +import WayofTime.bloodmagic.livingArmour.upgrade.LivingArmourUpgradePhysicalProtect; +import WayofTime.bloodmagic.livingArmour.upgrade.LivingArmourUpgradePoisonResist; +import WayofTime.bloodmagic.livingArmour.upgrade.LivingArmourUpgradeRevealing; +import WayofTime.bloodmagic.livingArmour.upgrade.LivingArmourUpgradeSelfSacrifice; +import WayofTime.bloodmagic.livingArmour.upgrade.LivingArmourUpgradeSolarPowered; +import WayofTime.bloodmagic.livingArmour.upgrade.LivingArmourUpgradeSpeed; +import WayofTime.bloodmagic.livingArmour.upgrade.LivingArmourUpgradeStepAssist; public class ModArmourTrackers { @@ -27,6 +40,7 @@ public class ModArmourTrackers LivingArmourHandler.registerStatTracker(StatTrackerMeleeDamage.class); LivingArmourHandler.registerStatTracker(StatTrackerArrowShot.class); LivingArmourHandler.registerStatTracker(StatTrackerGrimReaperSprint.class); + LivingArmourHandler.registerStatTracker(StatTrackerSolarPowered.class); LivingArmourHandler.registerArmourUpgrade(new LivingArmourUpgradeSpeed(0)); LivingArmourHandler.registerArmourUpgrade(new LivingArmourUpgradeDigging(0)); @@ -40,5 +54,6 @@ public class ModArmourTrackers LivingArmourHandler.registerArmourUpgrade(new LivingArmourUpgradeStepAssist(0)); LivingArmourHandler.registerArmourUpgrade(new LivingArmourUpgradeGrimReaperSprint(0)); LivingArmourHandler.registerArmourUpgrade(new LivingArmourUpgradeRevealing(0)); + LivingArmourHandler.registerArmourUpgrade(new LivingArmourUpgradeSolarPowered(0)); } } diff --git a/src/main/java/WayofTime/bloodmagic/util/handler/EventHandler.java b/src/main/java/WayofTime/bloodmagic/util/handler/EventHandler.java index 0f36532d..0c9b5a11 100644 --- a/src/main/java/WayofTime/bloodmagic/util/handler/EventHandler.java +++ b/src/main/java/WayofTime/bloodmagic/util/handler/EventHandler.java @@ -3,8 +3,6 @@ package WayofTime.bloodmagic.util.handler; import java.util.List; import java.util.Random; -import WayofTime.bloodmagic.api.livingArmour.LivingArmourHandler; -import WayofTime.bloodmagic.item.ItemUpgradeTome; import net.minecraft.block.Block; import net.minecraft.enchantment.Enchantment; import net.minecraft.enchantment.EnchantmentHelper; @@ -56,6 +54,7 @@ import WayofTime.bloodmagic.api.util.helper.PlayerHelper; import WayofTime.bloodmagic.block.BlockAltar; import WayofTime.bloodmagic.entity.projectile.EntitySentientArrow; import WayofTime.bloodmagic.item.ItemAltarMaker; +import WayofTime.bloodmagic.item.ItemUpgradeTome; import WayofTime.bloodmagic.item.armour.ItemLivingArmour; import WayofTime.bloodmagic.item.gear.ItemPackSacrifice; import WayofTime.bloodmagic.livingArmour.LivingArmour; @@ -66,6 +65,7 @@ import WayofTime.bloodmagic.livingArmour.tracker.StatTrackerHealthboost; import WayofTime.bloodmagic.livingArmour.tracker.StatTrackerMeleeDamage; import WayofTime.bloodmagic.livingArmour.tracker.StatTrackerPhysicalProtect; import WayofTime.bloodmagic.livingArmour.tracker.StatTrackerSelfSacrifice; +import WayofTime.bloodmagic.livingArmour.tracker.StatTrackerSolarPowered; import WayofTime.bloodmagic.livingArmour.upgrade.LivingArmourUpgradeArrowShot; import WayofTime.bloodmagic.livingArmour.upgrade.LivingArmourUpgradeDigging; import WayofTime.bloodmagic.livingArmour.upgrade.LivingArmourUpgradeGrimReaperSprint; @@ -343,7 +343,13 @@ public class EventHandler ItemStack chestStack = player.getCurrentArmor(2); LivingArmour armour = ItemLivingArmour.armourMap.get(chestStack); if (armour != null) + { StatTrackerHealthboost.incrementCounter(armour, event.amount); + if (player.worldObj.canSeeSky(player.getPosition()) && player.worldObj.provider.isDaytime()) + { + StatTrackerSolarPowered.incrementCounter(armour, event.amount); + } + } } } diff --git a/src/main/resources/assets/bloodmagic/lang/en_US.lang b/src/main/resources/assets/bloodmagic/lang/en_US.lang index de59a552..dcdb2d00 100644 --- a/src/main/resources/assets/bloodmagic/lang/en_US.lang +++ b/src/main/resources/assets/bloodmagic/lang/en_US.lang @@ -282,6 +282,7 @@ tooltip.BloodMagic.livingArmour.upgrade.meleeDamage=Fierce Strike tooltip.BloodMagic.livingArmour.upgrade.arrowShot=Trick Shot tooltip.BloodMagic.livingArmour.upgrade.stepAssist=Step Assist tooltip.BloodMagic.livingArmour.upgrade.grimReaper=Grim Reaper's Sprint +tooltip.BloodMagic.livingArmour.upgrade.grimReaper=Solar Powered tooltip.BloodMagic.livingArmour.upgrade.revealing=Revealing tooltip.BloodMagic.livingArmour.upgrade.level=%s (Level %d)