use of WayofTime.bloodmagic.livingArmour.StatTracker in project BloodMagic by WayofTime.
the class RitualUpgradeRemove method performRitual.
@Override
public void performRitual(IMasterRitualStone masterRitualStone) {
World world = masterRitualStone.getWorldObj();
if (world.isRemote) {
return;
}
BlockPos pos = masterRitualStone.getBlockPos();
AreaDescriptor checkRange = getBlockRange(CHECK_RANGE);
List<EntityPlayer> playerList = world.getEntitiesWithinAABB(EntityPlayer.class, checkRange.getAABB(pos));
for (EntityPlayer player : playerList) {
if (LivingArmour.hasFullSet(player)) {
boolean removedUpgrade = false;
ItemStack chestStack = Iterables.toArray(player.getArmorInventoryList(), ItemStack.class)[2];
LivingArmour armour = ItemLivingArmour.getLivingArmour(chestStack);
if (armour != null) {
@SuppressWarnings("unchecked") HashMap<String, LivingArmourUpgrade> upgradeMap = (HashMap<String, LivingArmourUpgrade>) armour.upgradeMap.clone();
for (Entry<String, LivingArmourUpgrade> entry : upgradeMap.entrySet()) {
LivingArmourUpgrade upgrade = entry.getValue();
String upgradeKey = entry.getKey();
ItemStack upgradeStack = new ItemStack(RegistrarBloodMagicItems.UPGRADE_TOME);
LivingUpgrades.setKey(upgradeStack, upgradeKey);
LivingUpgrades.setLevel(upgradeStack, upgrade.getUpgradeLevel());
boolean successful = armour.removeUpgrade(player, upgrade);
if (successful) {
removedUpgrade = true;
world.spawnEntity(new EntityItem(world, player.posX, player.posY, player.posZ, upgradeStack));
for (Entry<String, StatTracker> trackerEntry : armour.trackerMap.entrySet()) {
StatTracker tracker = trackerEntry.getValue();
if (tracker != null) {
if (tracker.providesUpgrade(upgradeKey)) {
// Resets the tracker if the upgrade corresponding to it was removed.
tracker.resetTracker();
}
}
}
}
}
if (removedUpgrade) {
((ItemLivingArmour) chestStack.getItem()).setLivingArmour(chestStack, armour, true);
ItemLivingArmour.setLivingArmour(chestStack, armour);
armour.recalculateUpgradePoints();
masterRitualStone.setActive(false);
world.spawnEntity(new EntityLightningBolt(world, pos.getX(), pos.getY() - 1, pos.getZ(), true));
}
}
}
}
}
use of WayofTime.bloodmagic.livingArmour.StatTracker in project BloodMagic by WayofTime.
the class StatTrackerGrimReaperSprint method incrementCounter.
public static void incrementCounter(LivingArmour armour) {
StatTracker tracker = armour.getTracker(BloodMagic.MODID + ".tracker.grimReaper");
if (tracker instanceof StatTrackerGrimReaperSprint) {
((StatTrackerGrimReaperSprint) tracker).totalDeaths++;
BMLog.DEBUG.info(String.valueOf(((StatTrackerGrimReaperSprint) tracker).totalDeaths));
tracker.markDirty();
}
// changeMap.put(armour, changeMap.containsKey(armour) ? changeMap.get(armour) + 1 : 1);
}
use of WayofTime.bloodmagic.livingArmour.StatTracker in project BloodMagic by WayofTime.
the class ItemLivingArmour method addInformation.
@Override
@SideOnly(Side.CLIENT)
public void addInformation(ItemStack stack, World world, List<String> tooltip, ITooltipFlag flag) {
if (!stack.hasTagCompound())
return;
if (this == RegistrarBloodMagicItems.LIVING_ARMOUR_CHEST) {
LivingArmour armour = getLivingArmourFromStack(stack);
for (Entry<String, LivingArmourUpgrade> entry : armour.upgradeMap.entrySet()) {
LivingArmourUpgrade upgrade = entry.getValue();
if (upgrade != null) {
if (Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) && Keyboard.isKeyDown(Keyboard.KEY_M)) {
StatTracker tracker = null;
for (StatTracker searchTracker : armour.trackerMap.values()) {
if (searchTracker != null && searchTracker.providesUpgrade(upgrade.getUniqueIdentifier())) {
tracker = searchTracker;
break;
}
}
if (tracker != null) {
double progress = tracker.getProgress(armour, upgrade.getUpgradeLevel());
tooltip.add(TextHelper.localize("tooltip.bloodmagic.livingArmour.upgrade.progress", TextHelper.localize(upgrade.getUnlocalizedName()), MathHelper.clamp((int) (progress * 100D), 0, 100)));
}
} else {
tooltip.add(TextHelper.localize("tooltip.bloodmagic.livingArmour.upgrade.level", TextHelper.localize(upgrade.getUnlocalizedName()), upgrade.getUpgradeLevel() + 1));
}
}
}
tooltip.add(TextHelper.localizeEffect("tooltip.bloodmagic.livingArmour.upgrade.points", armour.totalUpgradePoints, armour.maxUpgradePoints));
if (!(Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) && Keyboard.isKeyDown(Keyboard.KEY_M))) {
tooltip.add(TextHelper.localizeEffect("tooltip.bloodmagic.livingArmour.extraExtraInfo"));
}
}
super.addInformation(stack, world, tooltip, flag);
}
Aggregations