Java Code Examples for net.minecraft.client.font.TextRenderer#draw()

The following examples show how to use net.minecraft.client.font.TextRenderer#draw() . 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: SpaceRaceScreen.java    From Galacticraft-Rewoven with MIT License 6 votes vote down vote up
private void renderButton(MatrixStack stack, TextRenderer textRenderer, Text text, int x, int y, int width, int height) {
    RenderSystem.disableBlend();
    stack.push();

    fillSolid(stack.peek().getModel(), x, y, x + width, y + height, 0x0);

    drawHorizontalLineSolid(stack, x, x + width, y, 0x2d2d2d);
    drawVerticalLineSolid(stack, x + width, y, y + height, 0x2d2d2d);
    drawHorizontalLineSolid(stack, x + width, x, y + height, 0x2d2d2d);
    drawVerticalLineSolid(stack, x, y, y + height, 0x2d2d2d);

    stack.pop();
    RenderSystem.enableBlend();

    textRenderer.draw(stack, text, x + (width / 2F) - (textRenderer.getWidth(text) / 2F), y + (height / 2F) - 4F, 0xffffff);
}
 
Example 2
Source File: FeatureButton.java    From Wurst7 with GNU General Public License v3.0 6 votes vote down vote up
private void drawName(MatrixStack matrixStack, int x1, int x3, int y1)
{
	GL11.glColor4f(1, 1, 1, 1);
	GL11.glEnable(GL11.GL_TEXTURE_2D);
	
	TextRenderer tr = MC.textRenderer;
	String name = feature.getName();
	int nameWidth = tr.getWidth(name);
	int tx = x1 + (x3 - x1 - nameWidth) / 2;
	int ty = y1 + 2;
	
	tr.draw(matrixStack, name, tx, ty, 0xF0F0F0);
	
	GL11.glDisable(GL11.GL_TEXTURE_2D);
	GL11.glEnable(GL11.GL_BLEND);
}
 
Example 3
Source File: SliderComponent.java    From Wurst7 with GNU General Public License v3.0 6 votes vote down vote up
private void drawNameAndValue(MatrixStack matrixStack, int x1, int x2,
	int y1, boolean renderAsDisabled)
{
	GL11.glColor4f(1, 1, 1, 1);
	GL11.glEnable(GL11.GL_TEXTURE_2D);
	
	TextRenderer tr = MC.textRenderer;
	String name = setting.getName();
	String value = setting.getValueString();
	int valueWidth = tr.getWidth(value);
	int color = renderAsDisabled ? 0xAAAAAA : 0xF0F0F0;
	tr.draw(matrixStack, name, x1, y1 + 2, color);
	tr.draw(matrixStack, value, x2 - valueWidth, y1 + 2, color);
	
	GL11.glDisable(GL11.GL_TEXTURE_2D);
	GL11.glEnable(GL11.GL_BLEND);
}
 
Example 4
Source File: HackListHUD.java    From Wurst7 with GNU General Public License v3.0 6 votes vote down vote up
private void drawString(MatrixStack matrixStack, String s)
{
	TextRenderer tr = WurstClient.MC.textRenderer;
	int posX;
	
	if(otf.getPosition() == Position.LEFT)
		posX = 2;
	else
	{
		int screenWidth = WurstClient.MC.getWindow().getScaledWidth();
		int stringWidth = tr.getWidth(s);
		
		posX = screenWidth - stringWidth - 2;
	}
	
	tr.draw(matrixStack, s, posX + 1, posY + 1, 0xff000000);
	tr.draw(matrixStack, s, posX, posY, textColor | 0xff000000);
	
	posY += 9;
}
 
Example 5
Source File: HackListHUD.java    From Wurst7 with GNU General Public License v3.0 6 votes vote down vote up
private void drawWithOffset(MatrixStack matrixStack, HackListEntry e,
	float partialTicks)
{
	TextRenderer tr = WurstClient.MC.textRenderer;
	String s = e.hack.getRenderName();
	
	float offset =
		e.offset * partialTicks + e.prevOffset * (1 - partialTicks);
	
	float posX;
	if(otf.getPosition() == Position.LEFT)
		posX = 2 - 5 * offset;
	else
	{
		int screenWidth = WurstClient.MC.getWindow().getScaledWidth();
		int stringWidth = tr.getWidth(s);
		
		posX = screenWidth - stringWidth - 2 + 5 * offset;
	}
	
	int alpha = (int)(255 * (1 - offset / 4)) << 24;
	tr.draw(matrixStack, s, posX + 1, posY + 1, 0x04000000 | alpha);
	tr.draw(matrixStack, s, posX, posY, textColor | alpha);
	
	posY += 9;
}
 
