CuboidGizmo.java

net.minecraft.gizmos.CuboidGizmo

信息

  • 全限定名:net.minecraft.gizmos.CuboidGizmo
  • 类型:public record
  • 包:net.minecraft.gizmos
  • 源码路径:src/main/java/net/minecraft/gizmos/CuboidGizmo.java
  • 起始行号:L7
  • 实现:Gizmo
  • 职责:

    TODO

字段/常量

内部类/嵌套类型

构造器

方法

下面的方法块按源码顺序生成。

public void emit(GizmoPrimitives primitives, float alphaMultiplier) @ L8

  • 方法名:emit
  • 源码定位:L8
  • 返回类型:void
  • 修饰符:public

参数:

  • primitives: GizmoPrimitives
  • alphaMultiplier: float

说明:

TODO

代码

public record CuboidGizmo(AABB aabb, GizmoStyle style, boolean coloredCornerStroke) implements Gizmo {
    @Override
    public void emit(GizmoPrimitives primitives, float alphaMultiplier) {
        double x0 = this.aabb.minX;
        double y0 = this.aabb.minY;
        double z0 = this.aabb.minZ;
        double x1 = this.aabb.maxX;
        double y1 = this.aabb.maxY;
        double z1 = this.aabb.maxZ;
        if (this.style.hasFill()) {
            int color = this.style.multipliedFill(alphaMultiplier);
            primitives.addQuad(new Vec3(x1, y0, z0), new Vec3(x1, y1, z0), new Vec3(x1, y1, z1), new Vec3(x1, y0, z1), color);
            primitives.addQuad(new Vec3(x0, y0, z0), new Vec3(x0, y0, z1), new Vec3(x0, y1, z1), new Vec3(x0, y1, z0), color);
            primitives.addQuad(new Vec3(x0, y0, z0), new Vec3(x0, y1, z0), new Vec3(x1, y1, z0), new Vec3(x1, y0, z0), color);
            primitives.addQuad(new Vec3(x0, y0, z1), new Vec3(x1, y0, z1), new Vec3(x1, y1, z1), new Vec3(x0, y1, z1), color);
            primitives.addQuad(new Vec3(x0, y1, z0), new Vec3(x0, y1, z1), new Vec3(x1, y1, z1), new Vec3(x1, y1, z0), color);
            primitives.addQuad(new Vec3(x0, y0, z0), new Vec3(x1, y0, z0), new Vec3(x1, y0, z1), new Vec3(x0, y0, z1), color);
        }
 
        if (this.style.hasStroke()) {
            int color = this.style.multipliedStroke(alphaMultiplier);
            primitives.addLine(
                new Vec3(x0, y0, z0), new Vec3(x1, y0, z0), this.coloredCornerStroke ? ARGB.multiply(color, -34953) : color, this.style.strokeWidth()
            );
            primitives.addLine(
                new Vec3(x0, y0, z0), new Vec3(x0, y1, z0), this.coloredCornerStroke ? ARGB.multiply(color, -8913033) : color, this.style.strokeWidth()
            );
            primitives.addLine(
                new Vec3(x0, y0, z0), new Vec3(x0, y0, z1), this.coloredCornerStroke ? ARGB.multiply(color, -8947713) : color, this.style.strokeWidth()
            );
            primitives.addLine(new Vec3(x1, y0, z0), new Vec3(x1, y1, z0), color, this.style.strokeWidth());
            primitives.addLine(new Vec3(x1, y1, z0), new Vec3(x0, y1, z0), color, this.style.strokeWidth());
            primitives.addLine(new Vec3(x0, y1, z0), new Vec3(x0, y1, z1), color, this.style.strokeWidth());
            primitives.addLine(new Vec3(x0, y1, z1), new Vec3(x0, y0, z1), color, this.style.strokeWidth());
            primitives.addLine(new Vec3(x0, y0, z1), new Vec3(x1, y0, z1), color, this.style.strokeWidth());
            primitives.addLine(new Vec3(x1, y0, z1), new Vec3(x1, y0, z0), color, this.style.strokeWidth());
            primitives.addLine(new Vec3(x0, y1, z1), new Vec3(x1, y1, z1), color, this.style.strokeWidth());
            primitives.addLine(new Vec3(x1, y0, z1), new Vec3(x1, y1, z1), color, this.style.strokeWidth());
            primitives.addLine(new Vec3(x1, y1, z0), new Vec3(x1, y1, z1), color, this.style.strokeWidth());
        }
    }
}

引用的其他类

  • Gizmo

    • 引用位置: 实现
  • GizmoPrimitives

    • 引用位置: 参数
  • ARGB

    • 引用位置: 方法调用
    • 关联成员: ARGB.multiply()
  • Vec3

    • 引用位置: 构造调用
    • 关联成员: Vec3()