| 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 |
|