Repackage living armor upgrades and trackers
all the organizations
This commit is contained in:
parent
a408f9a959
commit
d769ee2d37
20 changed files with 48 additions and 44 deletions
|
@ -0,0 +1,102 @@
|
|||
package WayofTime.bloodmagic.livingArmour.tracker;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import WayofTime.bloodmagic.livingArmour.LivingArmour;
|
||||
import WayofTime.bloodmagic.livingArmour.upgrade.LivingArmourUpgradeSpeed;
|
||||
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 StatTrackerMovement extends StatTracker
|
||||
{
|
||||
public static Map<EntityPlayer, Double> lastPosX = new HashMap<EntityPlayer, Double>();
|
||||
public static Map<EntityPlayer, Double> lastPosZ = new HashMap<EntityPlayer, Double>();
|
||||
|
||||
public static int[] blocksRequired = new int[] { 200, 1000, 2000, 4000, 7000, 15000, 25000, 35000, 50000, 70000 };
|
||||
|
||||
public double totalMovement = 0;
|
||||
|
||||
@Override
|
||||
public String getUniqueIdentifier()
|
||||
{
|
||||
return Constants.Mod.MODID + ".tracker.movement";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resetTracker()
|
||||
{
|
||||
this.totalMovement = 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound tag)
|
||||
{
|
||||
totalMovement = tag.getDouble(Constants.Mod.MODID + ".tracker.movement");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound tag)
|
||||
{
|
||||
tag.setDouble(Constants.Mod.MODID + ".tracker.movement", totalMovement);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onTick(World world, EntityPlayer player, LivingArmour livingArmour)
|
||||
{
|
||||
if (!lastPosX.containsKey(player))
|
||||
{
|
||||
lastPosX.put(player, player.posX);
|
||||
lastPosZ.put(player, player.posZ);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!player.onGround)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
double distanceTravelled = Math.sqrt(Math.pow(lastPosX.get(player) - player.posX, 2) + Math.pow(lastPosZ.get(player) - player.posZ, 2));
|
||||
|
||||
if (distanceTravelled > 0.0001 && distanceTravelled < 2)
|
||||
{
|
||||
totalMovement += distanceTravelled;
|
||||
|
||||
lastPosX.put(player, player.posX);
|
||||
lastPosZ.put(player, player.posZ);
|
||||
|
||||
markDirty();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
lastPosX.put(player, player.posX);
|
||||
lastPosZ.put(player, player.posZ);
|
||||
|
||||
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 (totalMovement >= blocksRequired[i])
|
||||
{
|
||||
upgradeList.add(new LivingArmourUpgradeSpeed(i));
|
||||
}
|
||||
}
|
||||
|
||||
return upgradeList;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue