Java Code Examples for net.minecraft.client.gui.FontRenderer#drawStringWithShadow()

The following examples show how to use net.minecraft.client.gui.FontRenderer#drawStringWithShadow() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GuiButton.java    From WearableBackpacks with MIT License 6 votes vote down vote up
/** Draws the content on the button, such as text. */
protected void drawButtonForeground(boolean isHighlighted, float partialTicks) {
	String text = getText();
	if (text.isEmpty()) return;
	FontRenderer fontRenderer = getFontRenderer();
	
	int textWidth = fontRenderer.getStringWidth(text);
	int maxTextWidth = getWidth() - MIN_TEXT_PADDING;
	if ((textWidth > maxTextWidth) && (textWidth > ELLIPSIS_WIDTH)) {
		text = fontRenderer.trimStringToWidth(text, maxTextWidth - ELLIPSIS_WIDTH).trim() + ELLIPSIS;
		textWidth = fontRenderer.getStringWidth(text);
	}
	
	fontRenderer.drawStringWithShadow(text, getWidth() / 2 - textWidth / 2,
	                                        (getHeight() - 8) / 2, getTextColor(isHighlighted));
}
 
Example 2
Source File: GuiButtonIcon.java    From WearableBackpacks with MIT License 6 votes vote down vote up
@Override
protected void drawButtonForeground(boolean isHighlighted, float partialTicks) {
	String text = getText();
	FontRenderer fontRenderer = getFontRenderer();
	
	int contentWidth = _icon.width;
	if (!text.isEmpty()) {
		int textWidth = fontRenderer.getStringWidth(text);
		int maxTextWidth = getWidth() - _icon.width - ICON_SPACING - MIN_TEXT_PADDING;
		if ((textWidth > maxTextWidth) && (textWidth > ELLIPSIS_WIDTH)) {
			text = fontRenderer.trimStringToWidth(text, maxTextWidth - ELLIPSIS_WIDTH).trim() + ELLIPSIS;
			textWidth = fontRenderer.getStringWidth(text);
		}
		contentWidth += ICON_SPACING + textWidth;
	}
	
	int x = (getWidth() - contentWidth) / 2;
	int y = (getHeight() - _icon.height) / 2;
	_icon.texture.bind();
	_icon.texture.drawQuad(x, y, _icon.u, _icon.v, _icon.width, _icon.height);
	
	if (!text.isEmpty())
		fontRenderer.drawStringWithShadow(text,
			x + _icon.width + ICON_SPACING,
			(getHeight() - 8) / 2, getTextColor(isHighlighted));
}
 
Example 3
Source File: Render.java    From mapwriter with MIT License 5 votes vote down vote up
public static void drawCentredString(int x, int y, int colour, String formatString, Object...args) {
	Minecraft mc = Minecraft.getMinecraft();
	//mc.renderEngine.resetBoundTexture();
	FontRenderer fr = mc.fontRenderer;
	String s = String.format(formatString, args);
	int w = fr.getStringWidth(s);
	fr.drawStringWithShadow(s, x - (w / 2), y, colour);
}
 
Example 4
Source File: TankWidget.java    From GregTech with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public void drawInBackground(int mouseX, int mouseY, IRenderContext context) {
    Position pos = getPosition();
    Size size = getSize();
    if (backgroundTexture != null) {
        for (TextureArea textureArea : backgroundTexture) {
            textureArea.draw(pos.x, pos.y, size.width, size.height);
        }
    }
    //do not draw fluids if they are handled by JEI - it draws them itself
    if (lastFluidInTank != null && lastFluidInTank.amount > 0 && !gui.isJEIHandled) {
        GlStateManager.disableBlend();
        RenderUtil.drawFluidForGui(lastFluidInTank, alwaysShowFull ? lastFluidInTank.amount : lastTankCapacity,
            pos.x + fluidRenderOffset, pos.y + fluidRenderOffset,
            size.width - fluidRenderOffset, size.height - fluidRenderOffset);
        int bucketsAmount = lastFluidInTank.amount / 1000;
        if (alwaysShowFull && !hideTooltip && bucketsAmount > 0) {
            String s = String.valueOf(bucketsAmount);
            FontRenderer fontRenderer = Minecraft.getMinecraft().fontRenderer;
            fontRenderer.drawStringWithShadow(s, pos.x + 1 + size.width - 2 - fontRenderer.getStringWidth(s), pos.y + (size.height / 3) + 3, 0xFFFFFF);
        }
        GlStateManager.enableBlend();
        GlStateManager.color(1.0f, 1.0f, 1.0f);
    }
    if (overlayTexture != null) {
        overlayTexture.draw(pos.x, pos.y, size.width, size.height);
    }
}
 