Example 6
Source File: WurstLogo.java    From Wurst7 with GNU General Public License v3.0 6 votes vote down vote up
public void render(MatrixStack matrixStack)
{
	if(!WurstClient.INSTANCE.getOtfs().wurstLogoOtf.isVisible())
		return;
	
	String version = getVersionString();
	TextRenderer tr = WurstClient.MC.textRenderer;
	
	// draw version background
	GL11.glEnable(GL11.GL_BLEND);
	GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
	
	if(WurstClient.INSTANCE.getHax().rainbowUiHack.isEnabled())
	{
		float[] acColor = WurstClient.INSTANCE.getGui().getAcColor();
		GL11.glColor4f(acColor[0], acColor[1], acColor[2], 0.5F);
		
	}else
		GL11.glColor4f(1, 1, 1, 0.5F);
	
	drawQuads(0, 6, tr.getWidth(version) + 76, 17);
	
	// draw version string
	GL11.glEnable(GL11.GL_TEXTURE_2D);
	GL11.glEnable(GL11.GL_CULL_FACE);
	GL11.glDisable(GL11.GL_DEPTH_TEST);
	tr.draw(matrixStack, version, 74, 8, 0xFF000000);
	
	// draw Wurst logo
	GL11.glColor4f(1, 1, 1, 1);
	GL11.glEnable(GL11.GL_BLEND);
	WurstClient.MC.getTextureManager().bindTexture(texture);
	DrawableHelper.drawTexture(matrixStack, 0, 3, 0, 0, 72, 18, 72, 18);
}
 
Example 7
Source File: EditItemListScreen.java    From Wurst7 with GNU General Public License v3.0 6 votes vote down vote up
@Override
protected void renderItem(MatrixStack matrixStack, int index, int x,
	int y, int var4, int var5, int var6, float partialTicks)
{
	String name = list.get(index);
	Item item = Registry.ITEM.get(new Identifier(name));
	ItemStack stack = new ItemStack(item);
	TextRenderer fr = mc.textRenderer;
	
	String displayName =
		renderIconAndGetName(matrixStack, stack, x + 1, y + 1, true);
	fr.draw(matrixStack, displayName, x + 28, y, 0xf0f0f0);
	fr.draw(matrixStack, name, x + 28, y + 9, 0xa0a0a0);
	fr.draw(matrixStack, "ID: " + Registry.ITEM.getId(item).toString(),
		x + 28, y + 18, 0xa0a0a0);
}
 
Example 8
Source File: EditBlockListScreen.java    From Wurst7 with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected void renderItem(MatrixStack matrixStack, int index, int x,
	int y, int var4, int var5, int var6, float partialTicks)
{
	String name = list.get(index);
	ItemStack stack = new ItemStack(BlockUtils.getBlockFromName(name));
	TextRenderer fr = mc.textRenderer;
	
	String displayName =
		renderIconAndGetName(matrixStack, stack, x + 1, y + 1, true);
	fr.draw(matrixStack, displayName, x + 28, y, 0xf0f0f0);
	fr.draw(matrixStack, name, x + 28, y + 9, 0xa0a0a0);
	fr.draw(matrixStack, "ID: " + BlockUtils.getBlockFromName(name),
		x + 28, y + 18, 0xa0a0a0);
}
 
