Added poison upgrade. Tweaked digging upgrade so it actually worked.

This commit is contained in:
WayofTime 2016-01-05 10:29:50 -05:00
parent 04f5b7a584
commit fbaf5de9ab
9 changed files with 169 additions and 13 deletions

View file

@ -80,7 +80,7 @@ public class LivingArmour
public void notifyPlayerOfUpgrade(EntityPlayer user, LivingArmourUpgrade upgrade)
{
ChatUtil.sendNoSpam(user, TextHelper.localize(chatBase + "newUpgrade"));
ChatUtil.sendChat(user, TextHelper.localize(chatBase + "newUpgrade"));
}
/**

View file

@ -0,0 +1,74 @@
package WayofTime.bloodmagic.livingArmour;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionEffect;
import net.minecraft.world.World;
import WayofTime.bloodmagic.api.Constants;
import WayofTime.bloodmagic.api.livingArmour.LivingArmourUpgrade;
import WayofTime.bloodmagic.util.ChatUtil;
import WayofTime.bloodmagic.util.helper.TextHelper;
public class LivingArmourUpgradePoisonResist extends LivingArmourUpgrade
{
public static final int[] costs = new int[] { 2, 6, 14, 25, 40 };
public static final int[] poisonCooldownTime = new int[] { 1200, 800, 600, 300, 100 };
public static final int[] poisonMaxCure = new int[] { 0, 1, 2, 2, 3 };
public int poisonCooldown = 0;
public LivingArmourUpgradePoisonResist(int level)
{
super(level);
}
@Override
public void onTick(World world, EntityPlayer player, LivingArmour livingArmour)
{
if (player.isPotionActive(Potion.poison) && poisonCooldown <= 0)
{
PotionEffect eff = player.getActivePotionEffect(Potion.poison);
if (eff.getAmplifier() <= poisonMaxCure[this.level])
{
player.removePotionEffect(Potion.poison.id);
poisonCooldown = poisonCooldownTime[this.level];
ChatUtil.sendNoSpam(player, TextHelper.localize(chatBase + "poisonRemove"));
}
} else if (poisonCooldown > 0)
{
poisonCooldown--;
}
}
@Override
public String getUniqueIdentifier()
{
return Constants.Mod.MODID + ".upgrade.poisonResist";
}
@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)
{
tag.setInteger(Constants.NBT.UPGRADE_POISON_TIMER, poisonCooldown);
}
@Override
public void readFromNBT(NBTTagCompound tag)
{
poisonCooldown = tag.getInteger(Constants.NBT.UPGRADE_POISON_TIMER);
}
}

View file

@ -13,9 +13,10 @@ import WayofTime.bloodmagic.api.livingArmour.StatTracker;
public class StatTrackerDigging extends StatTracker
{
public double totalBlocksDug = 0;
public int totalBlocksDug = 0;
public static HashMap<LivingArmour, Integer> changeMap = new HashMap<LivingArmour, Integer>();
public static int[] blocksRequired = new int[] { 128, 512, 1024, 2048, 8192, 16000, 32000 };
public static void incrementCounter(LivingArmour armour)
{
@ -37,13 +38,13 @@ public class StatTrackerDigging extends StatTracker
@Override
public void readFromNBT(NBTTagCompound tag)
{
totalBlocksDug = tag.getDouble(Constants.Mod.MODID + ".tracker.digging");
totalBlocksDug = tag.getInteger(Constants.Mod.MODID + ".tracker.digging");
}
@Override
public void writeToNBT(NBTTagCompound tag)
{
tag.setDouble(Constants.Mod.MODID + ".tracker.digging", totalBlocksDug);
tag.setInteger(Constants.Mod.MODID + ".tracker.digging", totalBlocksDug);
}
@Override
@ -73,17 +74,13 @@ public class StatTrackerDigging extends StatTracker
// TODO Auto-generated method stub
List<LivingArmourUpgrade> upgradeList = new ArrayList<LivingArmourUpgrade>();
if (totalBlocksDug >= 10)
for (int i = 0; i < 5; i++)
{
upgradeList.add(new LivingArmourUpgradeDigging(0));
if (totalBlocksDug < blocksRequired[i])
{
upgradeList.add(new LivingArmourUpgradeDigging(i));
}
}
// for (int i = 0; i < 5; i++)
// {
// if (totalMovement > (i + 1) * (i + 1) * (i + 1) * 100)
// {
// upgradeList.add(new LivingArmourUpgradeSpeed(i));
// }
// }
return upgradeList;
}

View file

@ -0,0 +1,73 @@
package WayofTime.bloodmagic.livingArmour;
import java.util.ArrayList;
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;
public class StatTrackerPoison extends StatTracker
{
public int totalPoisonTicks = 0;
public static int[] poisonTicksRequired = new int[] { 60 * 20, 3 * 60 * 20, 10 * 60 * 20, 20 * 60 * 20, 25 * 60 * 20 };
@Override
public String getUniqueIdentifier()
{
return Constants.Mod.MODID + ".tracker.poison";
}
@Override
public void resetTracker()
{
this.totalPoisonTicks = 0;
}
@Override
public void readFromNBT(NBTTagCompound tag)
{
totalPoisonTicks = tag.getInteger(Constants.Mod.MODID + ".tracker.poison");
}
@Override
public void writeToNBT(NBTTagCompound tag)
{
tag.setInteger(Constants.Mod.MODID + ".tracker.poison", totalPoisonTicks);
}
@Override
public boolean onTick(World world, EntityPlayer player, LivingArmour livingArmour)
{
if (player.isPotionActive(Potion.poison))
{
totalPoisonTicks++;
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 < 3; i++)
{
if (totalPoisonTicks < poisonTicksRequired[i])
{
upgradeList.add(new LivingArmourUpgradePoisonResist(i));
}
}
return upgradeList;
}
}