Example 5
Source File: MixinGuiOverlayDebug.java    From Hyperium with GNU Lesser General Public License v3.0 5 votes vote down vote up
private void renderOldDebugInfoRight(ScaledResolution scaledResolution) {
    int scaledWidth = scaledResolution.getScaledWidth();
    FontRenderer fontRendererObj = mc.fontRendererObj;
    long maxMemory = Runtime.getRuntime().maxMemory();
    long totalMemory = Runtime.getRuntime().totalMemory();
    long freeMemory = Runtime.getRuntime().freeMemory();
    long usedMemory = totalMemory - freeMemory;
    String memoryStr = "Used memory: " + usedMemory * 100L / maxMemory + "% (" + usedMemory / 1024L / 1024L + "MB) of " + maxMemory / 1024L / 1024L + "MB";
    fontRendererObj.drawStringWithShadow(memoryStr, scaledWidth - fontRendererObj.getStringWidth(memoryStr) - 2, 2, -1);
    memoryStr = "Allocated memory: " + totalMemory * 100L / maxMemory + "% (" + totalMemory / 1024L / 1024L + "MB)";
    fontRendererObj.drawStringWithShadow(memoryStr, scaledWidth - fontRendererObj.getStringWidth(memoryStr) - 2, 12, -1);
    String versionString = "Hyperium " + Metadata.getVersion();
    fontRendererObj.drawStringWithShadow(versionString, scaledWidth - fontRendererObj.getStringWidth(versionString) - 2, 22, -1);
}
 
Example 6
Source File: ClientEventHandler.java    From PneumaticCraft with GNU General Public License v3.0 5 votes vote down vote up
@SubscribeEvent
public void tickEnd(TickEvent.RenderTickEvent event){
    if(event.phase == TickEvent.Phase.END && FMLClientHandler.instance().getClient().inGameHasFocus && PneumaticCraft.proxy.getPlayer().worldObj != null && (ModuleRegulatorTube.inverted || !ModuleRegulatorTube.inLine)) {
        Minecraft mc = FMLClientHandler.instance().getClient();
        ScaledResolution sr = new ScaledResolution(mc, mc.displayWidth, mc.displayHeight);
        FontRenderer fontRenderer = FMLClientHandler.instance().getClient().fontRenderer;
        String warning = EnumChatFormatting.RED + I18n.format("gui.regulatorTube.hudMessage." + (ModuleRegulatorTube.inverted ? "inverted" : "notInLine"));
        fontRenderer.drawStringWithShadow(warning, sr.getScaledWidth() / 2 - fontRenderer.getStringWidth(warning) / 2, sr.getScaledHeight() / 2 + 30, 0xFFFFFFFF);
    }
}
 
Example 7
Source File: Render.java    From mapwriter with MIT License 5 votes vote down vote up
public static void drawString(int x, int y, int colour, String formatString, Object...args) {
	Minecraft mc = Minecraft.getMinecraft();
	//mc.renderEngine.resetBoundTexture();
	FontRenderer fr = mc.fontRenderer;
	String s = String.format(formatString, args);
	fr.drawStringWithShadow(s, x, y, colour);
}
 
