Search in sources :

Example 1 with IUpgradeRenderHandler

use of me.desht.pneumaticcraft.api.client.pneumaticHelmet.IUpgradeRenderHandler in project pnc-repressurized by TeamPneumatic.

the class HUDHandler method render2D.

private void render2D(float partialTicks) {
    Minecraft minecraft = FMLClientHandler.instance().getClient();
    EntityPlayer player = minecraft.player;
    ItemStack helmetStack = player.getItemStackFromSlot(EntityEquipmentSlot.HEAD);
    if (minecraft.inGameHasFocus && helmetStack.getItem() == Itemss.PNEUMATIC_HELMET) {
        ScaledResolution sr = new ScaledResolution(minecraft);
        GL11.glDepthMask(false);
        GL11.glDisable(GL11.GL_CULL_FACE);
        GL11.glDisable(GL11.GL_TEXTURE_2D);
        GL11.glPushMatrix();
        GL11.glClear(GL11.GL_DEPTH_BUFFER_BIT);
        GL11.glColor4d(0, 1, 0, 0.8D);
        CommonHUDHandler comHudHandler = CommonHUDHandler.getHandlerForPlayer(player);
        if (comHudHandler.ticksExisted <= comHudHandler.getStartupTime()) {
            // blockTrackInfo = null;
            gaveEmptyWarning = false;
            gaveNearlyEmptyWarning = false;
            RenderProgressBar.render(sr.getScaledWidth() / 2, 10, sr.getScaledWidth() - 10, 30, -90F, comHudHandler.ticksExisted * 100 / comHudHandler.getStartupTime());
        } else {
            if (comHudHandler.helmetPressure < 0.05F && !gaveEmptyWarning) {
                addMessage(new ArmorMessage("The helmet is out of air!", new ArrayList<String>(), 100, 0x70FF0000));
                gaveEmptyWarning = true;
            }
            if (comHudHandler.helmetPressure > 0.2F && comHudHandler.helmetPressure < 0.5F && !gaveNearlyEmptyWarning) {
                addMessage(new ArmorMessage("The helmet almost out of air!", new ArrayList<String>(), 60, 0x70FF0000));
                gaveNearlyEmptyWarning = true;
            }
            if (GuiKeybindCheckBox.trackedCheckboxes.get("pneumaticHelmet.upgrade.coreComponents").checked) {
                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) {
                            stat.render(-1, -1, partialTicks);
                        }
                        upgradeRenderHandler.render2D(partialTicks, comHudHandler.helmetPressure > 0F);
                    }
                }
            }
        }
        // render every item in the list.
        for (ArmorMessage message : messageList) {
            message.renderMessage(minecraft.fontRenderer, partialTicks);
        }
        GL11.glPopMatrix();
        GL11.glEnable(GL11.GL_CULL_FACE);
        GL11.glDepthMask(true);
        GL11.glEnable(GL11.GL_TEXTURE_2D);
        if (comHudHandler.ticksExisted <= comHudHandler.getStartupTime())
            minecraft.fontRenderer.drawString(CommonHUDHandler.getHandlerForPlayer().ticksExisted * 100 / comHudHandler.getStartupTime() + "%", sr.getScaledWidth() * 3 / 4 - 8, 16, 0x000000);
    } else if (helmetStack.isEmpty()) {
        messageList.clear();
    }
}
Also used : ScaledResolution(net.minecraft.client.gui.ScaledResolution) IUpgradeRenderHandler(me.desht.pneumaticcraft.api.client.pneumaticHelmet.IUpgradeRenderHandler) CommonHUDHandler(me.desht.pneumaticcraft.common.CommonHUDHandler) ArrayList(java.util.ArrayList) EntityPlayer(net.minecraft.entity.player.EntityPlayer) ItemStack(net.minecraft.item.ItemStack) Minecraft(net.minecraft.client.Minecraft) IGuiAnimatedStat(me.desht.pneumaticcraft.api.client.IGuiAnimatedStat)