Example 9
Source File: Window.java    From bleachhack-1.14 with GNU General Public License v3.0 5 votes vote down vote up
protected void drawBar(MatrixStack matrix, int mX, int mY, TextRenderer textRend) {
	/* background and title bar */
	fillGrey(matrix, x1, y1, x2, y2);
	fillGradient(matrix, x1 + 2, y1 + 2, x2 - 2, y1 + 12, (selected ? 0xff0000ff : 0xff606060), (selected ? 0xff4080ff : 0xffa0a0a0));
	
	/* buttons */
	fillGrey(matrix, x2 - 12, y1 + 3, x2 - 4, y1 + 11);
	textRend.draw(matrix, "x", x2 - 11, y1 + 2, 0x000000);
	
	fillGrey(matrix, x2 - 22, y1 + 3, x2 - 14, y1 + 11);
	textRend.draw(matrix, "_", x2 - 21, y1 + 1, 0x000000);
}
 
Example 10
Source File: BleachCheckbox.java    From bleachhack-1.14 with GNU General Public License v3.0 5 votes vote down vote up
public void renderButton(MatrixStack matrix, int mouseX, int mouseY, float delta) {
	MinecraftClient minecraftClient_1 = MinecraftClient.getInstance();
	GL11.glDepthMask(true);
	GL11.glEnable(GL11.GL_DEPTH_TEST);
	TextRenderer textRenderer = minecraftClient_1.textRenderer;
	int color = mouseX > x && mouseX < x + 10 && mouseY > y && mouseY < y + 10 ? 0xffc0c0c0 : 0xffe0e0e0;
	fill(matrix, x, y, x + 11, y + 11, color);
	fill(matrix, x, y, x + 1, y + 11, 0xff303030);
	fill(matrix, x, y + 10, x + 11, y + 11, 0xffb0b0b0);
	fill(matrix, x, y, x + 10, y + 1, 0xff303030);
	fill(matrix, x + 10, y, x + 11, y + 11, 0xffb0b0b0);
	if (checked) textRenderer.draw(matrix, "\u2714", x + 2, y + 2, 0x000000); //fill(x + 3, y + 5, x + 8, y + 6, 0xff000000);
	drawStringWithShadow(matrix, textRenderer, getMessage().getString(), x + 15, y + 2, 0xC0C0C0);
}
 
Example 11
Source File: SpaceRaceScreen.java    From Galacticraft-Rewoven with MIT License 5 votes vote down vote up
private void renderHoveredButton(MatrixStack stack, TextRenderer textRenderer, Text text, int x, int y, int width, int height) {
    RenderSystem.disableBlend();
    stack.push();

    fillSolid(stack.peek().getModel(), x, y, x + width, y + height, 0x1e1e1e);

    drawHorizontalLineSolid(stack, x, x + width, y, 0x3c3c3c);
    drawVerticalLineSolid(stack, x + width, y, y + height, 0x3c3c3c);
    drawHorizontalLineSolid(stack, x + width, x, y + height, 0x3c3c3c);
    drawVerticalLineSolid(stack, x, y, y + height, 0x3c3c3c);

    stack.pop();
    RenderSystem.enableBlend();

    textRenderer.draw(stack, text, x + (width / 2F) - (textRenderer.getWidth(text) / 2F), y + (height / 2F) - 4F, 0xffffff);
}
 
Example 12
Source File: Window.java    From bleachhack-1.14 with GNU General Public License v3.0 5 votes vote down vote up
protected void drawBar(int mX, int mY, TextRenderer textRend) {
	/* background and title bar */
	fillGrey(x1, y1, x2, y2);
	fillGradient(x1 + 2, y1 + 2, x2 - 2, y1 + 12, (selected ? 0xff0000ff : 0xff606060), (selected ? 0xff4080ff : 0xffa0a0a0));
	
	/* buttons */
	fillGrey(x2 - 12, y1 + 3, x2 - 4, y1 + 11);
	textRend.draw("x", x2 - 11, y1 + 2, 0x000000);
	
	fillGrey(x2 - 22, y1 + 3, x2 - 14, y1 + 11);
	textRend.draw("_", x2 - 21, y1 + 1, 0x000000);
}
 
Example 13
Source File: KeybindProfilesScreen.java    From Wurst7 with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected void renderItem(MatrixStack matrixStack, int index, int x,
	int y, int var4, int var5, int var6, float partialTicks)
{
	TextRenderer fr = mc.textRenderer;
	
	Path path = list.get(index);
	fr.draw(matrixStack, "" + path.getFileName(), x + 28, y, 0xf0f0f0);
	fr.draw(matrixStack,
		"" + client.runDirectory.toPath().relativize(path), x + 28,
		y + 9, 0xa0a0a0);
}
 