Example 8
Source File: GuiLabel.java    From WearableBackpacks with MIT License 5 votes vote down vote up
@Override
public void draw(int mouseX, int mouseY, float partialTicks) {
	if (!isVisible()) return;
	FontRenderer fontRenderer = getFontRenderer();
	List<String> lines = fontRenderer.listFormattedStringToWidth(_text, Integer.MAX_VALUE);
	int yPos = 1;
	for (String line : lines) {
		int lineWidth = fontRenderer.getStringWidth(line);
		if (!_expands && (lineWidth > getWidth())) {
			line = fontRenderer.trimStringToWidth(line, getWidth() - ELLIPSIS_WIDTH) + ELLIPSIS;
			lineWidth = fontRenderer.getStringWidth(line);
		}
		int xPos = 0;
		switch (_align) {
			case LEFT:   xPos = 0; break;
			case RIGHT:  xPos = getWidth() - lineWidth; break;
			case CENTER: xPos = (getWidth() - lineWidth) / 2; break;
		}
		
		int color = isEnabled() ? getColor() : getDisabledColor();
		int shadowColor = getShadowColor();
		if (shadowColor >= 0)
			fontRenderer.drawString(line, xPos + 1, yPos + 1, shadowColor);
		if (shadowColor == SHADOW_AUTOMATIC)
			fontRenderer.drawStringWithShadow(line, xPos, yPos, color);
		else fontRenderer.drawString(line, xPos, yPos, color);
		
		yPos += LINE_HEIGHT;
	}
}
 
Example 9
Source File: GuiButtonGlyph.java    From WearableBackpacks with MIT License 5 votes vote down vote up
@Override
protected void drawButtonForeground(boolean isHighlighted, float partialTicks) {
	String text = getText();
	FontRenderer fontRenderer = getFontRenderer();
	
	int contentWidth = getGlyphWidth();
	if (!text.isEmpty()) {
		int textWidth = fontRenderer.getStringWidth(text);
		int maxTextWidth = getWidth() - getGlyphWidth() - GLYPH_SPACING - MIN_TEXT_PADDING;
		if ((textWidth > maxTextWidth) && (textWidth > ELLIPSIS_WIDTH)) {
			text = fontRenderer.trimStringToWidth(text, maxTextWidth - ELLIPSIS_WIDTH).trim() + ELLIPSIS;
			textWidth = fontRenderer.getStringWidth(text);
		}
		contentWidth += GLYPH_SPACING + textWidth;
	}
	
	float scale = getGlyphScale();
	GlStateManager.pushMatrix();
	GlStateManager.scale(scale, scale, 1.0F);
	fontRenderer.drawStringWithShadow(getGlyph(),
		(int)((getWidth() - contentWidth) / 2 / scale),
		(int)((((getHeight() - 8) / scale / 2) - 1) / scale), getTextColor(isHighlighted));
	GlStateManager.popMatrix();
	
	if (!text.isEmpty())
		fontRenderer.drawStringWithShadow(text,
			(getWidth() - contentWidth) / 2 + getGlyphWidth() + GLYPH_SPACING,
			(getHeight() - 8) / 2, getTextColor(isHighlighted));
}
 
Example 10
Source File: PowerDisplay.java    From Cyberware with MIT License 4 votes vote down vote up
@Override
public void renderElement(int x, int y, EntityPlayer p, ScaledResolution resolution, boolean hudjackAvailable, boolean isConfigOpen, float partialTicks)
{
	if (!isHidden() && hudjackAvailable)
	{
		boolean flipHoriz = getHorizontalAnchor() == EnumAnchorHorizontal.RIGHT;

		float currTime = p.ticksExisted + partialTicks;
		
		GL11.glPushMatrix();
		GlStateManager.enableBlend();
		ICyberwareUserData data = CyberwareAPI.getCapability(p);
		
		Minecraft.getMinecraft().getTextureManager().bindTexture(HudHandler.HUD_TEXTURE);

		
		FontRenderer fr = Minecraft.getMinecraft().fontRendererObj;
		
		if (p.ticksExisted % 20 == 0)
		{
			cachedPercent = data.getPercentFull();
			cachedCap = data.getCapacity();
			cachedTotal = data.getStoredPower();
			cachedProd = data.getProduction();
			cachedCons = data.getConsumption();
		}
		
		float[] color = CyberwareAPI.getHUDColor();
		int colorHex = CyberwareAPI.getHUDColorHex();
		
		if (cachedPercent != -1)
		{
			int amount = Math.round((21F * cachedPercent));

			boolean danger = (cachedPercent <= .2F);
			boolean superDanger = danger && (cachedPercent <= .05F);
			int xOffset = (danger ? 39 : 0);
			
			if (!superDanger || p.ticksExisted % 4 != 0)
			{
				int moveX = flipHoriz ? (x + getWidth() - 13) : x;
				GlStateManager.pushMatrix();
				if (!danger) GlStateManager.color(color[0], color[1], color[2]);
				ClientUtils.drawTexturedModalRect(moveX, y, xOffset, 0, 13, 2 + (21 - amount));
				ClientUtils.drawTexturedModalRect(moveX, y + 2 + (21 - amount), 13 + xOffset, 2 + (21 - amount), 13, amount + 2);
				
				ClientUtils.drawTexturedModalRect(moveX, y + 2 + (21 - amount), 26 + xOffset, 2 + (21 - amount), 13, amount + 2);
				GlStateManager.popMatrix();

				String output = cachedTotal + " / " + cachedCap;
				int textX = flipHoriz ? x + getWidth() - 15 - fr.getStringWidth(output) : x + 15;
				fr.drawStringWithShadow(output, textX, y + 4, danger ? 0xFF0000 : colorHex);
				
				output = "-" + cachedCons + " / +" + cachedProd;
				textX = flipHoriz ? x + getWidth() - 15 - fr.getStringWidth(output) : x + 15;
				fr.drawStringWithShadow(output, textX, y + 14, danger ? 0xFF0000 : colorHex);
			}
		}
		
		GL11.glPopMatrix();
	}
}
 
Example 11
Source File: GuiContainerLargeStacks.java    From enderutilities with GNU Lesser General Public License v3.0 4 votes vote down vote up
public void renderLargeStackItemOverlayIntoGUI(FontRenderer fontRenderer, ItemStack stack, int xPosition, int yPosition)
{
    if (stack.isEmpty())
    {
        return;
    }

    if (stack.getCount() != 1)
    {
        String str = EUStringUtils.getStackSizeString(stack, 4);

        if (stack.getCount() < 1)
        {
            str = TextFormatting.RED + str;
        }

        GlStateManager.disableLighting();
        GlStateManager.disableDepth();
        GlStateManager.disableBlend();

        GlStateManager.pushMatrix();
        GlStateManager.translate(xPosition, yPosition, 0.0d);
        GlStateManager.scale(0.5d, 0.5d, 0.5d);

        fontRenderer.drawStringWithShadow(str, (31 - fontRenderer.getStringWidth(str)), 23, 0xFFFFFF);

        GlStateManager.popMatrix();

        GlStateManager.enableLighting();
        GlStateManager.enableDepth();
    }

    if (stack.getItem().showDurabilityBar(stack))
    {
        double health = stack.getItem().getDurabilityForDisplay(stack);
        int j = (int)Math.round(13.0D - health * 13.0D);
        int i = (int)Math.round(255.0D - health * 255.0D);

        GlStateManager.disableLighting();
        GlStateManager.disableDepth();
        GlStateManager.disableTexture2D();
        GlStateManager.disableAlpha();
        GlStateManager.disableBlend();

        Tessellator tessellator = Tessellator.getInstance();
        BufferBuilder vertexBuffer = tessellator.getBuffer();

        this.drawQuad(vertexBuffer, xPosition + 2, yPosition + 13, 13, 2, 0, 0, 0, 255);
        this.drawQuad(vertexBuffer, xPosition + 2, yPosition + 13, 12, 1, (255 - i) / 4, 64, 0, 255);
        this.drawQuad(vertexBuffer, xPosition + 2, yPosition + 13, j, 1, 255 - i, i, 0, 255);

        GlStateManager.enableAlpha();
        GlStateManager.enableTexture2D();
        GlStateManager.enableLighting();
        GlStateManager.enableDepth();
    }
}
 
