Search in sources :

Example 46 with FontRenderer

use of net.minecraft.client.gui.FontRenderer in project OpenModularTurrets by OpenModularTurretsTeam.

the class TurretBaseAbstractGui method drawGuiContainerForegroundLayer.

@SuppressWarnings("unchecked")
@Override
protected void drawGuiContainerForegroundLayer(int param1, int param2) {
    FontRenderer fontRenderer = Minecraft.getMinecraft().fontRenderer;
    fontRenderer.drawString(base.getTier() > 1 ? safeLocalize(OMTNames.Localizations.GUI.ADDONS) : "", 71, 6, 0);
    fontRenderer.drawString(base.getTier() > 1 ? safeLocalize(OMTNames.Localizations.GUI.UPGRADES) : "", 71, 39, 0);
    fontRenderer.drawString(safeLocalize(OMTNames.Localizations.GUI.AMMO), 8, 6, 0);
    fontRenderer.drawString(safeLocalize(OMTNames.Localizations.GUI.INVENTORY), 8, ySize - 97 + 4, 0);
    fontRenderer.drawStringWithShadow("" + base.getCurrentMaxRange(), String.valueOf(base.getCurrentMaxRange()).length() == 1 ? 127 : 124, 39, base.getCurrentMaxRange() == getBaseUpperBoundRange() ? 16724530 : 40000);
    fontRenderer.drawString(safeLocalize(OMTNames.Localizations.GUI.RANGE), 116, 6, 0);
    ArrayList targetInfo = new ArrayList();
    targetInfo.add("\u00A76" + safeLocalize(OMLibNames.Localizations.GUI.OWNER) + ": \u00A7f" + base.getOwnerName());
    targetInfo.add("\u00A76" + safeLocalize(OMLibNames.Localizations.GUI.MODE) + ": \u00A7f" + getMachineModeLocalization(base.getMode()));
    boolean isCurrentlyOn = base.isActive();
    targetInfo.add("\u00A76" + safeLocalize(OMLibNames.Localizations.GUI.ACTIVE) + ": " + getColoredBooleanLocalizationYesNo(isCurrentlyOn));
    targetInfo.add("");
    targetInfo.add("\u00A76" + safeLocalize(OMTNames.Localizations.GUI.KILLS) + ": " + base.getKills());
    targetInfo.add("\u00A76" + safeLocalize(OMTNames.Localizations.GUI.PLAYER_KILLS) + ": " + base.getPlayerKills());
    targetInfo.add("");
    if (base.getTrustedPlayers().size() != 0) {
        targetInfo.add("\u00A75" + safeLocalize(OMTNames.Localizations.GUI.TRUSTED_PLAYERS) + ":");
        for (TrustedPlayer trusted_player : base.getTrustedPlayers()) {
            targetInfo.add("\u00A7b" + trusted_player.name);
        }
    } else {
        targetInfo.add("\u00A75" + safeLocalize(OMTNames.Localizations.GUI.TRUSTED_PLAYERS) + ": " + getColoredBooleanLocalizationYesNo(false));
    }
    targetInfo.add("");
    targetInfo.add("\u00A77" + safeLocalize(OMTNames.Localizations.GUI.ATTACK_MOBS) + ": " + getColoredBooleanLocalizationYesNo(base.isAttacksMobs()));
    targetInfo.add("\u00A77" + safeLocalize(OMTNames.Localizations.GUI.ATTACK_NEUTRALS) + ": " + getColoredBooleanLocalizationYesNo(base.isAttacksNeutrals()));
    targetInfo.add("\u00A77" + safeLocalize(OMTNames.Localizations.GUI.ATTACK_PLAYERS) + ": " + getColoredBooleanLocalizationYesNo(base.isAttacksPlayers()));
    this.drawHoveringText(targetInfo, -128, 17, fontRenderer);
    drawTooltips();
    super.drawGuiContainerForegroundLayer(mouseX, mouseY);
}
Also used : TrustedPlayer(omtteam.omlib.util.TrustedPlayer) ArrayList(java.util.ArrayList) FontRenderer(net.minecraft.client.gui.FontRenderer)

Example 47 with FontRenderer

use of net.minecraft.client.gui.FontRenderer in project IDEProgram by Itay2805.

the class BlueJCodeEditor method render.

