Search in sources :

Example 26 with FontRenderer

use of net.minecraft.client.gui.FontRenderer in project Tropicraft by Tropicraft.

the class ScubaOverlayHandler method onRenderOverlay.

@SubscribeEvent
public void onRenderOverlay(RenderGameOverlayEvent.Text event) {
    // Check to see if player inventory contains dive computer
    float airRemaining = -1, airTemp, timeRemaining = 0, yaw;
    int blocksAbove, blocksBelow, currentDepth, maxDepth;
    EntityPlayer player = Minecraft.getMinecraft().player;
    FontRenderer fr = Minecraft.getMinecraft().fontRenderer;
    ScaledResolution sr = new ScaledResolution(Minecraft.getMinecraft());
    ItemStack helmet = player.getItemStackFromSlot(EntityEquipmentSlot.HEAD);
    if (helmet == null || !(helmet.getItem() instanceof ItemScubaHelmet)) {
        return;
    }
    ItemStack chestplate = player.getItemStackFromSlot(EntityEquipmentSlot.CHEST);
    IScubaGear gear = chestplate != null ? chestplate.getCapability(ScubaCapabilities.getGearCapability(), null) : null;
    maxDepth = getTagCompound(helmet).getInteger("MaxDepth");
    blocksAbove = getTagCompound(helmet).getInteger("WaterBlocksAbove");
    blocksBelow = getTagCompound(helmet).getInteger("WaterBlocksBelow");
    if (gear != null) {
        airRemaining = gear.getTotalPressure();
        timeRemaining += getTimeRemaining(gear.getTanks().getLeft());
        timeRemaining += getTimeRemaining(gear.getTanks().getRight());
    }
    airTemp = player.world.getBiomeForCoordsBody(new BlockPos(MathHelper.floor(player.posX), 0, MathHelper.floor(player.posZ))).getTemperature(player.getPosition());
    yaw = player.rotationYaw;
    int size = 100;
    int offset = -size / 2;
    GlStateManager.pushMatrix();
    GlStateManager.translate(sr.getScaledWidth() + offset - 20, 120, 0);
    GlStateManager.rotate(yaw + 180, 0.0F, 0.0F, -1.0F);
    Minecraft.getMinecraft().getTextureManager().bindTexture(TropicraftRenderUtils.getTextureGui("compass_background"));
    drawModalRectWithCustomSizedTexture(offset, offset, 0, 0, size, size, size, size);
    GlStateManager.popMatrix();
    // TODO make locations of text configurable
    GlStateManager.pushMatrix();
    if (gear != null) {
        drawString(fr, "psi", sr.getScaledWidth() - 50, 48, 0xffffff);
        // TODO display warning if air is running low / out
        drawString(fr, "Air", sr.getScaledWidth() - 75, 34, 0xffffff);
    }
    GlStateManager.scale(1.5F, 1.5F, 1.0F);
    if (gear != null) {
        String psi = String.format("%.0f", airRemaining);
        drawString(fr, psi, (int) ((sr.getScaledWidth() - 50) / 1.5f) - fr.getStringWidth(psi) - 1, 30, 0x00ccde);
    }
    // Current depth
    drawString(fr, TropicraftRenderUtils.translateGUI("currentDepth") + ": " + blocksAbove, 4, 70, 0xbbbbff);
    GlStateManager.popMatrix();
    drawString(fr, TropicraftRenderUtils.translateGUI("maxDepth") + ": " + maxDepth, 6, 130, 0xffffffff);
    drawString(fr, (airTemp * 50) + " F", 6, 150, 0xffffffff);
    if (gear != null) {
        // TODO localize
        String timeUnits = timeRemaining <= 60 ? "secs" : "mins";
        timeRemaining = timeRemaining <= 60 ? timeRemaining : timeRemaining / 60;
        drawString(fr, TropicraftRenderUtils.translateGUI("timeRemaining"), 30, 34, 0xffffff);
        drawString(fr, String.format("%.0f %s", timeRemaining, timeUnits), 33, 45, 0xF6EB12);
    }
    GlStateManager.depthMask(true);
    GlStateManager.enableAlpha();
    GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
}
Also used : ScaledResolution(net.minecraft.client.gui.ScaledResolution) IScubaGear(net.tropicraft.core.common.item.scuba.api.IScubaGear) EntityPlayer(net.minecraft.entity.player.EntityPlayer) ItemScubaHelmet(net.tropicraft.core.common.item.scuba.ItemScubaHelmet) BlockPos(net.minecraft.util.math.BlockPos) FontRenderer(net.minecraft.client.gui.FontRenderer) ItemStack(net.minecraft.item.ItemStack) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Example 27 with FontRenderer

use of net.minecraft.client.gui.FontRenderer in project Tropicraft by Tropicraft.

the class GuiClearButton method drawButton.

