RectGizmo .java

net.minecraft.gizmos.RectGizmo (record, 70 lines): record with 5 components. members: style, fromCuboidFace, emit. imports: Direction.

net.minecraft.gizmosrecord70 linescommon2.8 KB

Implements

API Surface (2)

RectGizmo fromCuboidFace(final Vec3 cuboidCornerA, final Vec3 cuboidCornerB, final Direction face, final GizmoStyle style)
void emit(final GizmoPrimitives primitives, final float alphaMultiplier)

Code Graph: Dependencies (5)

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

Full Source

RectGizmo.java70 lines · Minecraft 26.3 · verbatim
1
package net.minecraft.gizmos;
2
3
import net.minecraft.core.Direction;
4
import net.minecraft.world.phys.Vec3;
5
6
public record RectGizmo(Vec3 a, Vec3 b, Vec3 c, Vec3 d, GizmoStyle style) implements Gizmo {
7
	public static RectGizmo fromCuboidFace(final Vec3 cuboidCornerA, final Vec3 cuboidCornerB, final Direction face, final GizmoStyle style) {
8
		return switch (face) {
9
			case DOWN -> new RectGizmo(
10
				new Vec3(cuboidCornerA.x, cuboidCornerA.y, cuboidCornerA.z),
11
				new Vec3(cuboidCornerB.x, cuboidCornerA.y, cuboidCornerA.z),
12
				new Vec3(cuboidCornerB.x, cuboidCornerA.y, cuboidCornerB.z),
13
				new Vec3(cuboidCornerA.x, cuboidCornerA.y, cuboidCornerB.z),
14
				style
15
			);
16
			case UP -> new RectGizmo(
17
				new Vec3(cuboidCornerA.x, cuboidCornerB.y, cuboidCornerA.z),
18
				new Vec3(cuboidCornerA.x, cuboidCornerB.y, cuboidCornerB.z),
19
				new Vec3(cuboidCornerB.x, cuboidCornerB.y, cuboidCornerB.z),
20
				new Vec3(cuboidCornerB.x, cuboidCornerB.y, cuboidCornerA.z),
21
				style
22
			);
23
			case NORTH -> new RectGizmo(
24
				new Vec3(cuboidCornerA.x, cuboidCornerA.y, cuboidCornerA.z),
25
				new Vec3(cuboidCornerA.x, cuboidCornerB.y, cuboidCornerA.z),
26
				new Vec3(cuboidCornerB.x, cuboidCornerB.y, cuboidCornerA.z),
27
				new Vec3(cuboidCornerB.x, cuboidCornerA.y, cuboidCornerA.z),
28
				style
29
			);
30
			case SOUTH -> new RectGizmo(
31
				new Vec3(cuboidCornerA.x, cuboidCornerA.y, cuboidCornerB.z),
32
				new Vec3(cuboidCornerB.x, cuboidCornerA.y, cuboidCornerB.z),
33
				new Vec3(cuboidCornerB.x, cuboidCornerB.y, cuboidCornerB.z),
34
				new Vec3(cuboidCornerA.x, cuboidCornerB.y, cuboidCornerB.z),
35
				style
36
			);
37
			case WEST -> new RectGizmo(
38
				new Vec3(cuboidCornerA.x, cuboidCornerA.y, cuboidCornerA.z),
39
				new Vec3(cuboidCornerA.x, cuboidCornerA.y, cuboidCornerB.z),
40
				new Vec3(cuboidCornerA.x, cuboidCornerB.y, cuboidCornerB.z),
41
				new Vec3(cuboidCornerA.x, cuboidCornerB.y, cuboidCornerA.z),
42
				style
43
			);
44
			case EAST -> new RectGizmo(
45
				new Vec3(cuboidCornerB.x, cuboidCornerA.y, cuboidCornerA.z),
46
				new Vec3(cuboidCornerB.x, cuboidCornerB.y, cuboidCornerA.z),
47
				new Vec3(cuboidCornerB.x, cuboidCornerB.y, cuboidCornerB.z),
48
				new Vec3(cuboidCornerB.x, cuboidCornerA.y, cuboidCornerB.z),
49
				style
50
			);
51
		};
52
	}
53
54
	@Override
55
	public void emit(final GizmoPrimitives primitives, final float alphaMultiplier) {
56
		if (this.style.hasFill()) {
57
			int color = this.style.multipliedFill(alphaMultiplier);
58
			primitives.addQuad(this.a, this.b, this.c, this.d, color);
59
		}
60
61
		if (this.style.hasStroke()) {
62
			int color = this.style.multipliedStroke(alphaMultiplier);
63
			primitives.addLine(this.a, this.b, color, this.style.strokeWidth());
64
			primitives.addLine(this.b, this.c, color, this.style.strokeWidth());
65
			primitives.addLine(this.c, this.d, color, this.style.strokeWidth());
66
			primitives.addLine(this.d, this.a, color, this.style.strokeWidth());
67
		}
68
	}
69
}
70

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