Example 2 with IUpgradeRenderHandler

use of me.desht.pneumaticcraft.api.client.pneumaticHelmet.IUpgradeRenderHandler in project pnc-repressurized by TeamPneumatic.

the class GuiPneumaticHelmet method getStatusText.

private List<String> getStatusText() {
    List<String> text = new ArrayList<>();
    text.add("\u00a77Air Usage:");
    float totalUsage = UpgradeRenderHandlerList.instance().getAirUsage(FMLClientHandler.instance().getClient().player, true);
    if (totalUsage > 0F) {
        EntityPlayer player = FMLClientHandler.instance().getClient().player;
        for (int i = 0; i < UpgradeRenderHandlerList.instance().upgradeRenderers.size(); i++) {
            if (CommonHUDHandler.getHandlerForPlayer(player).upgradeRenderersInserted[i]) {
                IUpgradeRenderHandler handler = UpgradeRenderHandlerList.instance().upgradeRenderers.get(i);
                float upgradeUsage = handler.getEnergyUsage(CommonHUDHandler.getHandlerForPlayer(player).rangeUpgradesInstalled, player);
                if (upgradeUsage > 0F) {
                    text.add(TextFormatting.BLACK.toString() + PneumaticCraftUtils.roundNumberTo(upgradeUsage, 1) + " mL/tick (" + handler.getUpgradeName() + ")");
                }
            }
        }
        text.add("\u00a70--------+");
        text.add("\u00a70" + PneumaticCraftUtils.roundNumberTo(totalUsage, 1) + " mL/tick");
    } else {
        text.add(TextFormatting.BLACK + "0.0 mL/tick");
    }
    text.add("\u00a77Estimated time remaining:");
    int volume = ItemPneumaticArmor.getUpgrades(EnumUpgrade.VOLUME, te.getPrimaryInventory().getStackInSlot(TileEntityChargingStation.CHARGE_INVENTORY_INDEX)) * PneumaticValues.VOLUME_VOLUME_UPGRADE + getDefaultVolume();
    int airLeft = (int) (((IPressurizable) itemStack.getItem()).getPressure(itemStack) * volume);
    if (totalUsage == 0) {
        if (airLeft > 0)
            text.add("\u00a70infinite");
        else
            text.add("\u00a700s");
    } else {
        text.add("\u00a70" + PneumaticCraftUtils.convertTicksToMinutesAndSeconds((int) (airLeft / totalUsage), false));
    }
    return text;
}
Also used : IUpgradeRenderHandler(me.desht.pneumaticcraft.api.client.pneumaticHelmet.IUpgradeRenderHandler) ArrayList(java.util.ArrayList) EntityPlayer(net.minecraft.entity.player.EntityPlayer)

Example 3 with IUpgradeRenderHandler

use of me.desht.pneumaticcraft.api.client.pneumaticHelmet.IUpgradeRenderHandler in project pnc-repressurized by TeamPneumatic.

the class ClientTickHandler method tickEnd.

@SubscribeEvent
public void tickEnd(TickEvent.ClientTickEvent event) {
    if (event.phase == TickEvent.Phase.END) {
        if (Minecraft.getMinecraft().player == null) {
            for (IUpgradeRenderHandler handler : UpgradeRenderHandlerList.instance().upgradeRenderers) {
                handler.reset();
            }
        }
        TICKS++;
        ModuleRegulatorTube.hasTicked = false;
        ModuleRegulatorTube.inverted = false;
        ModuleRegulatorTube.inLine = true;
        for (int i = 0; i < updatedObjects.size(); i++) {
            INeedTickUpdate updatedObject = updatedObjects.get(i).get();
            if (updatedObject != null) {
                updatedObject.update();
            } else {
                updatedObjects.remove(i);
                i--;
            }
        }
    }
}
Also used : IUpgradeRenderHandler(me.desht.pneumaticcraft.api.client.pneumaticHelmet.IUpgradeRenderHandler) INeedTickUpdate(me.desht.pneumaticcraft.client.gui.INeedTickUpdate) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Example 4 with IUpgradeRenderHandler