@Override
public void drawButton(Minecraft minecraft, int i, int j, float partialTicks) {
    if (!visible) {
        return;
    }
    boolean flag = i >= xPosition && j >= yPosition && i < xPosition + width && j < yPosition + height;
    FontRenderer fontrenderer = minecraft.fontRenderer;
    RenderHelper.disableStandardItemLighting();
    GlStateManager.disableLighting();
    // glDisable(2929 /*GL_DEPTH_TEST*/);
    GlStateManager.disableDepth();
    GlStateManager.pushMatrix();
    TropicraftRenderUtils.bindTextureGui(buttonImageLoc);
    GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
    int k = getHoverState(flag);
    drawTexturedModalRect(xPosition, yPosition, type * 22 + 168 + (k - 1) * 11, 236, 11, 20);
    GlStateManager.popMatrix();
    mouseDragged(minecraft, i, j);
    if (!enabled) {
        fontrenderer.drawString(displayString, xPosition, yPosition + (height - 8) / 2, 0xffa0a0a0);
    } else if (flag) {
        fontrenderer.drawString(displayString, xPosition, yPosition + (height - 8) / 2, 0x990000);
    } else {
        fontrenderer.drawString(displayString, xPosition, yPosition + (height - 8) / 2, color);
    }
    GlStateManager.enableLighting();
    GlStateManager.enableDepth();
// GL11.glEnable(2896 /*GL_LIGHTING*/);
// GL11.glEnable(2929 /*GL_DEPTH_TEST*/);
}
Also used : FontRenderer(net.minecraft.client.gui.FontRenderer)

Example 28 with FontRenderer

use of net.minecraft.client.gui.FontRenderer in project EnderIO by SleepyTrousers.

the class ExperienceBarRenderer method render.

public static void render(@Nonnull Gui gui, int x, int y, int length, @Nonnull ExperienceContainer xpCont, int required) {
    String text = xpCont.getExperienceLevel() + "";
    int color = 8453920;
    boolean shadow = true;
    if (required > 0) {
        text += "/" + required;
        if (required > xpCont.getExperienceLevel()) {
            color = ColorUtil.getRGB(1f, 0, 0.1f);
            shadow = false;
        }
    }
    FontRenderer fr = Minecraft.getMinecraft().fontRenderer;
    int strX = x + length / 2 - fr.getStringWidth(text) / 2;
    fr.drawString(text, strX, y - 11, color, shadow);
    RenderUtil.bindTexture(IconEIO.TEXTURE);
    GlStateManager.color(1f, 1f, 1f, 1f);
    int xpScaled = xpCont.getXpBarScaled(length - 2);
    // x, y, u, v, width, height
    // start of 'slot'
    gui.drawTexturedModalRect(x, y, 0, 91, 1, 5);
    gui.drawTexturedModalRect(x + 1, y, 1, 91, length - 2, 5);
    gui.drawTexturedModalRect(x + length - 1, y, 125, 91, 1, 5);
    RenderUtil.renderQuad2D(x + 1, y + 1, 0, xpScaled, 3, ColorUtil.getRGB(0, 127, 14));
}
Also used : FontRenderer(net.minecraft.client.gui.FontRenderer)

Example 29 with FontRenderer

use of net.minecraft.client.gui.FontRenderer in project EnderIO by SleepyTrousers.

the class BaseSettingsPanel method render.

@Override
public void render(float par1, int par2, int par3) {
    FontRenderer fr = gui.getFontRenderer();
    int rgb = ColorUtil.getRGB(Color.darkGray);
    int x = left + 32;
    int y = gui.getGuiTop() + 10;
    fr.drawString(inputHeading, x, y, rgb);
    if (hasInputOutputMode) {
        x += 92;
        fr.drawString(outputHeading, x, y, rgb);
    }
    renderCustomOptions(y + gap + fr.FONT_HEIGHT + gap, par1, par2, par3);
}
Also used : FontRenderer(net.minecraft.client.gui.FontRenderer)

Example 30 with FontRenderer

use of net.minecraft.client.gui.FontRenderer in project EnderIO by SleepyTrousers.

the class GuiInventoryPanel method drawGuiContainerBackgroundLayer.

