Search in sources :

Example 6 with IUpgradeRenderHandler

use of pneumaticCraft.api.client.pneumaticHelmet.IUpgradeRenderHandler in project PneumaticCraft by MineMaarten.

the class HUDHandler method update.

private void update(EntityPlayer player) {
    for (ArmorMessage message : messageList) {
        message.getStat().update();
    }
    CommonHUDHandler comHudHandler = CommonHUDHandler.getHandlerForPlayer(player);
    boolean helmetEnabled = GuiKeybindCheckBox.trackedCheckboxes.get("pneumaticHelmet.upgrade.coreComponents").checked;
    if (comHudHandler.ticksExisted == 1) {
        for (IUpgradeRenderHandler handler : UpgradeRenderHandlerList.instance().upgradeRenderers) {
            handler.reset();
        }
        for (int i = 0; i < comHudHandler.upgradeRenderersEnabled.length; i++) {
            NetworkHandler.sendToServer(new PacketToggleHelmetFeature((byte) i, helmetEnabled && GuiKeybindCheckBox.trackedCheckboxes.get("pneumaticHelmet.upgrade." + UpgradeRenderHandlerList.instance().upgradeRenderers.get(i).getUpgradeName()).checked));
        }
    }
    if (comHudHandler.ticksExisted > comHudHandler.getStartupTime() && helmetEnabled) {
        for (int i = 0; i < UpgradeRenderHandlerList.instance().upgradeRenderers.size(); i++) {
            IUpgradeRenderHandler upgradeRenderHandler = UpgradeRenderHandlerList.instance().upgradeRenderers.get(i);
            if (comHudHandler.upgradeRenderersInserted[i] && GuiKeybindCheckBox.trackedCheckboxes.get("pneumaticHelmet.upgrade." + upgradeRenderHandler.getUpgradeName()).checked) {
                IGuiAnimatedStat stat = upgradeRenderHandler.getAnimatedStat();
                if (stat != null) {
                    if (comHudHandler.helmetPressure > 0F) {
                        stat.openWindow();
                    } else {
                        stat.closeWindow();
                    }
                    stat.update();
                }
                upgradeRenderHandler.update(player, comHudHandler.rangeUpgradesInstalled);
            }
        }
    }
    // clean the list
    for (int i = 0; i < messageList.size(); i++) {
        ArmorMessage message = messageList.get(i);
        if (message == null || --message.lifeSpan <= 0) {
            messageList.remove(i);
            i--;
        }
    }
    for (int i = 0; i < UpgradeRenderHandlerList.instance().upgradeRenderers.size(); i++) {
        if (comHudHandler.ticksExisted == comHudHandler.getStartupTime() / (UpgradeRenderHandlerList.instance().upgradeRenderers.size() + 2) * (i + 1)) {
            player.worldObj.playSound(player.posX, player.posY, player.posZ, Sounds.HUD_INIT, 0.1F, 0.5F + (float) (i + 1) / (UpgradeRenderHandlerList.instance().upgradeRenderers.size() + 2) * 0.5F, true);
            boolean upgradeEnabled = comHudHandler.upgradeRenderersInserted[i];
            addMessage(new ArmorMessage(I18n.format("pneumaticHelmet.upgrade." + UpgradeRenderHandlerList.instance().upgradeRenderers.get(i).getUpgradeName()) + " " + (upgradeEnabled ? "found" : "not installed"), new ArrayList<String>(), 50, upgradeEnabled ? 0x7000AA00 : 0x70FF0000));
        }
    }
    if (comHudHandler.ticksExisted == 1) {
        player.worldObj.playSound(player.posX, player.posY, player.posZ, Sounds.HUD_INIT, 0.1F, 0.5F, true);
        addMessage(new ArmorMessage("Initializing head-up display...", new ArrayList<String>(), 50, 0x7000AA00));
    }
    if (comHudHandler.ticksExisted == comHudHandler.getStartupTime()) {
        player.worldObj.playSound(player.posX, player.posY, player.posZ, Sounds.HUD_INIT_COMPLETE, 0.1F, 1.0F, true);
        addMessage(new ArmorMessage("Initialization complete!", new ArrayList<String>(), 50, 0x7000AA00));
    }
}
Also used : IUpgradeRenderHandler(pneumaticCraft.api.client.pneumaticHelmet.IUpgradeRenderHandler) CommonHUDHandler(pneumaticCraft.common.CommonHUDHandler) ArrayList(java.util.ArrayList) PacketToggleHelmetFeature(pneumaticCraft.common.network.PacketToggleHelmetFeature) IGuiAnimatedStat(pneumaticCraft.api.client.IGuiAnimatedStat)

Aggregations

IUpgradeRenderHandler (pneumaticCraft.api.client.pneumaticHelmet.IUpgradeRenderHandler)6 ArrayList (java.util.ArrayList)3 EntityPlayer (net.minecraft.entity.player.EntityPlayer)2 IGuiAnimatedStat (pneumaticCraft.api.client.IGuiAnimatedStat)2 CommonHUDHandler (pneumaticCraft.common.CommonHUDHandler)2 PacketToggleHelmetFeature (pneumaticCraft.common.network.PacketToggleHelmetFeature)2 SubscribeEvent (cpw.mods.fml.common.eventhandler.SubscribeEvent)1 Minecraft (net.minecraft.client.Minecraft)1 ScaledResolution (net.minecraft.client.gui.ScaledResolution)1 ItemStack (net.minecraft.item.ItemStack)1 IOptionPage (pneumaticCraft.api.client.pneumaticHelmet.IOptionPage)1 INeedTickUpdate (pneumaticCraft.client.gui.INeedTickUpdate)1