use of me.desht.pneumaticcraft.api.client.pneumaticHelmet.IUpgradeRenderHandler in project pnc-repressurized by TeamPneumatic.

the class GuiHelmetMainScreen method addPages.

private void addPages() {
    for (int i = 0; i < UpgradeRenderHandlerList.instance().upgradeRenderers.size(); i++) {
        if (inInitPhase || CommonHUDHandler.getHandlerForPlayer().upgradeRenderersInserted[i]) {
            IUpgradeRenderHandler upgradeRenderHandler = UpgradeRenderHandlerList.instance().upgradeRenderers.get(i);
            IOptionPage optionPage = upgradeRenderHandler.getGuiOptionsPage();
            if (optionPage != null) {
                upgradePageNames.add(upgradeRenderHandler.getUpgradeName());
                upgradePages.add(optionPage);
            }
        }
    }
}
Also used : IUpgradeRenderHandler(me.desht.pneumaticcraft.api.client.pneumaticHelmet.IUpgradeRenderHandler) IOptionPage(me.desht.pneumaticcraft.api.client.pneumaticHelmet.IOptionPage)

Example 5 with IUpgradeRenderHandler

use of me.desht.pneumaticcraft.api.client.pneumaticHelmet.IUpgradeRenderHandler in project pnc-repressurized by TeamPneumatic.

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.world.playSound(player.posX, player.posY, player.posZ, Sounds.HUD_INIT, SoundCategory.PLAYERS, 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.world.playSound(player.posX, player.posY, player.posZ, Sounds.HUD_INIT, SoundCategory.PLAYERS, 0.1F, 0.5F, true);
        addMessage(new ArmorMessage("Initializing head-up display...", Collections.emptyList(), 50, 0x7000AA00));
    }
    if (comHudHandler.ticksExisted == comHudHandler.getStartupTime()) {
        player.world.playSound(player.posX, player.posY, player.posZ, Sounds.HUD_INIT_COMPLETE, SoundCategory.PLAYERS, 0.1F, 1.0F, true);
        addMessage(new ArmorMessage("Initialization complete!", Collections.emptyList(), 50, 0x7000AA00));
    }
}
Also used : IUpgradeRenderHandler(me.desht.pneumaticcraft.api.client.pneumaticHelmet.IUpgradeRenderHandler) CommonHUDHandler(me.desht.pneumaticcraft.common.CommonHUDHandler) ArrayList(java.util.ArrayList) PacketToggleHelmetFeature(me.desht.pneumaticcraft.common.network.PacketToggleHelmetFeature) IGuiAnimatedStat(me.desht.pneumaticcraft.api.client.IGuiAnimatedStat)

Aggregations

IUpgradeRenderHandler (me.desht.pneumaticcraft.api.client.pneumaticHelmet.IUpgradeRenderHandler)6 ArrayList (java.util.ArrayList)3 IGuiAnimatedStat (me.desht.pneumaticcraft.api.client.IGuiAnimatedStat)2 CommonHUDHandler (me.desht.pneumaticcraft.common.CommonHUDHandler)2 PacketToggleHelmetFeature (me.desht.pneumaticcraft.common.network.PacketToggleHelmetFeature)2 EntityPlayer (net.minecraft.entity.player.EntityPlayer)2 IOException (java.io.IOException)1 IOptionPage (me.desht.pneumaticcraft.api.client.pneumaticHelmet.IOptionPage)1 INeedTickUpdate (me.desht.pneumaticcraft.client.gui.INeedTickUpdate)1 Minecraft (net.minecraft.client.Minecraft)1 ScaledResolution (net.minecraft.client.gui.ScaledResolution)1 ItemStack (net.minecraft.item.ItemStack)1 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)1