Example 12
Source File: GuiCustomButton.java    From Custom-Main-Menu with MIT License 4 votes vote down vote up
protected void drawHoveringText(Minecraft mc, List textLines, int x, int y, FontRenderer font)
{
	if (!textLines.isEmpty())
	{
		int width = mc.currentScreen.width;
		int height = mc.currentScreen.height;
		GlStateManager.disableDepth();
		int k = 0;
		Iterator iterator = textLines.iterator();

		while (iterator.hasNext())
		{
			String s = (String) iterator.next();
			int l = font.getStringWidth(s);

			if (l > k)
			{
				k = l;
			}
		}

		int j2 = x + 12;
		int k2 = y - 12;
		int i1 = 8;

		if (textLines.size() > 1)
		{
			i1 += 2 + (textLines.size() - 1) * 10;
		}

		if (j2 + k > width)
		{
			j2 -= 28 + k;
		}

		if (k2 + i1 + 6 > height)
		{
			k2 = this.height - i1 - 6;
		}

		this.zLevel = 300.0F;
		int j1 = -267386864;
		this.drawGradientRect(j2 - 3, k2 - 4, j2 + k + 3, k2 - 3, j1, j1);
		this.drawGradientRect(j2 - 3, k2 + i1 + 3, j2 + k + 3, k2 + i1 + 4, j1, j1);
		this.drawGradientRect(j2 - 3, k2 - 3, j2 + k + 3, k2 + i1 + 3, j1, j1);
		this.drawGradientRect(j2 - 4, k2 - 3, j2 - 3, k2 + i1 + 3, j1, j1);
		this.drawGradientRect(j2 + k + 3, k2 - 3, j2 + k + 4, k2 + i1 + 3, j1, j1);
		int k1 = 1347420415;
		int l1 = (k1 & 16711422) >> 1 | k1 & -16777216;
		this.drawGradientRect(j2 - 3, k2 - 3 + 1, j2 - 3 + 1, k2 + i1 + 3 - 1, k1, l1);
		this.drawGradientRect(j2 + k + 2, k2 - 3 + 1, j2 + k + 3, k2 + i1 + 3 - 1, k1, l1);
		this.drawGradientRect(j2 - 3, k2 - 3, j2 + k + 3, k2 - 3 + 1, k1, k1);
		this.drawGradientRect(j2 - 3, k2 + i1 + 2, j2 + k + 3, k2 + i1 + 3, l1, l1);

		for (int i2 = 0; i2 < textLines.size(); ++i2)
		{
			String s1 = (String) textLines.get(i2);
			font.drawStringWithShadow(s1, j2, k2, -1);

			if (i2 == 0)
			{
				k2 += 2;
			}

			k2 += 10;
		}

		this.zLevel = 0.0F;
		GlStateManager.enableDepth();
	}
}
 
Example 13
Source File: ScreenHelper.java    From malmo with MIT License 4 votes vote down vote up
public static void drawText(String s, int x, int y, int colour)
{
    FontRenderer frendo = Minecraft.getMinecraft().fontRendererObj;
    frendo.drawStringWithShadow(s, x, y, colour);
}
 
Example 14
Source File: FontRendererHelper.java    From LunatriusCore with MIT License 4 votes vote down vote up
public static void drawLeftAlignedString(final FontRenderer fontRenderer, final String str, final int x, final int y, final int color) {
    fontRenderer.drawStringWithShadow(str, x, y, color);
}
 
Example 15
Source File: RenderCodex.java    From Wizardry with GNU Lesser General Public License v3.0 4 votes vote down vote up
public void renderItemStack(ItemStack stack) {
	GlStateManager.enableAlpha();
	GlStateManager.enableBlend();
	GlStateManager.enableRescaleNormal();

	GlStateManager.pushMatrix();

	RenderItem itemRender = Minecraft.getMinecraft().getRenderItem();
	itemRender.renderItemAndEffectIntoGUI(stack, 0, 0);

	GlStateManager.translate(0, 0, 150);

	FontRenderer font = stack.getItem().getFontRenderer(stack);
	if (font == null) font = Minecraft.getMinecraft().fontRenderer;

	if (font != null && stack.getCount() != 1) {
		GlStateManager.translate(0, 0, 5);
		GlStateManager.disableLighting();
		GlStateManager.disableBlend();
		font.drawStringWithShadow(stack.getCount() + "",
				17F - font.getStringWidth(stack.getCount() + ""),
				9F,
				0xFFFFFF);
		GlStateManager.enableDepth();
		GlStateManager.enableBlend();
		GlStateManager.translate(0, 0, -5);
	}

	if (stack.getItem().showDurabilityBar(stack)) {
		GlStateManager.disableLighting();
		GlStateManager.disableTexture2D();
		GlStateManager.disableAlpha();
		GlStateManager.disableBlend();
		Tessellator tessellator = Tessellator.getInstance();
		BufferBuilder bufferbuilder = tessellator.getBuffer();
		double health = stack.getItem().getDurabilityForDisplay(stack);
		int rgbfordisplay = stack.getItem().getRGBDurabilityForDisplay(stack);
		int i = Math.round(13.0F - (float) health * 13.0F);
		draw(bufferbuilder, 2, 13, 13, 2, 0, 0, 0, 255);
		draw(bufferbuilder, 2, 13, i, 1, rgbfordisplay >> 16 & 255, rgbfordisplay >> 8 & 255, rgbfordisplay & 255, 255);
		GlStateManager.enableBlend();
		GlStateManager.enableAlpha();
		GlStateManager.enableTexture2D();
		GlStateManager.enableLighting();
	}


	EntityPlayerSP entityplayersp = Minecraft.getMinecraft().player;
	float f3 = entityplayersp == null ? 0.0F : entityplayersp.getCooldownTracker().getCooldown(stack.getItem(), Minecraft.getMinecraft().getRenderPartialTicks());

	if (f3 > 0.0F) {
		GlStateManager.disableLighting();
		GlStateManager.disableTexture2D();
		Tessellator tessellator1 = Tessellator.getInstance();
		BufferBuilder bufferbuilder1 = tessellator1.getBuffer();
		this.draw(bufferbuilder1, 0, MathHelper.floor(16.0F * (1.0F - f3)), 16, MathHelper.ceil(16.0F * f3), 255, 255, 255, 127);
		GlStateManager.enableTexture2D();
		GlStateManager.enableLighting();
	}

	GlStateManager.popMatrix();

	GlStateManager.enableLighting();
	GlStateManager.enableAlpha();
	GlStateManager.enableBlend();
	GlStateManager.disableRescaleNormal();
}
 