@Override
protected void render(Laptop laptop, Minecraft mc, int x, int y, int mouseX, int mouseY, boolean windowActive, float partialTicks) {
    if (!visible)
        return;
    GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
    Gui.drawRect(xPosition, yPosition, xPosition + width, yPosition + height, backgroundColor);
    FontRenderer font = Minecraft.getMinecraft().fontRendererObj;
    // render text
    if (highlighter == null) {
        // no highlighter
        IDEModProgramThingy.LOGGER.info("No highlighter attached! Using default highlighting!");
        for (int i = from; i < from + maxLines; i++) {
            if (i >= lines.size()) {
                break;
            }
            int Y = i * font.FONT_HEIGHT;
            font.drawString(lines.get(i).replace("\t", "    "), 2 + xPosition, 2 + yPosition + Y, Color.WHITE.getRGB());
        }
    } else {
        // with highlight
        IDEModProgramThingy.LOGGER.info("Using highlighter for: " + highlighter.getName());
        for (int i = from; i < from + maxLines; i++) {
            if (i >= lines.size()) {
                break;
            }
            int Y = i * font.FONT_HEIGHT;
            int X = 0;
            for (Token token : tokens) {
                String text = "";
                if (token instanceof StaticToken) {
                    text = ((StaticToken) token).getToken().replace("\t", "    ");
                } else if (token instanceof DynamicToken) {
                    text = ((DynamicToken) token).getToken().replace("\t", "    ");
                }
                font.drawString(text, 2 + xPosition + X, 2 + yPosition + Y, token.getColor());
                X += font.getStringWidth(text);
            }
        }
        for (Problem problem : problems) {
            if (from >= problem.getLine() || from + maxLines < problem.getLine()) {
                continue;
            }
            int X = font.getStringWidth(lines.get(problem.getLine()).substring(0, problem.getColumn()));
            int Y = problem.getLine() * font.FONT_HEIGHT * 2;
            int length = problem.getLength();
            while ((length--) > 0) {
                font.drawString("~", 2 + xPosition + X, 2 + yPosition + Y, problem.getColor());
                X += errorLength;
            }
        }
    }
    if (editable) {
        // render cursor
        if (cursorState) {
            int X = font.getStringWidth(getCurrentLine().substring(0, cursorX).replace("\t", "   "));
            int Y = (cursorY - from) * font.FONT_HEIGHT;
            font.drawString("|", 2 + xPosition + X, 2 + yPosition + Y, cursorColor);
        }
    }
}
Also used : DynamicToken(me.itay.idemodthingy.programs.bluej.api.tokens.DynamicToken) StaticToken(me.itay.idemodthingy.programs.bluej.api.tokens.StaticToken) Token(me.itay.idemodthingy.programs.bluej.api.tokens.Token) Problem(me.itay.idemodthingy.programs.bluej.api.Problem) FontRenderer(net.minecraft.client.gui.FontRenderer) DynamicToken(me.itay.idemodthingy.programs.bluej.api.tokens.DynamicToken) StaticToken(me.itay.idemodthingy.programs.bluej.api.tokens.StaticToken)

Example 48 with FontRenderer

use of net.minecraft.client.gui.FontRenderer in project Cavern2 by kegare.

the class MinerStatsHUDEventHooks method onRenderGamePostOverlay.

