Fixed something

This commit is contained in:
WayofTime 2016-02-09 21:08:54 -05:00
parent 1d7b6febb9
commit bb40cbb216
3 changed files with 238 additions and 0 deletions

View file

@ -0,0 +1,95 @@
package WayofTime.bloodmagic.livingArmour.tracker;
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;
import WayofTime.bloodmagic.livingArmour.LivingArmour;
import WayofTime.bloodmagic.livingArmour.upgrade.LivingArmourUpgradeGrimReaperSprint;
public class StatTrackerGrimReaperSprint extends StatTracker
{
public int totalDeaths = 0;
public static HashMap<LivingArmour, Integer> changeMap = new HashMap<LivingArmour, Integer>();
public static int[] deathsRequired = new int[] { 3, 5, 6, 7, 8, 9, 10, 11, 12, 13 }; //TODO: Modify
public static void incrementCounter(LivingArmour armour)
{
StatTracker tracker = armour.getTracker(Constants.Mod.MODID + ".tracker.grimReaper");
if (tracker instanceof StatTrackerGrimReaperSprint)
{
((StatTrackerGrimReaperSprint) tracker).totalDeaths++;
System.out.println(((StatTrackerGrimReaperSprint) tracker).totalDeaths);
tracker.markDirty();
}
// changeMap.put(armour, changeMap.containsKey(armour) ? changeMap.get(armour) + 1 : 1);
}
@Override
public String getUniqueIdentifier()
{
return Constants.Mod.MODID + ".tracker.grimReaper";
}
@Override
public void resetTracker()
{
this.totalDeaths = 0;
}
@Override
public void readFromNBT(NBTTagCompound tag)
{
totalDeaths = tag.getInteger(Constants.Mod.MODID + ".tracker.grimReaper");
}
@Override
public void writeToNBT(NBTTagCompound tag)
{
tag.setInteger(Constants.Mod.MODID + ".tracker.grimReaper", totalDeaths);
}
@Override
public boolean onTick(World world, EntityPlayer player, LivingArmour livingArmour)
{
if (changeMap.containsKey(livingArmour))
{
double change = Math.abs(changeMap.get(livingArmour));
if (change > 0)
{
totalDeaths += Math.abs(changeMap.get(livingArmour));
changeMap.put(livingArmour, 0);
this.markDirty();
return true;
}
}
return true;
}
@Override
public List<LivingArmourUpgrade> getUpgrades()
{
List<LivingArmourUpgrade> upgradeList = new ArrayList<LivingArmourUpgrade>();
for (int i = 0; i < 10; i++)
{
if (totalDeaths >= deathsRequired[i])
{
upgradeList.add(new LivingArmourUpgradeGrimReaperSprint(i));
}
}
return upgradeList;
}
}

View file

@ -0,0 +1,80 @@
package WayofTime.bloodmagic.livingArmour.upgrade;
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 WayofTime.bloodmagic.util.ChatUtil;
import WayofTime.bloodmagic.util.helper.TextHelper;
public class LivingArmourUpgradeGrimReaperSprint extends LivingArmourUpgrade
{
public static final int[] costs = new int[] { 20, 50, 130, 270, 450, 580, 700, 800, 900, 1000 };
public static final int[] rebirthDelay = new int[] { 20 * 60 * 60, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
public int deathTimer = 0;
public LivingArmourUpgradeGrimReaperSprint(int level)
{
super(level);
}
@Override
public void onTick(World world, EntityPlayer player, ILivingArmour livingArmour)
{
if (deathTimer > 0)
{
deathTimer--;
}
}
@Override
public String getUniqueIdentifier()
{
return Constants.Mod.MODID + ".upgrade.grimReaper";
}
@Override
public int getMaxTier()
{
return 1;
}
@Override
public int getCostOfUpgrade()
{
return costs[this.level];
}
@Override
public void readFromNBT(NBTTagCompound tag)
{
deathTimer = tag.getInteger(Constants.Mod.MODID + ".tracker.grimReaper");
}
@Override
public void writeToNBT(NBTTagCompound tag)
{
tag.setInteger(Constants.Mod.MODID + ".tracker.grimReaper", deathTimer);
}
@Override
public String getUnlocalizedName()
{
return tooltipBase + "grimReaper";
}
public void applyEffectOnRebirth(EntityPlayer player)
{
player.setHealth(player.getMaxHealth());
deathTimer = rebirthDelay[this.level];
ChatUtil.sendNoSpam(player, TextHelper.localizeEffect(chatBase + "grimReaper"));
}
public boolean canSavePlayer(EntityPlayer player)
{
return deathTimer <= 0;
}
}

View file

@ -0,0 +1,63 @@
package WayofTime.bloodmagic.livingArmour.upgrade;
import net.minecraft.nbt.NBTTagCompound;
import WayofTime.bloodmagic.api.Constants;
import WayofTime.bloodmagic.api.livingArmour.LivingArmourUpgrade;
public class LivingArmourUpgradeStepAssist extends LivingArmourUpgrade
{
public static final int[] costs = new int[] { 20 };
public static final float[] assist = new float[] { 1 };
// public static final double[] speedModifier = new double[] { 0.1, 0.2, 0.3, 0.4, 0.5, 0.7, 0.9, 1.1, 1.3, 1.5 };
// public static final int[] sprintSpeedTime = new int[] { 0, 0, 0, 0, 0, 20, 60, 60, 100, 200 };
// public static final int[] sprintSpeedLevel = new int[] { 0, 0, 0, 0, 0, 0, 0, 1, 1, 2 };
// public static final int[] healthModifier = new int[] { 0, 0, 0, 0, 0, 0, 0, 4, 10, 20 };
// public static final int[] sprintRegenTime = new int[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 25 };
public LivingArmourUpgradeStepAssist(int level)
{
super(level);
}
@Override
public String getUniqueIdentifier()
{
return Constants.Mod.MODID + ".upgrade.stepAssist";
}
@Override
public int getMaxTier()
{
return 1;
}
@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 + "stepAssist";
}
public float getStepAssist()
{
return assist[this.level];
}
}