Example 14
Source File: BleachCheckbox.java    From bleachhack-1.14 with GNU General Public License v3.0 5 votes vote down vote up
public void renderButton(int int_1, int int_2, float float_1) {
	MinecraftClient minecraftClient_1 = MinecraftClient.getInstance();
	GL11.glDepthMask(true);
	GL11.glEnable(GL11.GL_DEPTH_TEST);
	TextRenderer textRenderer = minecraftClient_1.textRenderer;
	int color = int_1 > x && int_1 < x + 10 && int_2 > y && int_2 < y + 10 ? 0xffc0c0c0 : 0xffe0e0e0;
	fill(x, y, x + 11, y + 11, color);
	fill(x, y, x + 1, y + 11, 0xff303030);
	fill(x, y + 10, x + 11, y + 11, 0xffb0b0b0);
	fill(x, y, x + 10, y + 1, 0xff303030);
	fill(x + 10, y, x + 11, y + 11, 0xffb0b0b0);
	if (checked) textRenderer.draw("\u2714", x + 2, y + 2, 0x000000); //fill(x + 3, y + 5, x + 8, y + 6, 0xff000000);
	drawString(textRenderer, getMessage(), x + 15, y + 2, 0xC0C0C0);
}
 
Example 15
Source File: BlockComponent.java    From Wurst7 with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void render(MatrixStack matrixStack, int mouseX, int mouseY,
	float partialTicks)
{
	ClickGui gui = WurstClient.INSTANCE.getGui();
	float[] bgColor = gui.getBgColor();
	float opacity = gui.getOpacity();
	
	int x1 = getX();
	int x2 = x1 + getWidth();
	int x3 = x2 - BLOCK_WITDH;
	int y1 = getY();
	int y2 = y1 + getHeight();
	
	int scroll = getParent().isScrollingEnabled()
		? getParent().getScrollOffset() : 0;
	boolean hovering = mouseX >= x1 && mouseY >= y1 && mouseX < x2
		&& mouseY < y2 && mouseY >= -scroll
		&& mouseY < getParent().getHeight() - 13 - scroll;
	boolean hText = hovering && mouseX < x3;
	boolean hBlock = hovering && mouseX >= x3;
	
	ItemStack stack = new ItemStack(setting.getBlock());
	
	// tooltip
	if(hText)
		gui.setTooltip(setting.getDescription());
	else if(hBlock)
	{
		String tooltip = "\u00a76Name:\u00a7r " + getBlockName(stack);
		tooltip += "\n\u00a76ID:\u00a7r " + setting.getBlockName();
		tooltip += "\n\n\u00a7e[left-click]\u00a7r to edit";
		tooltip += "\n\u00a7e[right-click]\u00a7r to reset";
		gui.setTooltip(tooltip);
	}
	
	// background
	GL11.glColor4f(bgColor[0], bgColor[1], bgColor[2], opacity);
	GL11.glBegin(GL11.GL_QUADS);
	GL11.glVertex2i(x1, y1);
	GL11.glVertex2i(x1, y2);
	GL11.glVertex2i(x2, y2);
	GL11.glVertex2i(x2, y1);
	GL11.glEnd();
	
	// setting name
	GL11.glColor4f(1, 1, 1, 1);
	GL11.glEnable(GL11.GL_TEXTURE_2D);
	TextRenderer fr = WurstClient.MC.textRenderer;
	String text = setting.getName() + ":";
	fr.draw(matrixStack, text, x1, y1 + 2, 0xf0f0f0);
	
	renderIcon(matrixStack, stack, x3, y1, true);
	
	GL11.glDisable(GL11.GL_TEXTURE_2D);
	GL11.glEnable(GL11.GL_BLEND);
}
 
Example 16
Source File: DrawableUtils.java    From Galacticraft-Rewoven with MIT License 4 votes vote down vote up
public static void drawCenteredString(MatrixStack stack, TextRenderer textRenderer, Text text, int x, int y, int color) {
    textRenderer.draw(stack, text, (float) (x - textRenderer.getWidth(text) / 2), (float) y, color);
}
 