@SubscribeEvent
public void onRenderGamePostOverlay(RenderGameOverlayEvent.Post event) {
    if (event.getType() != ElementType.HOTBAR) {
        return;
    }
    Minecraft mc = FMLClientHandler.instance().getClient();
    ConfigDisplayPos.Type displayType = getDisplayType();
    if (!canRenderHUD(mc)) {
        miningPointPer = -1.0D;
        return;
    }
    ScaledResolution resolution = event.getResolution();
    IMinerStats stats = MinerStats.get(mc.player, true);
    if (stats == null || stats.getPoint() < 0) {
        return;
    }
    MinerRank minerRank = MinerRank.get(stats.getRank());
    MiningAssist miningAssist = MiningAssist.get(stats.getMiningAssist());
    String point = Integer.toString(stats.getPoint());
    String rank = I18n.format(minerRank.getUnlocalizedName());
    if (miningAssist != MiningAssist.DISABLED && stats.getRank() >= MiningAssistConfig.minerRank.getValue()) {
        rank += " / " + I18n.format(miningAssist.getUnlocalizedName());
    }
    setDisplayPos(displayType, mc, resolution.getScaledWidth(), resolution.getScaledHeight());
    int x = posX;
    int y = posY;
    RenderItem renderItem = mc.getRenderItem();
    FontRenderer renderer = mc.fontRenderer;
    boolean flag = false;
    IMiningData data = MiningData.get(mc.player);
    long processTime = mc.world.getTotalWorldTime() - data.getLastMiningTime();
    if (data.getLastMiningTime() > 0L && processTime < 50 && data.getLastMiningBlock() != null && data.getLastMiningPoint() != 0) {
        IBlockState state = data.getLastMiningBlock();
        ItemStack stack = new ItemStack(CaveRenderingRegistry.getRenderBlock(state.getBlock()), 1, state.getBlock().getMetaFromState(state));
        RenderHelper.enableGUIStandardItemLighting();
        renderItem.renderItemIntoGUI(stack, x, y);
        renderItem.renderItemOverlayIntoGUI(renderer, stack, x, y, Integer.toString(data.getLastMiningPoint()));
        RenderHelper.disableStandardItemLighting();
        flag = true;
    }
    if (flag) {
        x += displayType.isLeft() ? 20 : -20;
    }
    renderItem.renderItemIntoGUI(minerRank.getItemStack(), x, y);
    GlStateManager.pushMatrix();
    GlStateManager.disableDepth();
    GlStateManager.enableBlend();
    GlStateManager.tryBlendFuncSeparate(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA, GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO);
    if (point.length() <= 1) {
        point = " " + point;
    }
    MinerRank nextRank = MinerRank.get(stats.getRank() + 1);
    if (minerRank.getRank() < nextRank.getRank()) {
        String per = String.format("%.2f", calcMiningPointPer(stats.getPoint(), nextRank.getPhase(), false)) + "%";
        point = displayType.isLeft() ? point + " < " + per : per + " > " + point;
    }
    String combo = null;
    if (data.getMiningCombo() > 0) {
        TextFormatting format = TextFormatting.WHITE;
        if (processTime < 3 * 20) {
            format = TextFormatting.BOLD;
        } else if (processTime > 12 * 20) {
            format = TextFormatting.GRAY;
        }
        combo = format + String.format("%d COMBO!", data.getMiningCombo()) + TextFormatting.RESET;
    }
    boolean showRank = DisplayConfig.showMinerRank;
    boolean hasCombo = combo != null;
    int pointX = displayType.isLeft() ? x + 5 : x + 17 - renderer.getStringWidth(point);
    int pointY = y + 9;
    int rankX = showRank ? displayType.isLeft() ? posX + 5 : posX + 17 - renderer.getStringWidth(rank) : -1;
    int rankY = showRank ? displayType.isTop() ? y + 21 : y - 12 : -1;
    int comboX = hasCombo ? displayType.isLeft() ? posX + 5 : posX + 17 - renderer.getStringWidth(combo) : -1;
    int comboY = hasCombo ? displayType.isTop() ? y + 33 : y - 24 : -1;
    renderer.drawStringWithShadow(point, pointX, pointY, 0xCECECE);
    if (showRank) {
        renderer.drawStringWithShadow(rank, rankX, rankY, 0xCECECE);
        if (hasCombo) {
            renderer.drawStringWithShadow(combo, comboX, comboY, 0xFFFFFF);
        }
    }
    GlStateManager.enableDepth();
    GlStateManager.disableBlend();
    GlStateManager.popMatrix();
}
Also used : IBlockState(net.minecraft.block.state.IBlockState) Minecraft(net.minecraft.client.Minecraft) MiningAssist(cavern.miningassist.MiningAssist) IMinerStats(cavern.api.IMinerStats) MinerRank(cavern.stats.MinerRank) RenderItem(net.minecraft.client.renderer.RenderItem) ScaledResolution(net.minecraft.client.gui.ScaledResolution) IMiningData(cavern.api.IMiningData) ConfigDisplayPos(cavern.config.property.ConfigDisplayPos) TextFormatting(net.minecraft.util.text.TextFormatting) FontRenderer(net.minecraft.client.gui.FontRenderer) ItemStack(net.minecraft.item.ItemStack) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Example 49 with FontRenderer

use of net.minecraft.client.gui.FontRenderer in project MineCamera by PorPit.

the class GuiPhotoProcessor method initGui.

