Search in sources :

Example 1 with StatTracker

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));
                }
            }
        }
    }
}
Also used : ItemLivingArmour(WayofTime.bloodmagic.item.armour.ItemLivingArmour) LivingArmour(WayofTime.bloodmagic.livingArmour.LivingArmour) ItemLivingArmour(WayofTime.bloodmagic.item.armour.ItemLivingArmour) HashMap(java.util.HashMap) LivingArmourUpgrade(WayofTime.bloodmagic.livingArmour.LivingArmourUpgrade) EntityLightningBolt(net.minecraft.entity.effect.EntityLightningBolt) World(net.minecraft.world.World) EntityPlayer(net.minecraft.entity.player.EntityPlayer) StatTracker(WayofTime.bloodmagic.livingArmour.StatTracker) BlockPos(net.minecraft.util.math.BlockPos) ItemStack(net.minecraft.item.ItemStack) EntityItem(net.minecraft.entity.item.EntityItem)

Example 2 with StatTracker

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);
}
Also used : StatTracker(WayofTime.bloodmagic.livingArmour.StatTracker)

Example 3 with StatTracker

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);
}
Also used : LivingArmour(WayofTime.bloodmagic.livingArmour.LivingArmour) LivingArmourUpgrade(WayofTime.bloodmagic.livingArmour.LivingArmourUpgrade) StatTracker(WayofTime.bloodmagic.livingArmour.StatTracker) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Aggregations

StatTracker (WayofTime.bloodmagic.livingArmour.StatTracker)3 LivingArmour (WayofTime.bloodmagic.livingArmour.LivingArmour)2 LivingArmourUpgrade (WayofTime.bloodmagic.livingArmour.LivingArmourUpgrade)2 ItemLivingArmour (WayofTime.bloodmagic.item.armour.ItemLivingArmour)1 HashMap (java.util.HashMap)1 EntityLightningBolt (net.minecraft.entity.effect.EntityLightningBolt)1 EntityItem (net.minecraft.entity.item.EntityItem)1 EntityPlayer (net.minecraft.entity.player.EntityPlayer)1 ItemStack (net.minecraft.item.ItemStack)1 BlockPos (net.minecraft.util.math.BlockPos)1 World (net.minecraft.world.World)1 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)1