Added health boost upgrade - trained by healing.

This commit is contained in:
WayofTime 2016-01-06 19:55:51 -05:00
parent 6dedb234fb
commit 65e0cea9af
7 changed files with 203 additions and 2 deletions

View file

@ -0,0 +1,78 @@
package WayofTime.bloodmagic.livingArmour;
import java.util.UUID;
import net.minecraft.entity.SharedMonsterAttributes;
import net.minecraft.entity.ai.attributes.AttributeModifier;
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.ILivingArmour;
import WayofTime.bloodmagic.api.livingArmour.LivingArmourUpgrade;
import com.google.common.collect.HashMultimap;
import com.google.common.collect.Multimap;
public class LivingArmourUpgradeHealthboost extends LivingArmourUpgrade
{
public static final int[] costs = new int[] { 5, 12, 20, 35, 49, 78, 110, 160, 215, 320 };
public static final int[] healthModifier = new int[] { 4, 8, 12, 16, 20, 26, 32, 38, 44, 50 };
public LivingArmourUpgradeHealthboost(int level)
{
super(level);
}
@Override
public void onTick(World world, EntityPlayer player, ILivingArmour livingArmour)
{
}
@Override
public Multimap<String, AttributeModifier> getAttributeModifiers()
{
Multimap<String, AttributeModifier> modifierMap = HashMultimap.<String, AttributeModifier>create();
modifierMap.put(SharedMonsterAttributes.maxHealth.getAttributeUnlocalizedName(), new AttributeModifier(new UUID(9423688, 1), "Health modifier" + 1, healthModifier[this.level], 0));
return modifierMap;
}
@Override
public String getUniqueIdentifier()
{
return Constants.Mod.MODID + ".upgrade.health";
}
@Override
public int getMaxTier()
{
return 10;
}
@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 + "health";
}
}

View file

@ -8,7 +8,7 @@ import WayofTime.bloodmagic.api.livingArmour.LivingArmourUpgrade;
public class LivingArmourUpgradePhysicalProtect 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.1, 0.3, 0.4, 0.5, 0.6, 0.7, 0.75, 0.8, 0.85, 0.9 };
public static final double[] protectionLevel = new double[] { 0.1, 0.3, 0.4, 0.5, 0.6, 0.7, 0.75, 0.77, 0.80, 0.83 };
public LivingArmourUpgradePhysicalProtect(int level)
{

View file

@ -0,0 +1,87 @@
package WayofTime.bloodmagic.livingArmour;
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;
public class StatTrackerHealthboost extends StatTracker
{
public double totalHealthGenned = 0;
public static HashMap<LivingArmour, Double> changeMap = new HashMap<LivingArmour, Double>();
public static int[] healthedRequired = new int[] { 80, 200, 340, 540, 800, 1600, 2800, 5000, 7600, 10000 };
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.health";
}
@Override
public void resetTracker()
{
this.totalHealthGenned = 0;
}
@Override
public void readFromNBT(NBTTagCompound tag)
{
totalHealthGenned = tag.getDouble(Constants.Mod.MODID + ".tracker.health");
}
@Override
public void writeToNBT(NBTTagCompound tag)
{
tag.setDouble(Constants.Mod.MODID + ".tracker.health", 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<LivingArmourUpgrade> getUpgrades()
{
// TODO Auto-generated method stub
List<LivingArmourUpgrade> upgradeList = new ArrayList<LivingArmourUpgrade>();
for (int i = 0; i < 10; i++)
{
if (totalHealthGenned >= healthedRequired[i])
{
upgradeList.add(new LivingArmourUpgradeHealthboost(i));
}
}
return upgradeList;
}
}