Added Soft Fall and Strong Legs living armour upgrades.

This commit is contained in:
WayofTime 2016-04-03 12:17:42 -04:00
parent f9bf63ccf1
commit 96ecd73286
14 changed files with 392 additions and 17 deletions

View file

@ -2,6 +2,9 @@
Version 2.0.0-31 Version 2.0.0-31
------------------------------------------------------ ------------------------------------------------------
- Fixed NPE when using an empty bucket. - Fixed NPE when using an empty bucket.
- Added Living Armour Upgrades:
- Strong Legs increases jump height. Pro tip: hold shift to bypass this jump boost.
- Soft Fall decreases all fall damage, up to 100% at level 5.
------------------------------------------------------ ------------------------------------------------------
Version 2.0.0-30 Version 2.0.0-30

View file

@ -125,6 +125,7 @@ public class ItemLivingArmour extends ItemArmor implements ISpecialArmor, IMeshP
{ {
LivingArmourUpgrade upgrade = entry.getValue(); LivingArmourUpgrade upgrade = entry.getValue();
remainder *= (1 - upgrade.getArmourProtection(player, source)); remainder *= (1 - upgrade.getArmourProtection(player, source));
/* /*
* Just as a side note, if one upgrade provides * Just as a side note, if one upgrade provides
* upgrade.getArmourProtection(source) = 0.5, the * upgrade.getArmourProtection(source) = 0.5, the
@ -137,10 +138,10 @@ public class ItemLivingArmour extends ItemArmor implements ISpecialArmor, IMeshP
armourReduction = armourReduction + (1 - remainder) * (1 - armourReduction); armourReduction = armourReduction + (1 - remainder) * (1 - armourReduction);
damageAmount *= (armourReduction); damageAmount *= (armourReduction);
if (source.isUnblockable()) // if (source.isUnblockable())
{ // {
return new ArmorProperties(-1, damageAmount * armourPenetrationReduction, maxAbsorption); // return new ArmorProperties(-1, damageAmount * armourPenetrationReduction, maxAbsorption);
} // }
return new ArmorProperties(-1, damageAmount, maxAbsorption); return new ArmorProperties(-1, damageAmount, maxAbsorption);
} }

View file

@ -0,0 +1,103 @@
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.LivingArmourUpgradeFallProtect;
public class StatTrackerFallProtect extends StatTracker
{
public int totalDamage = 0;
public static HashMap<LivingArmour, Double> changeMap = new HashMap<LivingArmour, Double>();
public static int[] damageRequired = new int[] { 30, 200, 400, 800, 1500 };
public static void incrementCounter(LivingArmour armour, double damage)
{
changeMap.put(armour, changeMap.containsKey(armour) ? changeMap.get(armour) + damage : damage);
}
@Override
public String getUniqueIdentifier()
{
return Constants.Mod.MODID + ".tracker.fallProtect";
}
@Override
public void resetTracker()
{
this.totalDamage = 0;
}
@Override
public void readFromNBT(NBTTagCompound tag)
{
totalDamage = tag.getInteger(Constants.Mod.MODID + ".tracker.fallProtect");
}
@Override
public void writeToNBT(NBTTagCompound tag)
{
tag.setInteger(Constants.Mod.MODID + ".tracker.fallProtect", totalDamage);
}
@Override
public boolean onTick(World world, EntityPlayer player, LivingArmour livingArmour)
{
if (changeMap.containsKey(livingArmour))
{
double change = Math.abs(changeMap.get(livingArmour));
if (change > 0)
{
totalDamage += Math.abs(changeMap.get(livingArmour));
changeMap.put(livingArmour, 0d);
this.markDirty();
return true;
}
}
return false;
}
@Override
public void onDeactivatedTick(World world, EntityPlayer player, LivingArmour livingArmour)
{
if (changeMap.containsKey(livingArmour))
{
changeMap.remove(livingArmour);
}
}
@Override
public List<LivingArmourUpgrade> getUpgrades()
{
List<LivingArmourUpgrade> upgradeList = new ArrayList<LivingArmourUpgrade>();
for (int i = 0; i < 5; i++)
{
if (totalDamage >= damageRequired[i])
{
upgradeList.add(new LivingArmourUpgradeFallProtect(i));
}
}
return upgradeList;
}
@Override
public boolean providesUpgrade(String key)
{
return key.equals(Constants.Mod.MODID + ".upgrade.fallProtect");
}
}

View file

@ -0,0 +1,104 @@
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.LivingArmourUpgradeJump;
public class StatTrackerJump extends StatTracker
{
public static HashMap<LivingArmour, Integer> changeMap = new HashMap<LivingArmour, Integer>();
public static int[] jumpsRequired = new int[] { 30, 200, 400, 700, 1100, 1500, 2000, 2800, 3600, 5000 }; //testing
public int totalJumps = 0;
public static void incrementCounter(LivingArmour armour)
{
changeMap.put(armour, changeMap.containsKey(armour) ? changeMap.get(armour) + 1 : 1);
}
@Override
public String getUniqueIdentifier()
{
return Constants.Mod.MODID + ".tracker.jump";
}
@Override
public void resetTracker()
{
this.totalJumps = 0;
}
@Override
public void readFromNBT(NBTTagCompound tag)
{
totalJumps = tag.getInteger(Constants.Mod.MODID + ".tracker.jump");
}
@Override
public void writeToNBT(NBTTagCompound tag)
{
tag.setInteger(Constants.Mod.MODID + ".tracker.jump", totalJumps);
}
@Override
public boolean onTick(World world, EntityPlayer player, LivingArmour livingArmour)
{
if (changeMap.containsKey(livingArmour))
{
int change = Math.abs(changeMap.get(livingArmour));
if (change > 0)
{
totalJumps += Math.abs(changeMap.get(livingArmour));
changeMap.put(livingArmour, 0);
this.markDirty();
return true;
}
}
return false;
}
@Override
public void onDeactivatedTick(World world, EntityPlayer player, LivingArmour livingArmour)
{
if (changeMap.containsKey(livingArmour))
{
changeMap.remove(livingArmour);
}
}
@Override
public List<LivingArmourUpgrade> getUpgrades()
{
List<LivingArmourUpgrade> upgradeList = new ArrayList<LivingArmourUpgrade>();
for (int i = 0; i < 10; i++)
{
if (totalJumps >= jumpsRequired[i])
{
upgradeList.add(new LivingArmourUpgradeJump(i));
}
}
return upgradeList;
}
@Override
public boolean providesUpgrade(String key)
{
return key.equals(Constants.Mod.MODID + ".upgrade.jump");
}
}

View file

@ -84,7 +84,7 @@ public class StatTrackerPhysicalProtect extends StatTracker
{ {
List<LivingArmourUpgrade> upgradeList = new ArrayList<LivingArmourUpgrade>(); List<LivingArmourUpgrade> upgradeList = new ArrayList<LivingArmourUpgrade>();
for (int i = 0; i < 1; i++) for (int i = 0; i < 10; i++)
{ {
if (totalDamage >= damageRequired[i]) if (totalDamage >= damageRequired[i])
{ {

View file

@ -1,17 +1,16 @@
package WayofTime.bloodmagic.livingArmour.upgrade; package WayofTime.bloodmagic.livingArmour.upgrade;
import java.util.HashMap;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.MobEffects;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.potion.PotionEffect;
import net.minecraft.world.World;
import WayofTime.bloodmagic.api.Constants; import WayofTime.bloodmagic.api.Constants;
import WayofTime.bloodmagic.api.livingArmour.ILivingArmour; import WayofTime.bloodmagic.api.livingArmour.ILivingArmour;
import WayofTime.bloodmagic.api.livingArmour.LivingArmourUpgrade; import WayofTime.bloodmagic.api.livingArmour.LivingArmourUpgrade;
import WayofTime.bloodmagic.livingArmour.LivingArmour; import WayofTime.bloodmagic.livingArmour.LivingArmour;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.MobEffects;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionEffect;
import net.minecraft.world.World;
import java.util.HashMap;
public class LivingArmourUpgradeDigging extends LivingArmourUpgrade public class LivingArmourUpgradeDigging extends LivingArmourUpgrade
{ {

View file

@ -0,0 +1,65 @@
package WayofTime.bloodmagic.livingArmour.upgrade;
import WayofTime.bloodmagic.api.Constants;
import WayofTime.bloodmagic.api.livingArmour.LivingArmourUpgrade;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.DamageSource;
public class LivingArmourUpgradeFallProtect extends LivingArmourUpgrade
{
public static final int[] costs = new int[] { 5, 10, 18, 35, 65, 100, 160, 220, 280, 350 };
public static final double[] protectionLevel = new double[] { 0.2, 0.4, 0.6, 0.8, 1 };
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;
}
@Override
public String getUniqueIdentifier()
{
return Constants.Mod.MODID + ".upgrade.fallProtect";
}
@Override
public int getMaxTier()
{
return 5; // 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)
{
// EMPTY
}
@Override
public void readFromNBT(NBTTagCompound tag)
{
// EMPTY
}
@Override
public String getUnlocalizedName()
{
return tooltipBase + "fallProtect";
}
}

View file

@ -0,0 +1,57 @@
package WayofTime.bloodmagic.livingArmour.upgrade;
import WayofTime.bloodmagic.api.Constants;
import WayofTime.bloodmagic.api.livingArmour.LivingArmourUpgrade;
import net.minecraft.nbt.NBTTagCompound;
public class LivingArmourUpgradeJump extends LivingArmourUpgrade
{
public static final int[] costs = new int[] { 7, 13, 22, 40, 65, 90, 130, 180, 250, 350 };
public static final double[] jumpModifier = new double[] { 0.15, 0.3, 0.45, 0.6, 0.75, 0.9, 1.05, 1.2, 1.35, 1.5 };
public LivingArmourUpgradeJump(int level)
{
super(level);
}
public double getJumpModifier()
{
return jumpModifier[this.level];
}
@Override
public String getUniqueIdentifier()
{
return Constants.Mod.MODID + ".upgrade.jump";
}
@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)
{
// EMPTY
}
@Override
public void readFromNBT(NBTTagCompound tag)
{
// EMPTY
}
@Override
public String getUnlocalizedName()
{
return tooltipBase + "jump";
}
}

View file

@ -19,7 +19,7 @@ public class LivingArmourUpgradePhysicalProtect extends LivingArmourUpgrade
@Override @Override
public double getArmourProtection(EntityLivingBase wearer, DamageSource source) public double getArmourProtection(EntityLivingBase wearer, DamageSource source)
{ {
if (source.getEntity() != null) if (source.getEntity() != null && !source.isMagicDamage() && !source.isProjectile())
{ {
return protectionLevel[this.level]; return protectionLevel[this.level];
} }

View file

@ -20,6 +20,8 @@ public class ModArmourTrackers
LivingArmourHandler.registerStatTracker(StatTrackerGrimReaperSprint.class); LivingArmourHandler.registerStatTracker(StatTrackerGrimReaperSprint.class);
LivingArmourHandler.registerStatTracker(StatTrackerSolarPowered.class); LivingArmourHandler.registerStatTracker(StatTrackerSolarPowered.class);
LivingArmourHandler.registerStatTracker(StatTrackerExperience.class); LivingArmourHandler.registerStatTracker(StatTrackerExperience.class);
LivingArmourHandler.registerStatTracker(StatTrackerJump.class);
LivingArmourHandler.registerStatTracker(StatTrackerFallProtect.class);
LivingArmourHandler.registerArmourUpgrade(new LivingArmourUpgradeSpeed(0)); LivingArmourHandler.registerArmourUpgrade(new LivingArmourUpgradeSpeed(0));
LivingArmourHandler.registerArmourUpgrade(new LivingArmourUpgradeDigging(0)); LivingArmourHandler.registerArmourUpgrade(new LivingArmourUpgradeDigging(0));
@ -34,5 +36,7 @@ public class ModArmourTrackers
LivingArmourHandler.registerArmourUpgrade(new LivingArmourUpgradeGrimReaperSprint(0)); LivingArmourHandler.registerArmourUpgrade(new LivingArmourUpgradeGrimReaperSprint(0));
LivingArmourHandler.registerArmourUpgrade(new LivingArmourUpgradeSolarPowered(0)); LivingArmourHandler.registerArmourUpgrade(new LivingArmourUpgradeSolarPowered(0));
LivingArmourHandler.registerArmourUpgrade(new LivingArmourUpgradeExperience(0)); LivingArmourHandler.registerArmourUpgrade(new LivingArmourUpgradeExperience(0));
LivingArmourHandler.registerArmourUpgrade(new LivingArmourUpgradeJump(0));
LivingArmourHandler.registerArmourUpgrade(new LivingArmourUpgradeFallProtect(0));
} }
} }

View file

@ -23,7 +23,7 @@ public class RitualPlacer extends Ritual
public RitualPlacer() public RitualPlacer()
{ {
super("ritualPlacer", 0, 5000, "ritual." + Constants.Mod.MODID + ".placerRitual"); super("ritualPlacer", 0, 5000, "ritual." + Constants.Mod.MODID + ".placerRitual");
addBlockRange(PLACER_RANGE, new AreaDescriptor.Rectangle(new BlockPos(-2, 0, -2), new BlockPos(3, 1, 3))); addBlockRange(PLACER_RANGE, new AreaDescriptor.Rectangle(new BlockPos(-2, 0, -2), 5, 1, 5));
} }
@Override @Override

View file

@ -29,7 +29,7 @@ public class RitualPortal extends Ritual
public RitualPortal() public RitualPortal()
{ {
super("ritualPortal", 0, 500, "ritual." + Constants.Mod.MODID + ".portalRitual"); super("ritualPortal", 0, 50000, "ritual." + Constants.Mod.MODID + ".portalRitual");
portalRitualTag = new NBTTagCompound(); portalRitualTag = new NBTTagCompound();
} }

View file

@ -88,8 +88,10 @@ import WayofTime.bloodmagic.livingArmour.LivingArmour;
import WayofTime.bloodmagic.livingArmour.tracker.StatTrackerArrowShot; import WayofTime.bloodmagic.livingArmour.tracker.StatTrackerArrowShot;
import WayofTime.bloodmagic.livingArmour.tracker.StatTrackerDigging; import WayofTime.bloodmagic.livingArmour.tracker.StatTrackerDigging;
import WayofTime.bloodmagic.livingArmour.tracker.StatTrackerExperience; import WayofTime.bloodmagic.livingArmour.tracker.StatTrackerExperience;
import WayofTime.bloodmagic.livingArmour.tracker.StatTrackerFallProtect;
import WayofTime.bloodmagic.livingArmour.tracker.StatTrackerGrimReaperSprint; import WayofTime.bloodmagic.livingArmour.tracker.StatTrackerGrimReaperSprint;
import WayofTime.bloodmagic.livingArmour.tracker.StatTrackerHealthboost; import WayofTime.bloodmagic.livingArmour.tracker.StatTrackerHealthboost;
import WayofTime.bloodmagic.livingArmour.tracker.StatTrackerJump;
import WayofTime.bloodmagic.livingArmour.tracker.StatTrackerMeleeDamage; import WayofTime.bloodmagic.livingArmour.tracker.StatTrackerMeleeDamage;
import WayofTime.bloodmagic.livingArmour.tracker.StatTrackerPhysicalProtect; import WayofTime.bloodmagic.livingArmour.tracker.StatTrackerPhysicalProtect;
import WayofTime.bloodmagic.livingArmour.tracker.StatTrackerSelfSacrifice; import WayofTime.bloodmagic.livingArmour.tracker.StatTrackerSelfSacrifice;
@ -98,6 +100,7 @@ import WayofTime.bloodmagic.livingArmour.upgrade.LivingArmourUpgradeArrowShot;
import WayofTime.bloodmagic.livingArmour.upgrade.LivingArmourUpgradeDigging; import WayofTime.bloodmagic.livingArmour.upgrade.LivingArmourUpgradeDigging;
import WayofTime.bloodmagic.livingArmour.upgrade.LivingArmourUpgradeExperience; import WayofTime.bloodmagic.livingArmour.upgrade.LivingArmourUpgradeExperience;
import WayofTime.bloodmagic.livingArmour.upgrade.LivingArmourUpgradeGrimReaperSprint; import WayofTime.bloodmagic.livingArmour.upgrade.LivingArmourUpgradeGrimReaperSprint;
import WayofTime.bloodmagic.livingArmour.upgrade.LivingArmourUpgradeJump;
import WayofTime.bloodmagic.livingArmour.upgrade.LivingArmourUpgradeSelfSacrifice; import WayofTime.bloodmagic.livingArmour.upgrade.LivingArmourUpgradeSelfSacrifice;
import WayofTime.bloodmagic.livingArmour.upgrade.LivingArmourUpgradeSpeed; import WayofTime.bloodmagic.livingArmour.upgrade.LivingArmourUpgradeSpeed;
import WayofTime.bloodmagic.livingArmour.upgrade.LivingArmourUpgradeStepAssist; import WayofTime.bloodmagic.livingArmour.upgrade.LivingArmourUpgradeStepAssist;
@ -145,6 +148,35 @@ public class EventHandler
} }
} }
@SubscribeEvent
public void onJumpEvent(LivingEvent.LivingJumpEvent event)
{
if (event.getEntityLiving() instanceof EntityPlayer)
{
EntityPlayer player = (EntityPlayer) event.getEntityLiving();
if (LivingArmour.hasFullSet(player))
{
ItemStack chestStack = player.getItemStackFromSlot(EntityEquipmentSlot.CHEST);
LivingArmour armour = ItemLivingArmour.armourMap.get(chestStack);
if (armour != null)
{
StatTrackerJump.incrementCounter(armour);
if (!player.isSneaking())
{
LivingArmourUpgrade upgrade = ItemLivingArmour.getUpgrade(Constants.Mod.MODID + ".upgrade.jump", chestStack);
if (upgrade instanceof LivingArmourUpgradeJump)
{
player.motionY += ((LivingArmourUpgradeJump) upgrade).getJumpModifier();
}
}
}
}
}
}
@SubscribeEvent @SubscribeEvent
public void onServerWorldTick(TickEvent.WorldTickEvent event) public void onServerWorldTick(TickEvent.WorldTickEvent event)
{ {
@ -583,11 +615,16 @@ public class EventHandler
LivingArmour armour = ItemLivingArmour.armourMap.get(chestStack); LivingArmour armour = ItemLivingArmour.armourMap.get(chestStack);
if (armour != null) if (armour != null)
{ {
if (sourceEntity != null && !source.isMagicDamage()) if (sourceEntity != null && !source.isMagicDamage() && !source.isProjectile())
{ {
// Add resistance to the upgrade that protects against non-magic damage // Add resistance to the upgrade that protects against non-magic damage
StatTrackerPhysicalProtect.incrementCounter(armour, amount); StatTrackerPhysicalProtect.incrementCounter(armour, amount);
} }
if (source.equals(DamageSource.fall))
{
StatTrackerFallProtect.incrementCounter(armour, amount);
}
} }
} else } else
{ {

View file

@ -319,6 +319,8 @@ tooltip.BloodMagic.livingArmour.upgrade.solarPowered=Solar Powered
tooltip.BloodMagic.livingArmour.upgrade.thaumRunicShielding=Runic Shielding tooltip.BloodMagic.livingArmour.upgrade.thaumRunicShielding=Runic Shielding
tooltip.BloodMagic.livingArmour.upgrade.revealing=Revealing tooltip.BloodMagic.livingArmour.upgrade.revealing=Revealing
tooltip.BloodMagic.livingArmour.upgrade.experienced=Experienced tooltip.BloodMagic.livingArmour.upgrade.experienced=Experienced
tooltip.BloodMagic.livingArmour.upgrade.jump=Strong Legs
tooltip.BloodMagic.livingArmour.upgrade.fallProtect=Soft Fall
tooltip.BloodMagic.livingArmour.upgrade.level=%s (Level %d) tooltip.BloodMagic.livingArmour.upgrade.level=%s (Level %d)
tooltip.BloodMagic.livingArmour.upgrade.points=&6Upgrade points: %s / %s tooltip.BloodMagic.livingArmour.upgrade.points=&6Upgrade points: %s / %s