Example 17
Source File: FileComponent.java    From Wurst7 with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void render(MatrixStack matrixStack, int mouseX, int mouseY,
	float partialTicks)
{
	ClickGui gui = WurstClient.INSTANCE.getGui();
	float[] bgColor = gui.getBgColor();
	float[] acColor = gui.getAcColor();
	float opacity = gui.getOpacity();
	
	TextRenderer fr = WurstClient.MC.textRenderer;
	int buttonWidth = fr.getWidth(setting.getSelectedFileName());
	
	int x1 = getX();
	int x2 = x1 + getWidth();
	int x3 = x2 - buttonWidth - 4;
	int y1 = getY();
	int y2 = y1 + getHeight();
	
	int scroll = getParent().isScrollingEnabled()
		? getParent().getScrollOffset() : 0;
	boolean hovering = mouseX >= x1 && mouseY >= y1 && mouseX < x2
		&& mouseY < y2 && mouseY >= -scroll
		&& mouseY < getParent().getHeight() - 13 - scroll;
	boolean hText = hovering && mouseX < x3;
	boolean hBox = hovering && mouseX >= x3;
	
	// tooltip
	if(hText)
		gui.setTooltip(setting.getDescription());
	else if(hBox)
	{
		String tooltip = "\u00a7e[left-click]\u00a7r to select file";
		gui.setTooltip(tooltip);
	}
	
	// background
	GL11.glColor4f(bgColor[0], bgColor[1], bgColor[2], opacity);
	GL11.glBegin(GL11.GL_QUADS);
	GL11.glVertex2i(x1, y1);
	GL11.glVertex2i(x1, y2);
	GL11.glVertex2i(x3, y2);
	GL11.glVertex2i(x3, y1);
	GL11.glEnd();
	
	// box
	GL11.glColor4f(bgColor[0], bgColor[1], bgColor[2],
		hBox ? opacity * 1.5F : opacity);
	GL11.glBegin(GL11.GL_QUADS);
	GL11.glVertex2i(x3, y1);
	GL11.glVertex2i(x3, y2);
	GL11.glVertex2i(x2, y2);
	GL11.glVertex2i(x2, y1);
	GL11.glEnd();
	GL11.glColor4f(acColor[0], acColor[1], acColor[2], 0.5F);
	GL11.glBegin(GL11.GL_LINE_LOOP);
	GL11.glVertex2i(x3, y1);
	GL11.glVertex2i(x3, y2);
	GL11.glVertex2i(x2, y2);
	GL11.glVertex2i(x2, y1);
	GL11.glEnd();
	
	// setting name
	GL11.glColor4f(1, 1, 1, 1);
	GL11.glEnable(GL11.GL_TEXTURE_2D);
	String text = setting.getName() + ": ";
	fr.draw(matrixStack, text, x1, y1 + 2, 0xf0f0f0);
	fr.draw(matrixStack, setting.getSelectedFileName(), x3 + 2, y1 + 2,
		0xf0f0f0);
	GL11.glDisable(GL11.GL_TEXTURE_2D);
	GL11.glEnable(GL11.GL_BLEND);
}
 
Example 18
Source File: DrawableUtils.java    From Galacticraft-Rewoven with MIT License 4 votes vote down vote up
public static void drawCenteredString(MatrixStack stack, TextRenderer textRenderer, String text, int x, int y, int color) {
    textRenderer.draw(stack, text, (float) (x - textRenderer.getWidth(text) / 2), (float) y, color);
}
 
