Added Runic Shielding upgrade to the Living Armour.

This commit is contained in:
WayofTime 2016-02-11 17:53:20 -05:00
parent 460df89e10
commit 95354ad557
8 changed files with 225 additions and 9 deletions

View file

@ -4,6 +4,7 @@ Version 2.0.0-17
- Added Living Armour Upgrades - Added Living Armour Upgrades
- Solar Powered - Solar Powered
- Grim Reaper's Sprint - Grim Reaper's Sprint
- [Thaumcraft] Runic Shielding
- Fixed Blood Altar's progress resetting when clicking with another item - Fixed Blood Altar's progress resetting when clicking with another item
- Fixed Divination and Seer sigils crashing when clicking on an altar while not bound - Fixed Divination and Seer sigils crashing when clicking on an altar while not bound

View file

@ -73,4 +73,9 @@ public abstract class LivingArmourUpgrade
public abstract void writeToNBT(NBTTagCompound tag); public abstract void writeToNBT(NBTTagCompound tag);
public abstract void readFromNBT(NBTTagCompound tag); public abstract void readFromNBT(NBTTagCompound tag);
public int getRunicShielding()
{
return 0;
}
} }

View file

@ -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;
}
}

View file

@ -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];
}
}

View file

@ -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;
}
}

View file

@ -5,7 +5,6 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Map.Entry; import java.util.Map.Entry;
import WayofTime.bloodmagic.api.util.helper.NBTHelper;
import net.minecraft.entity.Entity; import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.ai.attributes.AttributeModifier; import net.minecraft.entity.ai.attributes.AttributeModifier;
@ -19,19 +18,21 @@ import net.minecraftforge.common.ISpecialArmor;
import net.minecraftforge.fml.common.Optional; import net.minecraftforge.fml.common.Optional;
import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly; import net.minecraftforge.fml.relauncher.SideOnly;
import thaumcraft.api.items.IGoggles;
import thaumcraft.api.items.IRevealer;
import thaumcraft.api.items.IRunicArmor;
import WayofTime.bloodmagic.BloodMagic; import WayofTime.bloodmagic.BloodMagic;
import WayofTime.bloodmagic.api.Constants; import WayofTime.bloodmagic.api.Constants;
import WayofTime.bloodmagic.api.livingArmour.LivingArmourUpgrade; import WayofTime.bloodmagic.api.livingArmour.LivingArmourUpgrade;
import WayofTime.bloodmagic.api.util.helper.NBTHelper;
import WayofTime.bloodmagic.livingArmour.LivingArmour; import WayofTime.bloodmagic.livingArmour.LivingArmour;
import WayofTime.bloodmagic.registry.ModItems; import WayofTime.bloodmagic.registry.ModItems;
import WayofTime.bloodmagic.util.helper.TextHelper; import WayofTime.bloodmagic.util.helper.TextHelper;
import com.google.common.collect.Multimap; import com.google.common.collect.Multimap;
import thaumcraft.api.items.IGoggles;
import thaumcraft.api.items.IRevealer;
@Optional.InterfaceList({ @Optional.Interface(iface = "thaumcraft.api.items.IRevealer", modid = "Thaumcraft"), @Optional.Interface(iface = "thaumcraft.api.items.IGoggles", modid = "Thaumcraft") }) @Optional.InterfaceList({ @Optional.Interface(iface = "thaumcraft.api.items.IRevealer", modid = "Thaumcraft"), @Optional.Interface(iface = "thaumcraft.api.items.IGoggles", modid = "Thaumcraft"), @Optional.Interface(iface = "thaumcraft.api.items.IRunicArmor", modid = "Thaumcraft") })
public class ItemLivingArmour extends ItemArmor implements ISpecialArmor, IRevealer, IGoggles public class ItemLivingArmour extends ItemArmor implements ISpecialArmor, IRevealer, IGoggles, IRunicArmor
{ {
public static String[] names = { "helmet", "chest", "legs", "boots" }; public static String[] names = { "helmet", "chest", "legs", "boots" };
@ -336,4 +337,29 @@ public class ItemLivingArmour extends ItemArmor implements ISpecialArmor, IRevea
return armor.upgradeMap.containsKey(Constants.Mod.MODID + ".upgrade.revealing") && LivingArmour.hasFullSet((EntityPlayer) entityLivingBase); return armor.upgradeMap.containsKey(Constants.Mod.MODID + ".upgrade.revealing") && LivingArmour.hasFullSet((EntityPlayer) entityLivingBase);
} }
@Override
public int getRunicCharge(ItemStack stack)
{
if (this == ModItems.livingArmourChest)
{
stack = NBTHelper.checkNBT(stack);
LivingArmour armour = getLivingArmour(stack);
int shielding = 0;
if (armour != null)
{
for (Entry<String, LivingArmourUpgrade> entry : armour.upgradeMap.entrySet())
{
LivingArmourUpgrade upgrade = entry.getValue();
shielding += upgrade.getRunicShielding();
}
}
return shielding;
}
return 0;
}
} }

View file

@ -1,11 +1,12 @@
package WayofTime.bloodmagic.registry; package WayofTime.bloodmagic.registry;
import java.util.ArrayList;
import net.minecraftforge.fml.common.Loader;
import WayofTime.bloodmagic.compat.ICompatibility; import WayofTime.bloodmagic.compat.ICompatibility;
import WayofTime.bloodmagic.compat.jei.CompatibilityJustEnoughItems; import WayofTime.bloodmagic.compat.jei.CompatibilityJustEnoughItems;
import WayofTime.bloodmagic.compat.jei.CompatibilityThaumcraft;
import WayofTime.bloodmagic.compat.waila.CompatibilityWaila; import WayofTime.bloodmagic.compat.waila.CompatibilityWaila;
import net.minecraftforge.fml.common.Loader;
import java.util.ArrayList;
public class ModCompatibility public class ModCompatibility
{ {
@ -15,6 +16,7 @@ public class ModCompatibility
{ {
compatibilities.add(new CompatibilityJustEnoughItems()); compatibilities.add(new CompatibilityJustEnoughItems());
compatibilities.add(new CompatibilityWaila()); compatibilities.add(new CompatibilityWaila());
compatibilities.add(new CompatibilityThaumcraft());
} }
public static void loadCompat(ICompatibility.InitializationPhase phase) public static void loadCompat(ICompatibility.InitializationPhase phase)

View file

@ -282,7 +282,8 @@ tooltip.BloodMagic.livingArmour.upgrade.meleeDamage=Fierce Strike
tooltip.BloodMagic.livingArmour.upgrade.arrowShot=Trick Shot tooltip.BloodMagic.livingArmour.upgrade.arrowShot=Trick Shot
tooltip.BloodMagic.livingArmour.upgrade.stepAssist=Step Assist tooltip.BloodMagic.livingArmour.upgrade.stepAssist=Step Assist
tooltip.BloodMagic.livingArmour.upgrade.grimReaper=Grim Reaper's Sprint tooltip.BloodMagic.livingArmour.upgrade.grimReaper=Grim Reaper's Sprint
tooltip.BloodMagic.livingArmour.upgrade.grimReaper=Solar Powered tooltip.BloodMagic.livingArmour.upgrade.solarPowered=Solar Powered
tooltip.BloodMagic.livingArmour.upgrade.thaumRunicShielding=Runic Shielding
tooltip.BloodMagic.livingArmour.upgrade.revealing=Revealing tooltip.BloodMagic.livingArmour.upgrade.revealing=Revealing
tooltip.BloodMagic.livingArmour.upgrade.level=%s (Level %d) tooltip.BloodMagic.livingArmour.upgrade.level=%s (Level %d)