Example 16
Source File: ShowArmor.java    From ehacks-pro with GNU General Public License v3.0 4 votes vote down vote up
private int drawHoveringText(List<String> text, int x, int y, FontRenderer font) {
    int t = 0;
    if (!text.isEmpty()) {
        GL11.glDisable(GL12.GL_RESCALE_NORMAL);
        GL11.glDisable(GL11.GL_LIGHTING);
        GL11.glDisable(GL11.GL_DEPTH_TEST);
        int k = 0;

        for (String s : text) {
            int l = font.getStringWidth(s);

            if (l > k) {
                k = l;
            }
        }

        int j2 = x;
        int k2 = y;
        int i1 = 8;

        if (text.size() > 1) {
            i1 += 2 + (text.size() - 1) * 10;
        }

        t = i1;

        RenderItem.getInstance().zLevel = 300.0F;
        int j1 = -267386864;
        this.drawGradientRect(j2 - 3, k2 - 4, j2 + k + 3, k2 - 3, j1, j1);
        this.drawGradientRect(j2 - 3, k2 + i1 + 3, j2 + k + 3, k2 + i1 + 4, j1, j1);
        this.drawGradientRect(j2 - 3, k2 - 3, j2 + k + 3, k2 + i1 + 3, j1, j1);
        this.drawGradientRect(j2 - 4, k2 - 3, j2 - 3, k2 + i1 + 3, j1, j1);
        this.drawGradientRect(j2 + k + 3, k2 - 3, j2 + k + 4, k2 + i1 + 3, j1, j1);
        int k1 = 1347420415;
        int l1 = (k1 & 16711422) >> 1 | k1 & -16777216;
        this.drawGradientRect(j2 - 3, k2 - 3 + 1, j2 - 3 + 1, k2 + i1 + 3 - 1, k1, l1);
        this.drawGradientRect(j2 + k + 2, k2 - 3 + 1, j2 + k + 3, k2 + i1 + 3 - 1, k1, l1);
        this.drawGradientRect(j2 - 3, k2 - 3, j2 + k + 3, k2 - 3 + 1, k1, k1);
        this.drawGradientRect(j2 - 3, k2 + i1 + 2, j2 + k + 3, k2 + i1 + 3, l1, l1);

        for (int i2 = 0; i2 < text.size(); ++i2) {
            String s1 = text.get(i2);
            font.drawStringWithShadow(s1, j2, k2, -1);

            if (i2 == 0) {
                k2 += 2;
            }

            k2 += 10;
        }

        RenderItem.getInstance().zLevel = 0.0F;
        GL11.glEnable(GL11.GL_DEPTH_TEST);
        GL11.glEnable(GL12.GL_RESCALE_NORMAL);
    }
    return t;
}
 
