Search in sources :

Example 1 with IUpgradeRenderHandler

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

the class GuiPneumaticHelmet method getStatusText.

private List<String> getStatusText() {
    List<String> text = new ArrayList<String>();
    text.add("§7Air Usage:");
    float totalUsage = UpgradeRenderHandlerList.instance().getAirUsage(FMLClientHandler.instance().getClient().thePlayer, true);
    if (totalUsage > 0F) {
        EntityPlayer player = FMLClientHandler.instance().getClient().thePlayer;
        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(EnumChatFormatting.BLACK.toString() + PneumaticCraftUtils.roundNumberTo(upgradeUsage, 1) + " mL/tick (" + handler.getUpgradeName() + ")");
                }
            }
        }
        text.add("§0--------+");
        text.add("§0" + PneumaticCraftUtils.roundNumberTo(totalUsage, 1) + " mL/tick");
    } else {
        text.add(EnumChatFormatting.BLACK + "0.0 mL/tick");
    }
    text.add("§7Estimated time remaining:");
    int volume = ItemPneumaticArmor.getUpgrades(ItemMachineUpgrade.UPGRADE_VOLUME_DAMAGE, te.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("§0infinite");
        else
            text.add("§00s");
    } else {
        text.add("§0" + PneumaticCraftUtils.convertTicksToMinutesAndSeconds((int) (airLeft / totalUsage), false));
    }
    return text;
}
Also used : IUpgradeRenderHandler(pneumaticCraft.api.client.pneumaticHelmet.IUpgradeRenderHandler) ArrayList(java.util.ArrayList) EntityPlayer(net.minecraft.entity.player.EntityPlayer)

Example 2 with IUpgradeRenderHandler

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

the class HUDHandler method render2D.

private void render2D(float partialTicks) {
    Minecraft minecraft = FMLClientHandler.instance().getClient();
    EntityPlayer player = minecraft.thePlayer;
    ItemStack helmetStack = player.inventory.armorInventory[3];
    if (helmetStack != null && minecraft.inGameHasFocus && helmetStack.getItem() == Itemss.pneumaticHelmet) {
        ScaledResolution sr = new ScaledResolution(minecraft, minecraft.displayWidth, minecraft.displayHeight);
        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 == null) {
        messageList.clear();
    }
}
Also used : ScaledResolution(net.minecraft.client.gui.ScaledResolution) IUpgradeRenderHandler(pneumaticCraft.api.client.pneumaticHelmet.IUpgradeRenderHandler) CommonHUDHandler(pneumaticCraft.common.CommonHUDHandler) ArrayList(java.util.ArrayList) EntityPlayer(net.minecraft.entity.player.EntityPlayer) ItemStack(net.minecraft.item.ItemStack) Minecraft(net.minecraft.client.Minecraft) IGuiAnimatedStat(pneumaticCraft.api.client.IGuiAnimatedStat)

Example 3 with IUpgradeRenderHandler

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

the class GuiKeybindCheckBox method onMouseClicked.

@Override
public void onMouseClicked(int mouseX, int mouseY, int button) {
    if (button == 0) {
        super.onMouseClicked(mouseX, mouseY, button);
        GuiKeybindCheckBox trackedBox = trackedCheckboxes.get(keyBindingName);
        if (trackedBox != this) {
            trackedBox.onMouseClicked(mouseX, mouseY, button);
        } else {
            Config.config.get("pneumatic_helmet_widgetDefaults", keyBindingName, true).set(checked);
            Config.config.save();
            for (int i = 0; i < UpgradeRenderHandlerList.instance().upgradeRenderers.size(); i++) {
                IUpgradeRenderHandler upgradeRenderHandler = UpgradeRenderHandlerList.instance().upgradeRenderers.get(i);
                if (("pneumaticHelmet.upgrade." + upgradeRenderHandler.getUpgradeName()).equals(keyBindingName)) {
                    NetworkHandler.sendToServer(new PacketToggleHelmetFeature((byte) i, GuiKeybindCheckBox.trackedCheckboxes.get("pneumaticHelmet.upgrade.coreComponents").checked && checked));
                }
            }
            if (keyBindingName.equals("pneumaticHelmet.upgrade.coreComponents")) {
                for (int i = 0; i < UpgradeRenderHandlerList.instance().upgradeRenderers.size(); i++) {
                    NetworkHandler.sendToServer(new PacketToggleHelmetFeature((byte) i, checked && GuiKeybindCheckBox.trackedCheckboxes.get("pneumaticHelmet.upgrade." + UpgradeRenderHandlerList.instance().upgradeRenderers.get(i).getUpgradeName()).checked));
                }
            }
        }
    } else {
        isAwaitingKey = !isAwaitingKey;
        if (isAwaitingKey) {
            oldCheckboxText = text;
            text = "gui.setKeybind";
        } else {
            text = oldCheckboxText;
        }
    }
}
Also used : IUpgradeRenderHandler(pneumaticCraft.api.client.pneumaticHelmet.IUpgradeRenderHandler) PacketToggleHelmetFeature(pneumaticCraft.common.network.PacketToggleHelmetFeature)

Example 4 with IUpgradeRenderHandler

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

the class ClientTickHandler method tickEnd.

@SubscribeEvent
public void tickEnd(TickEvent.ClientTickEvent event) {
    if (event.phase == TickEvent.Phase.END) {
        if (Minecraft.getMinecraft().thePlayer == 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(pneumaticCraft.api.client.pneumaticHelmet.IUpgradeRenderHandler) INeedTickUpdate(pneumaticCraft.client.gui.INeedTickUpdate) SubscribeEvent(cpw.mods.fml.common.eventhandler.SubscribeEvent)

Example 5 with IUpgradeRenderHandler

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

the class GuiHelmetMainScreen method addPages.

private void addPages() {
    for (int i = 0; i < UpgradeRenderHandlerList.instance().upgradeRenderers.size(); i++) {
        if (init || 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(pneumaticCraft.api.client.pneumaticHelmet.IUpgradeRenderHandler) IOptionPage(pneumaticCraft.api.client.pneumaticHelmet.IOptionPage)

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