Added digging stat tracker and upgrade to Living Armour. Added chat message for when the armour upgrades.
This commit is contained in:
parent
f0331b4d4d
commit
00adb96931
11 changed files with 234 additions and 24 deletions
|
@ -13,12 +13,15 @@ import net.minecraft.world.World;
|
|||
import WayofTime.bloodmagic.api.livingArmour.LivingArmourHandler;
|
||||
import WayofTime.bloodmagic.api.livingArmour.LivingArmourUpgrade;
|
||||
import WayofTime.bloodmagic.api.livingArmour.StatTracker;
|
||||
import WayofTime.bloodmagic.util.ChatUtil;
|
||||
import WayofTime.bloodmagic.util.helper.TextHelper;
|
||||
|
||||
import com.google.common.collect.HashMultimap;
|
||||
import com.google.common.collect.Multimap;
|
||||
|
||||
public class LivingArmour
|
||||
{
|
||||
public static String chatBase = "chat.BloodMagic.livingArmour.";
|
||||
public HashMap<String, StatTracker> trackerMap = new HashMap<String, StatTracker>();
|
||||
public HashMap<String, LivingArmourUpgrade> upgradeMap = new HashMap<String, LivingArmourUpgrade>();
|
||||
|
||||
|
@ -77,7 +80,7 @@ public class LivingArmour
|
|||
|
||||
public void notifyPlayerOfUpgrade(EntityPlayer user, LivingArmourUpgrade upgrade)
|
||||
{
|
||||
System.out.println("Upgraded!");
|
||||
ChatUtil.sendNoSpam(user, TextHelper.localize(chatBase + "newUpgrade"));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -0,0 +1,67 @@
|
|||
package WayofTime.bloodmagic.livingArmour;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
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;
|
||||
|
||||
public class LivingArmourUpgradeDigging extends LivingArmourUpgrade
|
||||
{
|
||||
public static HashMap<LivingArmour, Boolean> changeMap = new HashMap<LivingArmour, Boolean>();
|
||||
|
||||
public static void hasDug(LivingArmour armour)
|
||||
{
|
||||
changeMap.put(armour, true);
|
||||
}
|
||||
|
||||
public LivingArmourUpgradeDigging(int level)
|
||||
{
|
||||
super(level);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTick(World world, EntityPlayer player, LivingArmour livingArmour)
|
||||
{
|
||||
if (changeMap.containsKey(livingArmour) && changeMap.get(livingArmour))
|
||||
{
|
||||
changeMap.put(livingArmour, false);
|
||||
|
||||
player.addPotionEffect(new PotionEffect(Potion.digSpeed.id, 100, 0, false, false));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUniqueIdentifier()
|
||||
{
|
||||
return Constants.Mod.MODID + ".upgrade.digging";
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxTier()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCostOfUpgrade()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound tag)
|
||||
{
|
||||
// EMPTY
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound tag)
|
||||
{
|
||||
// EMPTY
|
||||
}
|
||||
}
|
|
@ -23,8 +23,8 @@ public class LivingArmourUpgradeSpeed extends LivingArmourUpgrade
|
|||
{
|
||||
Multimap<String, AttributeModifier> modifierMap = HashMultimap.<String, AttributeModifier>create();
|
||||
|
||||
// Adds 10% per level
|
||||
modifierMap.put(SharedMonsterAttributes.movementSpeed.getAttributeUnlocalizedName(), new AttributeModifier(new UUID(895132, 1), "Speed modifier" + 1, (this.level + 1) * 0.1, 1));
|
||||
// Adds 5% per level
|
||||
modifierMap.put(SharedMonsterAttributes.movementSpeed.getAttributeUnlocalizedName(), new AttributeModifier(new UUID(895132, 1), "Speed modifier" + 1, (this.level + 1) * 0.05, 1));
|
||||
|
||||
return modifierMap;
|
||||
}
|
||||
|
@ -38,13 +38,13 @@ public class LivingArmourUpgradeSpeed extends LivingArmourUpgrade
|
|||
@Override
|
||||
public int getMaxTier()
|
||||
{
|
||||
return 5;
|
||||
return 10;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCostOfUpgrade()
|
||||
{
|
||||
return this.level + 1;
|
||||
return 3 * (this.level + 1) * (this.level + 1) * (this.level + 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -0,0 +1,91 @@
|
|||
package WayofTime.bloodmagic.livingArmour;
|
||||
|
||||
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;
|
||||
|
||||
public class StatTrackerDigging extends StatTracker
|
||||
{
|
||||
public double totalBlocksDug = 0;
|
||||
|
||||
public static HashMap<LivingArmour, Integer> changeMap = new HashMap<LivingArmour, Integer>();
|
||||
|
||||
public static void incrementCounter(LivingArmour armour)
|
||||
{
|
||||
changeMap.put(armour, changeMap.containsKey(armour) ? changeMap.get(armour) + 1 : 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUniqueIdentifier()
|
||||
{
|
||||
return Constants.Mod.MODID + ".tracker.digging";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resetTracker()
|
||||
{
|
||||
this.totalBlocksDug = 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound tag)
|
||||
{
|
||||
totalBlocksDug = tag.getDouble(Constants.Mod.MODID + ".tracker.digging");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound tag)
|
||||
{
|
||||
tag.setDouble(Constants.Mod.MODID + ".tracker.digging", totalBlocksDug);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onTick(World world, EntityPlayer player, LivingArmour livingArmour)
|
||||
{
|
||||
if (changeMap.containsKey(livingArmour))
|
||||
{
|
||||
int change = Math.abs(changeMap.get(livingArmour));
|
||||
if (change > 0)
|
||||
{
|
||||
totalBlocksDug += Math.abs(changeMap.get(livingArmour));
|
||||
|
||||
changeMap.put(livingArmour, 0);
|
||||
|
||||
System.out.println("Blocks dug: " + totalBlocksDug);
|
||||
this.markDirty();
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<LivingArmourUpgrade> getUpgrades()
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
List<LivingArmourUpgrade> upgradeList = new ArrayList<LivingArmourUpgrade>();
|
||||
|
||||
if (totalBlocksDug >= 10)
|
||||
{
|
||||
upgradeList.add(new LivingArmourUpgradeDigging(0));
|
||||
}
|
||||
// for (int i = 0; i < 5; i++)
|
||||
// {
|
||||
// if (totalMovement > (i + 1) * (i + 1) * (i + 1) * 100)
|
||||
// {
|
||||
// upgradeList.add(new LivingArmourUpgradeSpeed(i));
|
||||
// }
|
||||
// }
|
||||
|
||||
return upgradeList;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue