Added health boost upgrade - trained by healing.
This commit is contained in:
parent
6dedb234fb
commit
65e0cea9af
|
@ -1,7 +1,8 @@
|
|||
------------------------------------------------------
|
||||
Version 2.0.0-4
|
||||
------------------------------------------------------
|
||||
- Added Physical resistance upgrade.
|
||||
- Added Physical resistance upgrade (Tough skin).
|
||||
- Added health boost upgrade (Healthy)
|
||||
|
||||
|
||||
------------------------------------------------------
|
||||
|
|
|
@ -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";
|
||||
}
|
||||
}
|
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -2,12 +2,14 @@ package WayofTime.bloodmagic.registry;
|
|||
|
||||
import WayofTime.bloodmagic.api.livingArmour.LivingArmourHandler;
|
||||
import WayofTime.bloodmagic.livingArmour.LivingArmourUpgradeDigging;
|
||||
import WayofTime.bloodmagic.livingArmour.LivingArmourUpgradeHealthboost;
|
||||
import WayofTime.bloodmagic.livingArmour.LivingArmourUpgradeKnockbackResist;
|
||||
import WayofTime.bloodmagic.livingArmour.LivingArmourUpgradePoisonResist;
|
||||
import WayofTime.bloodmagic.livingArmour.LivingArmourUpgradeSelfSacrifice;
|
||||
import WayofTime.bloodmagic.livingArmour.LivingArmourUpgradeSpeed;
|
||||
import WayofTime.bloodmagic.livingArmour.StatTrackerDigging;
|
||||
import WayofTime.bloodmagic.livingArmour.StatTrackerFood;
|
||||
import WayofTime.bloodmagic.livingArmour.StatTrackerHealthboost;
|
||||
import WayofTime.bloodmagic.livingArmour.StatTrackerMovement;
|
||||
import WayofTime.bloodmagic.livingArmour.StatTrackerPoison;
|
||||
import WayofTime.bloodmagic.livingArmour.StatTrackerSelfSacrifice;
|
||||
|
@ -21,11 +23,13 @@ public class ModArmourTrackers
|
|||
LivingArmourHandler.registerStatTracker(StatTrackerPoison.class);
|
||||
LivingArmourHandler.registerStatTracker(StatTrackerSelfSacrifice.class);
|
||||
LivingArmourHandler.registerStatTracker(StatTrackerFood.class);
|
||||
LivingArmourHandler.registerStatTracker(StatTrackerHealthboost.class);
|
||||
|
||||
LivingArmourHandler.registerArmourUpgrade(new LivingArmourUpgradeSpeed(0));
|
||||
LivingArmourHandler.registerArmourUpgrade(new LivingArmourUpgradeDigging(0));
|
||||
LivingArmourHandler.registerArmourUpgrade(new LivingArmourUpgradePoisonResist(0));
|
||||
LivingArmourHandler.registerArmourUpgrade(new LivingArmourUpgradeSelfSacrifice(0));
|
||||
LivingArmourHandler.registerArmourUpgrade(new LivingArmourUpgradeKnockbackResist(0));
|
||||
LivingArmourHandler.registerArmourUpgrade(new LivingArmourUpgradeHealthboost(0));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,6 +9,7 @@ import net.minecraft.init.Items;
|
|||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.DamageSource;
|
||||
import net.minecraftforge.event.entity.living.LivingAttackEvent;
|
||||
import net.minecraftforge.event.entity.living.LivingHealEvent;
|
||||
import net.minecraftforge.event.entity.living.LivingHurtEvent;
|
||||
import net.minecraftforge.event.entity.player.FillBucketEvent;
|
||||
import net.minecraftforge.event.entity.player.PlayerEvent;
|
||||
|
@ -31,6 +32,7 @@ import WayofTime.bloodmagic.livingArmour.LivingArmour;
|
|||
import WayofTime.bloodmagic.livingArmour.LivingArmourUpgradeDigging;
|
||||
import WayofTime.bloodmagic.livingArmour.LivingArmourUpgradeSelfSacrifice;
|
||||
import WayofTime.bloodmagic.livingArmour.StatTrackerDigging;
|
||||
import WayofTime.bloodmagic.livingArmour.StatTrackerHealthboost;
|
||||
import WayofTime.bloodmagic.livingArmour.StatTrackerPhysicalProtect;
|
||||
import WayofTime.bloodmagic.livingArmour.StatTrackerSelfSacrifice;
|
||||
import WayofTime.bloodmagic.registry.ModBlocks;
|
||||
|
@ -173,6 +175,34 @@ public class EventHandler
|
|||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onEntityHealed(LivingHealEvent event)
|
||||
{
|
||||
EntityLivingBase healedEntity = event.entityLiving;
|
||||
if (!(healedEntity instanceof EntityPlayer))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
EntityPlayer player = (EntityPlayer) healedEntity;
|
||||
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
ItemStack stack = player.getCurrentArmor(i);
|
||||
if (stack == null || !(stack.getItem() instanceof ItemLivingArmour))
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
ItemStack chestStack = player.getCurrentArmor(2);
|
||||
LivingArmour armour = ItemLivingArmour.armourMap.get(chestStack);
|
||||
if (armour != null)
|
||||
{
|
||||
StatTrackerHealthboost.incrementCounter(armour, event.amount);
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onEntityAttacked(LivingAttackEvent event)
|
||||
{
|
||||
|
|
|
@ -224,6 +224,7 @@ tooltip.BloodMagic.livingArmour.upgrade.poisonResist=Poison Resistance
|
|||
tooltip.BloodMagic.livingArmour.upgrade.selfSacrifice=Tough Palms
|
||||
tooltip.BloodMagic.livingArmour.upgrade.knockback=Body Builder
|
||||
tooltip.BloodMagic.livingArmour.upgrade.physicalProtect=Tough Skin
|
||||
tooltip.BloodMagic.livingArmour.upgrade.health=Healthy
|
||||
tooltip.BloodMagic.livingArmour.upgrade.level=(Level %d)
|
||||
|
||||
# Ritual
|
||||
|
|
Loading…
Reference in a new issue