CuboidGizmo .java

net.minecraft.gizmos.CuboidGizmo (record, 43 lines): record with 3 components. members: aabb, style, coloredCornerStroke, emit. imports: ARGB.

net.minecraft.gizmosrecord43 linescommon2.7 KB

Implements

API Surface (1)

void emit(final GizmoPrimitives primitives, final float alphaMultiplier)

Code Graph: Dependencies (6)

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

Full Source

CuboidGizmo.java43 lines · Minecraft 26.3 · verbatim
1
package net.minecraft.gizmos;
2
3
import net.minecraft.util.ARGB;
4
import net.minecraft.world.phys.AABB;
5
import net.minecraft.world.phys.Vec3;
6
7
public record CuboidGizmo(AABB aabb, GizmoStyle style, boolean coloredCornerStroke) implements Gizmo {
8
	@Override
9
	public void emit(final GizmoPrimitives primitives, final float alphaMultiplier) {
10
		double x0 = this.aabb.minX;
11
		double y0 = this.aabb.minY;
12
		double z0 = this.aabb.minZ;
13
		double x1 = this.aabb.maxX;
14
		double y1 = this.aabb.maxY;
15
		double z1 = this.aabb.maxZ;
16
		if (this.style.hasFill()) {
17
			int color = this.style.multipliedFill(alphaMultiplier);
18
			primitives.addQuad(new Vec3(x1, y0, z0), new Vec3(x1, y1, z0), new Vec3(x1, y1, z1), new Vec3(x1, y0, z1), color);
19
			primitives.addQuad(new Vec3(x0, y0, z0), new Vec3(x0, y0, z1), new Vec3(x0, y1, z1), new Vec3(x0, y1, z0), color);
20
			primitives.addQuad(new Vec3(x0, y0, z0), new Vec3(x0, y1, z0), new Vec3(x1, y1, z0), new Vec3(x1, y0, z0), color);
21
			primitives.addQuad(new Vec3(x0, y0, z1), new Vec3(x1, y0, z1), new Vec3(x1, y1, z1), new Vec3(x0, y1, z1), color);
22
			primitives.addQuad(new Vec3(x0, y1, z0), new Vec3(x0, y1, z1), new Vec3(x1, y1, z1), new Vec3(x1, y1, z0), color);
23
			primitives.addQuad(new Vec3(x0, y0, z0), new Vec3(x1, y0, z0), new Vec3(x1, y0, z1), new Vec3(x0, y0, z1), color);
24
		}
25
26
		if (this.style.hasStroke()) {
27
			int color = this.style.multipliedStroke(alphaMultiplier);
28
			primitives.addLine(new Vec3(x0, y0, z0), new Vec3(x1, y0, z0), this.coloredCornerStroke ? ARGB.multiply(color, -34953) : color, this.style.strokeWidth());
29
			primitives.addLine(new Vec3(x0, y0, z0), new Vec3(x0, y1, z0), this.coloredCornerStroke ? ARGB.multiply(color, -8913033) : color, this.style.strokeWidth());
30
			primitives.addLine(new Vec3(x0, y0, z0), new Vec3(x0, y0, z1), this.coloredCornerStroke ? ARGB.multiply(color, -8947713) : color, this.style.strokeWidth());
31
			primitives.addLine(new Vec3(x1, y0, z0), new Vec3(x1, y1, z0), color, this.style.strokeWidth());
32
			primitives.addLine(new Vec3(x1, y1, z0), new Vec3(x0, y1, z0), color, this.style.strokeWidth());
33
			primitives.addLine(new Vec3(x0, y1, z0), new Vec3(x0, y1, z1), color, this.style.strokeWidth());
34
			primitives.addLine(new Vec3(x0, y1, z1), new Vec3(x0, y0, z1), color, this.style.strokeWidth());
35
			primitives.addLine(new Vec3(x0, y0, z1), new Vec3(x1, y0, z1), color, this.style.strokeWidth());
36
			primitives.addLine(new Vec3(x1, y0, z1), new Vec3(x1, y0, z0), color, this.style.strokeWidth());
37
			primitives.addLine(new Vec3(x0, y1, z1), new Vec3(x1, y1, z1), color, this.style.strokeWidth());
38
			primitives.addLine(new Vec3(x1, y0, z1), new Vec3(x1, y1, z1), color, this.style.strokeWidth());
39
			primitives.addLine(new Vec3(x1, y1, z0), new Vec3(x1, y1, z1), color, this.style.strokeWidth());
40
		}
41
	}
42
}
43

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