Example 19
Source File: ItemListEditButton.java    From Wurst7 with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void render(MatrixStack matrixStack, int mouseX, int mouseY,
	float partialTicks)
{
	ClickGui gui = WurstClient.INSTANCE.getGui();
	float[] bgColor = gui.getBgColor();
	float[] acColor = gui.getAcColor();
	float opacity = gui.getOpacity();
	
	int x1 = getX();
	int x2 = x1 + getWidth();
	int x3 = x2 - buttonWidth - 4;
	int y1 = getY();
	int y2 = y1 + getHeight();
	
	int scroll = getParent().isScrollingEnabled()
		? getParent().getScrollOffset() : 0;
	boolean hovering = mouseX >= x1 && mouseY >= y1 && mouseX < x2
		&& mouseY < y2 && mouseY >= -scroll
		&& mouseY < getParent().getHeight() - 13 - scroll;
	boolean hText = hovering && mouseX < x3;
	boolean hBox = hovering && mouseX >= x3;
	
	// tooltip
	if(hText)
		gui.setTooltip(setting.getDescription());
	
	// background
	GL11.glColor4f(bgColor[0], bgColor[1], bgColor[2], opacity);
	GL11.glBegin(GL11.GL_QUADS);
	GL11.glVertex2i(x1, y1);
	GL11.glVertex2i(x1, y2);
	GL11.glVertex2i(x3, y2);
	GL11.glVertex2i(x3, y1);
	GL11.glEnd();
	
	// box
	GL11.glColor4f(bgColor[0], bgColor[1], bgColor[2],
		hBox ? opacity * 1.5F : opacity);
	GL11.glBegin(GL11.GL_QUADS);
	GL11.glVertex2i(x3, y1);
	GL11.glVertex2i(x3, y2);
	GL11.glVertex2i(x2, y2);
	GL11.glVertex2i(x2, y1);
	GL11.glEnd();
	GL11.glColor4f(acColor[0], acColor[1], acColor[2], 0.5F);
	GL11.glBegin(GL11.GL_LINE_LOOP);
	GL11.glVertex2i(x3, y1);
	GL11.glVertex2i(x3, y2);
	GL11.glVertex2i(x2, y2);
	GL11.glVertex2i(x2, y1);
	GL11.glEnd();
	
	// setting name
	GL11.glColor4f(1, 1, 1, 1);
	GL11.glEnable(GL11.GL_TEXTURE_2D);
	TextRenderer fr = WurstClient.MC.textRenderer;
	String text = setting.getName() + ": " + setting.getItemNames().size();
	fr.draw(matrixStack, text, x1, y1 + 2, 0xf0f0f0);
	fr.draw(matrixStack, "Edit...", x3 + 2, y1 + 2, 0xf0f0f0);
	GL11.glDisable(GL11.GL_TEXTURE_2D);
}
 
Example 20
Source File: EntityRendererMixin.java    From Wurst7 with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Copy of renderLabelIfPresent() since calling the original would result in
 * an infinite loop. Also makes it easier to modify.
 */
protected void wurstRenderLabelIfPresent(T entity, Text text,
	MatrixStack matrixStack, VertexConsumerProvider vertexConsumerProvider,
	int i)
{
	double d = this.dispatcher.getSquaredDistanceToCamera(entity);
	
	if(d > 4096)
		return;
	
	NameTagsHack nameTagsHack = WurstClient.INSTANCE.getHax().nameTagsHack;
	
	boolean bl = !entity.isSneaky() || nameTagsHack.isEnabled();
	float f = entity.getHeight() + 0.5F;
	int j = "deadmau5".equals(text.getString()) ? -10 : 0;
	
	matrixStack.push();
	matrixStack.translate(0.0D, f, 0.0D);
	matrixStack.multiply(this.dispatcher.getRotation());
	
	float scale = 0.025F;
	if(nameTagsHack.isEnabled())
	{
		double distance = WurstClient.MC.player.distanceTo(entity);
		
		if(distance > 10)
			scale *= distance / 10;
	}
	
	matrixStack.scale(-scale, -scale, scale);
	
	Matrix4f matrix4f = matrixStack.peek().getModel();
	float g = WurstClient.MC.options.getTextBackgroundOpacity(0.25F);
	int k = (int)(g * 255.0F) << 24;
	
	TextRenderer textRenderer = this.getFontRenderer();
	float h = -textRenderer.getWidth(text) / 2;
	
	textRenderer.draw(text, h, j, 553648127, false, matrix4f,
		vertexConsumerProvider, bl, k, i);
	
	if(bl)
		textRenderer.draw(text, h, j, -1, false, matrix4f,
			vertexConsumerProvider, false, 0, i);
	
	matrixStack.pop();
}