Added Runic Shielding upgrade to the Living Armour.
This commit is contained in:
parent
460df89e10
commit
95354ad557
8 changed files with 225 additions and 9 deletions
|
@ -0,0 +1,32 @@
|
|||
package WayofTime.bloodmagic.compat.jei;
|
||||
|
||||
import WayofTime.bloodmagic.api.livingArmour.LivingArmourHandler;
|
||||
import WayofTime.bloodmagic.compat.ICompatibility;
|
||||
import WayofTime.bloodmagic.compat.thaumcraft.LivingArmourUpgradeThaumRunicShielding;
|
||||
import WayofTime.bloodmagic.compat.thaumcraft.StatTrackerThaumRunicShielding;
|
||||
|
||||
public class CompatibilityThaumcraft implements ICompatibility
|
||||
{
|
||||
@Override
|
||||
public void loadCompatibility(InitializationPhase phase)
|
||||
{
|
||||
if (phase == InitializationPhase.POST_INIT)
|
||||
{
|
||||
LivingArmourHandler.registerStatTracker(StatTrackerThaumRunicShielding.class);
|
||||
|
||||
LivingArmourHandler.registerArmourUpgrade(new LivingArmourUpgradeThaumRunicShielding(0));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getModId()
|
||||
{
|
||||
return "Thaumcraft";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean enableCompat()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,58 @@
|
|||
package WayofTime.bloodmagic.compat.thaumcraft;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import WayofTime.bloodmagic.api.Constants;
|
||||
import WayofTime.bloodmagic.api.livingArmour.LivingArmourUpgrade;
|
||||
|
||||
public class LivingArmourUpgradeThaumRunicShielding 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[] { 2, 4, 6, 8, 10, 13, 16, 19, 22, 25 };
|
||||
|
||||
public LivingArmourUpgradeThaumRunicShielding(int level)
|
||||
{
|
||||
super(level);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUniqueIdentifier()
|
||||
{
|
||||
return Constants.Mod.MODID + ".upgrade.thaumRunicShielding";
|
||||
}
|
||||
|
||||
@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 + "thaumRunicShielding";
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRunicShielding()
|
||||
{
|
||||
return healthModifier[this.level];
|
||||
}
|
||||
}
|
|
@ -0,0 +1,91 @@
|
|||
package WayofTime.bloodmagic.compat.thaumcraft;
|
||||
|
||||
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.potion.Potion;
|
||||
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;
|
||||
|
||||
public class StatTrackerThaumRunicShielding extends StatTracker
|
||||
{
|
||||
public float totalShieldDamage = 0;
|
||||
|
||||
public static HashMap<LivingArmour, Float> changeMap = new HashMap<LivingArmour, Float>();
|
||||
public static int[] healthedRequired = new int[] { 80, 200, 340, 540, 800, 1600, 2800, 5000, 7600, 10000 };
|
||||
|
||||
@Override
|
||||
public String getUniqueIdentifier()
|
||||
{
|
||||
return Constants.Mod.MODID + ".tracker.thaumRunicShielding";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resetTracker()
|
||||
{
|
||||
this.totalShieldDamage = 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound tag)
|
||||
{
|
||||
totalShieldDamage = tag.getFloat(Constants.Mod.MODID + ".tracker.thaumRunicShielding");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound tag)
|
||||
{
|
||||
tag.setFloat(Constants.Mod.MODID + ".tracker.thaumRunicShielding", totalShieldDamage);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onTick(World world, EntityPlayer player, LivingArmour livingArmour)
|
||||
{
|
||||
if (changeMap.containsKey(livingArmour))
|
||||
{
|
||||
float lastCharge = Math.abs(changeMap.get(livingArmour));
|
||||
float currentCharge = player.getAbsorptionAmount();
|
||||
if (currentCharge < lastCharge)
|
||||
{
|
||||
totalShieldDamage += lastCharge - currentCharge;
|
||||
|
||||
this.markDirty();
|
||||
|
||||
changeMap.put(livingArmour, currentCharge);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (currentCharge != lastCharge && !player.isPotionActive(Potion.absorption)) //Charge is only updated if the "shielding" isn't caused by Absorption.
|
||||
{
|
||||
changeMap.put(livingArmour, currentCharge);
|
||||
}
|
||||
} else
|
||||
{
|
||||
changeMap.put(livingArmour, 0f);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<LivingArmourUpgrade> getUpgrades()
|
||||
{
|
||||
List<LivingArmourUpgrade> upgradeList = new ArrayList<LivingArmourUpgrade>();
|
||||
|
||||
for (int i = 0; i < 10; i++)
|
||||
{
|
||||
if (totalShieldDamage >= healthedRequired[i])
|
||||
{
|
||||
upgradeList.add(new LivingArmourUpgradeThaumRunicShielding(i));
|
||||
}
|
||||
}
|
||||
|
||||
return upgradeList;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue