GuiTextRenderState .java

net.minecraft.client.renderer.state.gui.GuiTextRenderState (class): members: ensurePrepared, preparedText, scissor, includeEmpty, backgroundColor, bounds.

net.minecraft.client.renderer.state.guiclass69 linesclient1.9 KB

Implements

API Surface (1)

Font.PreparedText ensurePrepared()

Fields & Constants (12)

font
text
pose
x
y
color
backgroundColor
dropShadow
includeEmpty
scissor
preparedText
bounds

Code Graph: Dependencies (4)

Edges (calls / imports / inherits / references) resolved by graphify from the AST. Every chip opens the class source.

Full Source

GuiTextRenderState.java69 lines · Minecraft 26.3 · verbatim
1
package net.minecraft.client.renderer.state.gui;
2
3
import net.fabricmc.api.EnvType;
4
import net.fabricmc.api.Environment;
5
import net.minecraft.client.gui.Font;
6
import net.minecraft.client.gui.navigation.ScreenRectangle;
7
import net.minecraft.util.FormattedCharSequence;
8
import org.joml.Matrix3x2fc;
9
import org.jspecify.annotations.Nullable;
10
11
@Environment(EnvType.CLIENT)
12
public final class GuiTextRenderState implements ScreenArea {
13
	private final Font font;
14
	private final FormattedCharSequence text;
15
	public final Matrix3x2fc pose;
16
	private final int x;
17
	private final int y;
18
	private final int color;
19
	private final int backgroundColor;
20
	private final boolean dropShadow;
21
	private final boolean includeEmpty;
22
	public final @Nullable ScreenRectangle scissor;
23
	private Font.@Nullable PreparedText preparedText;
24
	private @Nullable ScreenRectangle bounds;
25
26
	public GuiTextRenderState(
27
		final Font font,
28
		final FormattedCharSequence text,
29
		final Matrix3x2fc pose,
30
		final int x,
31
		final int y,
32
		final int color,
33
		final int backgroundColor,
34
		final boolean dropShadow,
35
		final boolean includeEmpty,
36
		final @Nullable ScreenRectangle scissor
37
	) {
38
		this.font = font;
39
		this.text = text;
40
		this.pose = pose;
41
		this.x = x;
42
		this.y = y;
43
		this.color = color;
44
		this.backgroundColor = backgroundColor;
45
		this.dropShadow = dropShadow;
46
		this.includeEmpty = includeEmpty;
47
		this.scissor = scissor;
48
	}
49
50
	public Font.PreparedText ensurePrepared() {
51
		if (this.preparedText == null) {
52
			this.preparedText = this.font.prepareText(this.text, this.x, this.y, this.color, this.dropShadow, this.includeEmpty, this.backgroundColor);
53
			ScreenRectangle bounds = this.preparedText.bounds();
54
			if (bounds != null) {
55
				bounds = bounds.transformMaxBounds(this.pose);
56
				this.bounds = this.scissor != null ? this.scissor.intersection(bounds) : bounds;
57
			}
58
		}
59
60
		return this.preparedText;
61
	}
62
63
	@Override
64
	public @Nullable ScreenRectangle bounds() {
65
		this.ensurePrepared();
66
		return this.bounds;
67
	}
68
}
69

Decompiled Minecraft 26.3 source of GuiTextRenderState (net/minecraft/client/renderer/state/gui/GuiTextRenderState.java) with Mojang official mappings, stored verbatim on the site.