Example 17
Source File: CellViewer.java    From ehacks-pro with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void renderItemOverlayIntoGUI(FontRenderer p_94148_1_, TextureManager p_94148_2_, ItemStack p_94148_3_, int p_94148_4_, int p_94148_5_, String p_94148_6_) {
    if (p_94148_3_ != null) {
        boolean renderSmall = p_94148_3_.stackTagCompound != null && "ok".equals(p_94148_3_.stackTagCompound.getString("render-cellviewer"));

        if (p_94148_3_.getItem().showDurabilityBar(p_94148_3_)) {
            double health = p_94148_3_.getItem().getDurabilityForDisplay(p_94148_3_);
            int j1 = (int) Math.round(13.0D - health * 13.0D);
            int k = (int) Math.round(255.0D - health * 255.0D);
            GL11.glDisable(GL11.GL_LIGHTING);
            GL11.glDisable(GL11.GL_DEPTH_TEST);
            GL11.glDisable(GL11.GL_TEXTURE_2D);
            GL11.glDisable(GL11.GL_ALPHA_TEST);
            GL11.glDisable(GL11.GL_BLEND);
            Tessellator tessellator = Tessellator.instance;
            int l = 255 - k << 16 | k << 8;
            int i1 = (255 - k) / 4 << 16 | 16128;
            this.renderQuad(tessellator, p_94148_4_ + 2, p_94148_5_ + 13, 13, 2, 0);
            this.renderQuad(tessellator, p_94148_4_ + 2, p_94148_5_ + 13, 12, 1, i1);
            this.renderQuad(tessellator, p_94148_4_ + 2, p_94148_5_ + 13, j1, 1, l);
            //GL11.glEnable(GL11.GL_BLEND); // Forge: Disable Bled because it screws with a lot of things down the line.
            GL11.glEnable(GL11.GL_ALPHA_TEST);
            GL11.glEnable(GL11.GL_TEXTURE_2D);
            GL11.glEnable(GL11.GL_LIGHTING);
            GL11.glEnable(GL11.GL_DEPTH_TEST);
            GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
        }

        if (p_94148_3_.stackSize > 1 || p_94148_6_ != null || renderSmall) {
            String s1 = p_94148_6_ == null ? String.valueOf(p_94148_3_.stackSize) : p_94148_6_;
            if (renderSmall) {
                s1 = getStringOfNum(p_94148_3_.stackSize);
            }
            GL11.glDisable(GL11.GL_LIGHTING);
            GL11.glDisable(GL11.GL_DEPTH_TEST);
            GL11.glDisable(GL11.GL_BLEND);
            if (renderSmall) {
                GL11.glScalef(.5f, .5f, .5f);
            }
            int textX = p_94148_4_ + 19 - 2 - p_94148_1_.getStringWidth(s1);
            int textY = p_94148_5_ + 6 + 3;
            if (renderSmall) {
                textX = p_94148_4_ * 2 + 32 - p_94148_1_.getStringWidth(s1) - 2;
                textY = p_94148_5_ * 2 + 23;
            }
            p_94148_1_.drawStringWithShadow(s1, textX, textY, 16777215);
            if (renderSmall) {
                GL11.glScalef(2f, 2f, 2f);
            }
            GL11.glEnable(GL11.GL_LIGHTING);
            GL11.glEnable(GL11.GL_DEPTH_TEST);
        }
    }
}
 
Example 18
Source File: AbstractFluidWidget.java    From ExtraCells1 with MIT License 4 votes vote down vote up
@SuppressWarnings("rawtypes")
protected void drawHoveringText(List list, int x, int y, FontRenderer fontrenderer)
{
	if (!list.isEmpty())
	{
		GL11.glDisable(GL12.GL_RESCALE_NORMAL);
		RenderHelper.disableStandardItemLighting();
		GL11.glDisable(GL11.GL_LIGHTING);
		GL11.glDisable(GL11.GL_DEPTH_TEST);
		int k = 0;

		for (Object string : list)
		{
			String s = (String) string;
			int l = fontrenderer.getStringWidth(s);

			if (l > k)
			{
				k = l;
			}
		}

		int i1 = x + 12;
		int j1 = y - 12;
		int k1 = 8;

		if (list.size() > 1)
		{
			k1 += 2 + (list.size() - 1) * 10;
		}

		this.zLevel = 300.0F;
		int l1 = -267386864;
		this.drawGradientRect(i1 - 3, j1 - 4, i1 + k + 3, j1 - 3, l1, l1);
		this.drawGradientRect(i1 - 3, j1 + k1 + 3, i1 + k + 3, j1 + k1 + 4, l1, l1);
		this.drawGradientRect(i1 - 3, j1 - 3, i1 + k + 3, j1 + k1 + 3, l1, l1);
		this.drawGradientRect(i1 - 4, j1 - 3, i1 - 3, j1 + k1 + 3, l1, l1);
		this.drawGradientRect(i1 + k + 3, j1 - 3, i1 + k + 4, j1 + k1 + 3, l1, l1);
		int i2 = 1347420415;
		int j2 = (i2 & 16711422) >> 1 | i2 & -16777216;
		this.drawGradientRect(i1 - 3, j1 - 3 + 1, i1 - 3 + 1, j1 + k1 + 3 - 1, i2, j2);
		this.drawGradientRect(i1 + k + 2, j1 - 3 + 1, i1 + k + 3, j1 + k1 + 3 - 1, i2, j2);
		this.drawGradientRect(i1 - 3, j1 - 3, i1 + k + 3, j1 - 3 + 1, i2, i2);
		this.drawGradientRect(i1 - 3, j1 + k1 + 2, i1 + k + 3, j1 + k1 + 3, j2, j2);

		for (int k2 = 0; k2 < list.size(); ++k2)
		{
			String s1 = (String) list.get(k2);
			fontrenderer.drawStringWithShadow(s1, i1, j1, -1);

			if (k2 == 0)
			{
				j1 += 2;
			}

			j1 += 10;
		}

		this.zLevel = 0.0F;
		GL11.glEnable(GL11.GL_LIGHTING);
		GL11.glEnable(GL11.GL_DEPTH_TEST);
		RenderHelper.enableStandardItemLighting();
		GL11.glEnable(GL12.GL_RESCALE_NORMAL);
	}
}
 
Example 19
Source File: MixinGuiButton.java    From LiquidBounce with GNU General Public License v3.0 4 votes vote down vote up
/**
 * @author CCBlueX
 */
@Overwrite
public void drawButton(Minecraft mc, int mouseX, int mouseY) {
   if (visible) {
      final FontRenderer fontRenderer =
         mc.getLanguageManager().isCurrentLocaleUnicode() ? mc.fontRendererObj : Fonts.font35;
      hovered = (mouseX >= this.xPosition && mouseY >= this.yPosition &&
                 mouseX < this.xPosition + this.width && mouseY < this.yPosition + this.height);

      final int delta = RenderUtils.deltaTime;

      if (enabled && hovered) {
         cut += 0.05F * delta;

         if (cut >= 4) cut = 4;

         alpha += 0.3F * delta;

         if (alpha >= 210) alpha = 210;
      } else {
         cut -= 0.05F * delta;

         if (cut <= 0) cut = 0;

         alpha -= 0.3F * delta;

         if (alpha <= 120) alpha = 120;
      }

      Gui.drawRect(this.xPosition + (int) this.cut, this.yPosition,
              this.xPosition + this.width - (int) this.cut, this.yPosition + this.height,
              this.enabled ? new Color(0F, 0F, 0F, this.alpha / 255F).getRGB() :
                      new Color(0.5F, 0.5F, 0.5F, 0.5F).getRGB());

      mc.getTextureManager().bindTexture(buttonTextures);
      mouseDragged(mc, mouseX, mouseY);

      net.ccbluex.liquidbounce.ui.font.AWTFontRenderer.Companion.setAssumeNonVolatile(true);

      fontRenderer.drawStringWithShadow(displayString,
              (float) ((this.xPosition + this.width / 2) -
                      fontRenderer.getStringWidth(displayString) / 2),
              this.yPosition + (this.height - 5) / 2F, 14737632);

      net.ccbluex.liquidbounce.ui.font.AWTFontRenderer.Companion.setAssumeNonVolatile(false);

      GlStateManager.resetColor();
   }
}
 
Example 20
Source File: FontRendererHelper.java    From LunatriusCore with MIT License 4 votes vote down vote up
public static void drawCenteredString(final FontRenderer fontRenderer, final String str, final int x, final int y, final int color) {
    fontRenderer.drawStringWithShadow(str, x - fontRenderer.getStringWidth(str) / 2, y, color);
}