DrawableGizmoPrimitives .java

net.minecraft.client.renderer.gizmos.DrawableGizmoPrimitives (class): members: triangleFans, TriangleFan, Quad, addTriangleFan, addPoint, addQuad, opaque.

net.minecraft.client.renderer.gizmosclass99 linesclient3.2 KB

Implements

API Surface (13)

void addPoint(final Vec3 pos, final int color, final float size)
void addLine(final Vec3 start, final Vec3 end, final int color, final float width)
void addTriangleFan(final Vec3[] points, final int color)
void addQuad(final Vec3 a, final Vec3 b, final Vec3 c, final Vec3 d, final int color)
void addText(final Vec3 pos, final String text, final Style style)
void submit(final SubmitNodeCollector submitNodeCollector, final CameraRenderState cameraRenderState, final boolean onTop)
boolean isEmpty()
record Group(boolean opaque, List<DrawableGizmoPrimitives.Line> lines, List<DrawableGizmoPrimitives.Quad> quads, List<DrawableGizmoPrimitives.TriangleFan> triangleFans, List<DrawableGizmoPrimitives.Text> texts, List<DrawableGizmoPrimitives.Point> points)
record Line(Vec3 start, Vec3 end, int color, float width)
record Point(Vec3 pos, int color, float size)
record Quad(Vec3 a, Vec3 b, Vec3 c, Vec3 d, int color)
record Text(Vec3 pos, String text, Style style)
record TriangleFan(Vec3[] points, int color)

Fields & Constants (7)

opaque
translucent
isEmpty
lines
quads
triangleFans
texts

Same Package (1)

Code Graph: Dependencies (6)

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

Full Source

DrawableGizmoPrimitives.java99 lines · Minecraft 26.3 · verbatim
1
package net.minecraft.client.renderer.gizmos;
2
3
import java.util.ArrayList;
4
import java.util.List;
5
import net.fabricmc.api.EnvType;
6
import net.fabricmc.api.Environment;
7
import net.minecraft.client.renderer.SubmitNodeCollector;
8
import net.minecraft.client.renderer.state.level.CameraRenderState;
9
import net.minecraft.gizmos.GizmoPrimitives;
10
import net.minecraft.gizmos.TextGizmo.Style;
11
import net.minecraft.util.ARGB;
12
import net.minecraft.world.phys.Vec3;
13
14
@Environment(EnvType.CLIENT)
15
public class DrawableGizmoPrimitives implements GizmoPrimitives {
16
	private final DrawableGizmoPrimitives.Group opaque = new DrawableGizmoPrimitives.Group(true);
17
	private final DrawableGizmoPrimitives.Group translucent = new DrawableGizmoPrimitives.Group(false);
18
	private boolean isEmpty = true;
19
20
	private DrawableGizmoPrimitives.Group getGroup(final int color) {
21
		return ARGB.alpha(color) < 255 ? this.translucent : this.opaque;
22
	}
23
24
	@Override
25
	public void addPoint(final Vec3 pos, final int color, final float size) {
26
		this.getGroup(color).points.add(new DrawableGizmoPrimitives.Point(pos, color, size));
27
		this.isEmpty = false;
28
	}
29
30
	@Override
31
	public void addLine(final Vec3 start, final Vec3 end, final int color, final float width) {
32
		this.getGroup(color).lines.add(new DrawableGizmoPrimitives.Line(start, end, color, width));
33
		this.isEmpty = false;
34
	}
35
36
	@Override
37
	public void addTriangleFan(final Vec3[] points, final int color) {
38
		this.getGroup(color).triangleFans.add(new DrawableGizmoPrimitives.TriangleFan(points, color));
39
		this.isEmpty = false;
40
	}
41
42
	@Override
43
	public void addQuad(final Vec3 a, final Vec3 b, final Vec3 c, final Vec3 d, final int color) {
44
		this.getGroup(color).quads.add(new DrawableGizmoPrimitives.Quad(a, b, c, d, color));
45
		this.isEmpty = false;
46
	}
47
48
	@Override
49
	public void addText(final Vec3 pos, final String text, final Style style) {
50
		this.getGroup(style.color()).texts.add(new DrawableGizmoPrimitives.Text(pos, text, style));
51
		this.isEmpty = false;
52
	}
53
54
	public void submit(final SubmitNodeCollector submitNodeCollector, final CameraRenderState cameraRenderState, final boolean onTop) {
55
		if (!this.isEmpty) {
56
			submitNodeCollector.submitGizmoPrimitives(this.opaque, cameraRenderState, onTop);
57
			submitNodeCollector.submitGizmoPrimitives(this.translucent, cameraRenderState, onTop);
58
		}
59
	}
60
61
	public boolean isEmpty() {
62
		return this.isEmpty;
63
	}
64
65
	@Environment(EnvType.CLIENT)
66
	public record Group(
67
		boolean opaque,
68
		List<DrawableGizmoPrimitives.Line> lines,
69
		List<DrawableGizmoPrimitives.Quad> quads,
70
		List<DrawableGizmoPrimitives.TriangleFan> triangleFans,
71
		List<DrawableGizmoPrimitives.Text> texts,
72
		List<DrawableGizmoPrimitives.Point> points
73
	) {
74
		private Group(final boolean opaque) {
75
			this(opaque, new ArrayList<>(), new ArrayList<>(), new ArrayList<>(), new ArrayList<>(), new ArrayList<>());
76
		}
77
	}
78
79
	@Environment(EnvType.CLIENT)
80
	public record Line(Vec3 start, Vec3 end, int color, float width) {
81
	}
82
83
	@Environment(EnvType.CLIENT)
84
	public record Point(Vec3 pos, int color, float size) {
85
	}
86
87
	@Environment(EnvType.CLIENT)
88
	public record Quad(Vec3 a, Vec3 b, Vec3 c, Vec3 d, int color) {
89
	}
90
91
	@Environment(EnvType.CLIENT)
92
	public record Text(Vec3 pos, String text, Style style) {
93
	}
94
95
	@Environment(EnvType.CLIENT)
96
	public record TriangleFan(Vec3[] points, int color) {
97
	}
98
}
99

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