@Override
public void initGui() {
    super.initGui();
    final FontRenderer fr = this.fontRendererObj;
    int offsetX = (this.width - this.xSize) / 2, offsetY = (this.height - this.ySize) / 2;
    this.buttonList.add(new GuiButton(BUTTON_START, offsetX + 11, offsetY + 101, 25, 16, "") {

        @Override
        public void drawButton(Minecraft mc, int mouseX, int mouseY) {
            if (this.visible) {
                GlStateManager.color(1.0F, 1.0F, 1.0F);
                mc.getTextureManager().bindTexture(TEXTURE);
                int x = mouseX - this.xPosition, y = mouseY - this.yPosition;
                if (x >= 0 && y >= 0 && x < this.width && y < this.height) {
                    this.drawTexturedModalRect(this.xPosition, this.yPosition, 50, 206, this.width, this.height);
                } else {
                    this.drawTexturedModalRect(this.xPosition, this.yPosition, 24, 206, this.width, this.height);
                }
            }
        }

        @Override
        public void mouseReleased(int mouseX, int mouseY) {
            infolock = true;
            int lightlevel = container.getTileEntity().getWorld().getLight(container.getTileEntity().getPos());
            if (!container.getSlot(0).getHasStack()) {
                info = TextFormatting.RED + I18n.format("container.photoprocessor.text.nonectl");
                return;
            } else if (!container.getSlot(1).getHasStack()) {
                info = TextFormatting.RED + I18n.format("container.photoprocessor.text.noneda");
                return;
            } else if (!container.getSlot(2).getHasStack()) {
                info = TextFormatting.RED + I18n.format("container.photoprocessor.text.nonefilm");
                return;
            } else if (!container.getSlot(3).getHasStack()) {
                info = TextFormatting.RED + I18n.format("container.photoprocessor.text.nonepaper");
                return;
            } else if (container.getSlot(4).getHasStack()) {
                info = TextFormatting.RED + I18n.format("container.photoprocessor.text.hasphotoout");
                return;
            } else if (container.getBurnTime() != container.totalBurnTime) {
                return;
            } else if (lightlevel > 5) {
                info = TextFormatting.RED + I18n.format("container.photoprocessor.text.lightleveltoohigh");
                return;
            }
            if (container.getSlot(2).getStack().hasTagCompound() && container.getSlot(2).getStack().getTagCompound().hasKey("pid")) {
                String imagename = container.getSlot(2).getStack().getTagCompound().getString("pid");
                EnumFailLoadImage flag = PictureFactory.isFailedToLoad(imagename);
                if (flag != null) {
                    info = TextFormatting.RED + I18n.format("container.photoprocessor.text.failed." + flag.toString());
                    return;
                }
                MessagePhotoProcessorStart message = new MessagePhotoProcessorStart();
                NetworkLoader.instance.sendToServer(message);
            }
        }
    });
}
Also used : EnumFailLoadImage(com.porpit.minecamera.util.EnumFailLoadImage) GuiButton(net.minecraft.client.gui.GuiButton) MessagePhotoProcessorStart(com.porpit.minecamera.network.MessagePhotoProcessorStart) FontRenderer(net.minecraft.client.gui.FontRenderer) Minecraft(net.minecraft.client.Minecraft)

Example 50 with FontRenderer

use of net.minecraft.client.gui.FontRenderer in project BetterQuesting by Funwayguy.

the class RenderUtils method RenderItemStack.

public static void RenderItemStack(Minecraft mc, ItemStack stack, int x, int y, String text, Color color) {
    if (stack == null || stack.getItem() == null) {
        return;
    }
    ItemStack rStack = stack;
    if (stack.getItemDamage() == OreDictionary.WILDCARD_VALUE) {
        NonNullList<ItemStack> tmp = NonNullList.<ItemStack>create();
        stack.getItem().getSubItems(CreativeTabs.SEARCH, tmp);
        if (tmp.size() > 0) {
            rStack = tmp.get((int) ((Minecraft.getSystemTime() / 1000) % tmp.size()));
        }
    }
    GlStateManager.pushMatrix();
    RenderItem itemRender = mc.getRenderItem();
    float preZ = itemRender.zLevel;
    try {
        GlStateManager.color(color.getRed() / 255F, color.getGreen() / 255F, color.getBlue() / 255F);
        RenderHelper.enableGUIStandardItemLighting();
        GlStateManager.enableRescaleNormal();
        GlStateManager.translate(0.0F, 0.0F, 32.0F);
        itemRender.zLevel = 200.0F;
        FontRenderer font = null;
        if (rStack != null)
            font = rStack.getItem().getFontRenderer(rStack);
        if (font == null)
            font = mc.fontRenderer;
        itemRender.renderItemAndEffectIntoGUI(rStack, x, y);
        itemRender.renderItemOverlayIntoGUI(font, rStack, x, y, text);
        RenderHelper.disableStandardItemLighting();
    } catch (Exception e) {
    }
    // Just in case
    itemRender.zLevel = preZ;
    GlStateManager.popMatrix();
}
Also used : RenderItem(net.minecraft.client.renderer.RenderItem) FontRenderer(net.minecraft.client.gui.FontRenderer) ItemStack(net.minecraft.item.ItemStack)

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