@Override
protected void drawGuiContainerBackgroundLayer(float par1, int mouseX, int mouseY) {
    syncSettingsChange();
    GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
    bindGuiTexture();
    int sx = guiLeft;
    int sy = guiTop;
    drawTexturedModalRect(sx + 24, sy, 0, 0, 232, ySize);
    drawTexturedModalRect(sx + 24 + 232, sy, 232, 0, 24, 68);
    if (craftingHelper != null || getContainer().hasCraftingRecipe()) {
        boolean hover = btnRefill.contains(mouseX - sx, mouseY - sy);
        int iconX = hover ? (isShiftKeyDown() ? 48 : 24) : 0;
        drawTexturedModalRect(sx + btnRefill.x - 2, sy + btnRefill.y - 2, iconX, 232, 24, 24);
    }
    TileInventoryPanel te = getTileEntity();
    int y = sy;
    int numStoredRecipes = te.getStoredCraftingRecipes();
    if (numStoredRecipes == 1) {
        drawTexturedModalRect(sx, y, 227, 225, 28, 30);
        y += 30;
    } else if (numStoredRecipes > 1) {
        drawTexturedModalRect(sx, y, 227, 225, 28, 24);
        y += 24;
        for (int i = 1; i < numStoredRecipes - 1; i++) {
            drawTexturedModalRect(sx, y, 198, 229, 28, 20);
            y += 20;
        }
        drawTexturedModalRect(sx, y, 198, 229, 28, 26);
        y += 26;
    }
    if (numStoredRecipes < TileInventoryPanel.MAX_STORED_CRAFTING_RECIPES && getContainer().hasNewCraftingRecipe()) {
        y += 2;
        btnAddStoredRecipe.x = 13;
        btnAddStoredRecipe.y = y - sy;
        btnAddStoredRecipe.width = 12;
        btnAddStoredRecipe.height = 14;
        boolean hover = btnAddStoredRecipe.contains(mouseX - sx, mouseY - sy);
        drawTexturedModalRect(sx + 13, y, 182, hover ? 241 : 225, 15, 14);
    } else {
        btnAddStoredRecipe.width = 0;
        btnAddStoredRecipe.height = 0;
    }
    SmartTank fuelTank = te.fuelTank;
    if (!InvpanelConfig.inventoryPanelFree.get()) {
        drawTexturedModalRect(sx + 35, sy + 132, 232, 163, 18, 49);
        if (fuelTank.getFluidAmount() > 0) {
            RenderUtil.renderGuiTank(fuelTank.getFluid(), fuelTank.getCapacity(), fuelTank.getFluidAmount(), sx + 24 + 12, sy + 133, zLevel, 16, 47);
        }
    }
    final EnderWidget returnButton = te.isExtractionDisabled() ? btnReturnArea.contains(mouseX - sx, mouseY - sy) ? EnderWidget.STOP_BUT_HOVER : EnderWidget.STOP_BUT : btnReturnArea.contains(mouseX - sx, mouseY - sy) ? EnderWidget.RETURN_BUT_HOVER : EnderWidget.RETURN_BUT;
    GlStateManager.color(1, 1, 1, 1);
    EnderWidget.RETURN_BUT.getMap().render(returnButton, sx + 24 + 7, sy + 72, true);
    int headerColor = 0x404040;
    int focusedColor = 0x648494;
    FontRenderer fr = getFontRenderer();
    fr.drawString(headerCrafting, sx + 24 + 7, sy + 6, headerColor);
    fr.drawString(te.isExtractionDisabled() ? headerStorage : headerReturn, sx + 24 + 7 + 10, sy + 72, btnReturnArea.contains(mouseX - sx, mouseY - sy) ? focusedColor : headerColor);
    fr.drawString(headerInventory, sx + 24 + 38, sy + 120, headerColor);
    super.drawGuiContainerBackgroundLayer(par1, mouseX, mouseY);
    if (JeiAccessor.isJeiRuntimeAvailable() && btnSync.isSelected()) {
        updateFromJEI();
    }
    view.setDatabase(getDatabase());
    view.setItemFilter(te.getItemFilter());
    view.updateFilter(tfFilter.getText());
    boolean update = view.sortItems();
    scrollbar.setScrollMax(Math.max(0, (view.getNumEntries() + GHOST_COLUMNS - 1) / GHOST_COLUMNS - GHOST_ROWS));
    if (update || scrollPos != scrollbar.getScrollPos()) {
        updateGhostSlots();
    }
    if (te.isActive()) {
        tfFilter.setEnabled(true);
        if (!tfFilter.isFocused() && tfFilter.getText().isEmpty()) {
            fr.drawString(infoTextFilter, tfFilter.x, tfFilter.y, 0x707070);
        }
    } else {
        tfFilter.setEnabled(false);
        setText(tfFilter, "");
        fr.drawString(infoTextOffline, tfFilter.x, tfFilter.y, 0x707070);
    }
}
Also used : EnderWidget(com.enderio.core.client.render.EnderWidget) FontRenderer(net.minecraft.client.gui.FontRenderer) SmartTank(com.enderio.core.common.fluid.SmartTank)

Aggregations

FontRenderer (net.minecraft.client.gui.FontRenderer)266 ScaledResolution (net.minecraft.client.gui.ScaledResolution)45 Minecraft (net.minecraft.client.Minecraft)39 ItemStack (net.minecraft.item.ItemStack)30 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)13 ArrayList (java.util.ArrayList)12 Tessellator (net.minecraft.client.renderer.Tessellator)11 RenderItem (net.minecraft.client.renderer.RenderItem)10 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)10 EntityPlayer (net.minecraft.entity.player.EntityPlayer)8 BufferBuilder (net.minecraft.client.renderer.BufferBuilder)7 IBlockState (net.minecraft.block.state.IBlockState)6 Block (net.minecraft.block.Block)5 GuiButton (net.minecraft.client.gui.GuiButton)5 List (java.util.List)4 RenderManager (net.minecraft.client.renderer.entity.RenderManager)4 ResourceLocation (net.minecraft.util.ResourceLocation)4 IGuiRect (betterquesting.api2.client.gui.misc.IGuiRect)3 Bounds (ivorius.reccomplex.gui.table.Bounds)3 Item (net.minecraft.item.Item)3