Gizmos.java

net.minecraft.gizmos.Gizmos

信息

  • 全限定名:net.minecraft.gizmos.Gizmos
  • 类型:public class
  • 包:net.minecraft.gizmos
  • 源码路径:src/main/java/net/minecraft/gizmos/Gizmos.java
  • 起始行号:L10
  • 职责:

    TODO

字段/常量

  • collector
    • 类型: ThreadLocal<GizmoCollector>
    • 修饰符: private static final
    • 源码定位: L11
    • 说明:

      TODO

内部类/嵌套类型

  • net.minecraft.gizmos.Gizmos.TemporaryCollection
    • 类型: class
    • 修饰符: public static
    • 源码定位: L105
    • 说明:

      TODO

构造器

private Gizmos() @ L13

  • 构造器名:Gizmos
  • 源码定位:L13
  • 修饰符:private

参数:

说明:

TODO

方法

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

public static Gizmos.TemporaryCollection withCollector(GizmoCollector collector) @ L16

  • 方法名:withCollector
  • 源码定位:L16
  • 返回类型:Gizmos.TemporaryCollection
  • 修饰符:public static

参数:

  • collector: GizmoCollector

说明:

TODO

public static GizmoProperties addGizmo(Gizmo gizmo) @ L22

  • 方法名:addGizmo
  • 源码定位:L22
  • 返回类型:GizmoProperties
  • 修饰符:public static

参数:

  • gizmo: Gizmo

说明:

TODO

public static GizmoProperties cuboid(AABB aabb, GizmoStyle style) @ L31

  • 方法名:cuboid
  • 源码定位:L31
  • 返回类型:GizmoProperties
  • 修饰符:public static

参数:

  • aabb: AABB
  • style: GizmoStyle

说明:

TODO

public static GizmoProperties cuboid(AABB aabb, GizmoStyle style, boolean coloredCorner) @ L35

  • 方法名:cuboid
  • 源码定位:L35
  • 返回类型:GizmoProperties
  • 修饰符:public static

参数:

  • aabb: AABB
  • style: GizmoStyle
  • coloredCorner: boolean

说明:

TODO

public static GizmoProperties cuboid(BlockPos blockPos, GizmoStyle style) @ L39

  • 方法名:cuboid
  • 源码定位:L39
  • 返回类型:GizmoProperties
  • 修饰符:public static

参数:

  • blockPos: BlockPos
  • style: GizmoStyle

说明:

TODO

public static GizmoProperties cuboid(BlockPos blockPos, float padding, GizmoStyle style) @ L43

  • 方法名:cuboid
  • 源码定位:L43
  • 返回类型:GizmoProperties
  • 修饰符:public static

参数:

  • blockPos: BlockPos
  • padding: float
  • style: GizmoStyle

说明:

TODO

public static GizmoProperties circle(Vec3 pos, float radius, GizmoStyle style) @ L47

  • 方法名:circle
  • 源码定位:L47
  • 返回类型:GizmoProperties
  • 修饰符:public static

参数:

  • pos: Vec3
  • radius: float
  • style: GizmoStyle

说明:

TODO

public static GizmoProperties line(Vec3 start, Vec3 end, int argb) @ L51

  • 方法名:line
  • 源码定位:L51
  • 返回类型:GizmoProperties
  • 修饰符:public static

参数:

  • start: Vec3
  • end: Vec3
  • argb: int

说明:

TODO

public static GizmoProperties line(Vec3 start, Vec3 end, int argb, float width) @ L55

  • 方法名:line
  • 源码定位:L55
  • 返回类型:GizmoProperties
  • 修饰符:public static

参数:

  • start: Vec3
  • end: Vec3
  • argb: int
  • width: float

说明:

TODO

public static GizmoProperties arrow(Vec3 start, Vec3 end, int argb) @ L59

  • 方法名:arrow
  • 源码定位:L59
  • 返回类型:GizmoProperties
  • 修饰符:public static

参数:

  • start: Vec3
  • end: Vec3
  • argb: int

说明:

TODO

public static GizmoProperties arrow(Vec3 start, Vec3 end, int argb, float width) @ L63

  • 方法名:arrow
  • 源码定位:L63
  • 返回类型:GizmoProperties
  • 修饰符:public static

参数:

  • start: Vec3
  • end: Vec3
  • argb: int
  • width: float

说明:

TODO

public static GizmoProperties rect(Vec3 cuboidCornerA, Vec3 cuboidCornerB, Direction face, GizmoStyle style) @ L67

  • 方法名:rect
  • 源码定位:L67
  • 返回类型:GizmoProperties
  • 修饰符:public static

参数:

  • cuboidCornerA: Vec3
  • cuboidCornerB: Vec3
  • face: Direction
  • style: GizmoStyle

说明:

TODO

public static GizmoProperties rect(Vec3 cornerA, Vec3 cornerB, Vec3 cornerC, Vec3 cornerD, GizmoStyle style) @ L71

  • 方法名:rect
  • 源码定位:L71
  • 返回类型:GizmoProperties
  • 修饰符:public static

参数:

  • cornerA: Vec3
  • cornerB: Vec3
  • cornerC: Vec3
  • cornerD: Vec3
  • style: GizmoStyle

说明:

TODO

public static GizmoProperties point(Vec3 position, int argb, float size) @ L75

  • 方法名:point
  • 源码定位:L75
  • 返回类型:GizmoProperties
  • 修饰符:public static

参数:

  • position: Vec3
  • argb: int
  • size: float

说明:

TODO

public static GizmoProperties billboardTextOverBlock(String text, BlockPos pos, int row, int color, float scale) @ L79

  • 方法名:billboardTextOverBlock
  • 源码定位:L79
  • 返回类型:GizmoProperties
  • 修饰符:public static

参数:

  • text: String
  • pos: BlockPos
  • row: int
  • color: int
  • scale: float

说明:

TODO

public static GizmoProperties billboardTextOverMob(Entity entity, int row, String text, int color, float scale) @ L89

  • 方法名:billboardTextOverMob
  • 源码定位:L89
  • 返回类型:GizmoProperties
  • 修饰符:public static

参数:

  • entity: Entity
  • row: int
  • text: String
  • color: int
  • scale: float

说明:

TODO

public static GizmoProperties billboardText(String name, Vec3 pos, TextGizmo.Style style) @ L101

  • 方法名:billboardText
  • 源码定位:L101
  • 返回类型:GizmoProperties
  • 修饰符:public static

参数:

  • name: String
  • pos: Vec3
  • style: TextGizmo.Style

说明:

TODO

代码

public class Gizmos {
    private static final ThreadLocal<@Nullable GizmoCollector> collector = new ThreadLocal<>();
 
    private Gizmos() {
    }
 
    public static Gizmos.TemporaryCollection withCollector(GizmoCollector collector) {
        Gizmos.TemporaryCollection result = new Gizmos.TemporaryCollection();
        Gizmos.collector.set(collector);
        return result;
    }
 
    public static GizmoProperties addGizmo(Gizmo gizmo) {
        GizmoCollector collector = Gizmos.collector.get();
        if (collector == null) {
            throw new IllegalStateException("Gizmos cannot be created here! No GizmoCollector has been registered.");
        } else {
            return collector.add(gizmo);
        }
    }
 
    public static GizmoProperties cuboid(AABB aabb, GizmoStyle style) {
        return cuboid(aabb, style, false);
    }
 
    public static GizmoProperties cuboid(AABB aabb, GizmoStyle style, boolean coloredCorner) {
        return addGizmo(new CuboidGizmo(aabb, style, coloredCorner));
    }
 
    public static GizmoProperties cuboid(BlockPos blockPos, GizmoStyle style) {
        return cuboid(new AABB(blockPos), style);
    }
 
    public static GizmoProperties cuboid(BlockPos blockPos, float padding, GizmoStyle style) {
        return cuboid(new AABB(blockPos).inflate(padding), style);
    }
 
    public static GizmoProperties circle(Vec3 pos, float radius, GizmoStyle style) {
        return addGizmo(new CircleGizmo(pos, radius, style));
    }
 
    public static GizmoProperties line(Vec3 start, Vec3 end, int argb) {
        return addGizmo(new LineGizmo(start, end, argb, 3.0F));
    }
 
    public static GizmoProperties line(Vec3 start, Vec3 end, int argb, float width) {
        return addGizmo(new LineGizmo(start, end, argb, width));
    }
 
    public static GizmoProperties arrow(Vec3 start, Vec3 end, int argb) {
        return addGizmo(new ArrowGizmo(start, end, argb, 2.5F));
    }
 
    public static GizmoProperties arrow(Vec3 start, Vec3 end, int argb, float width) {
        return addGizmo(new ArrowGizmo(start, end, argb, width));
    }
 
    public static GizmoProperties rect(Vec3 cuboidCornerA, Vec3 cuboidCornerB, Direction face, GizmoStyle style) {
        return addGizmo(RectGizmo.fromCuboidFace(cuboidCornerA, cuboidCornerB, face, style));
    }
 
    public static GizmoProperties rect(Vec3 cornerA, Vec3 cornerB, Vec3 cornerC, Vec3 cornerD, GizmoStyle style) {
        return addGizmo(new RectGizmo(cornerA, cornerB, cornerC, cornerD, style));
    }
 
    public static GizmoProperties point(Vec3 position, int argb, float size) {
        return addGizmo(new PointGizmo(position, argb, size));
    }
 
    public static GizmoProperties billboardTextOverBlock(String text, BlockPos pos, int row, int color, float scale) {
        double firstRowStartPosition = 1.3;
        double rowHeight = 0.2;
        GizmoProperties properties = billboardText(
            text, Vec3.atLowerCornerWithOffset(pos, 0.5, 1.3 + row * 0.2, 0.5), TextGizmo.Style.forColorAndCentered(color).withScale(scale)
        );
        properties.setAlwaysOnTop();
        return properties;
    }
 
    public static GizmoProperties billboardTextOverMob(Entity entity, int row, String text, int color, float scale) {
        double firstRowStartPosition = 2.4;
        double rowHeight = 0.25;
        double x = entity.getBlockX() + 0.5;
        double y = entity.getY() + 2.4 + row * 0.25;
        double z = entity.getBlockZ() + 0.5;
        float textAdjustLeft = 0.5F;
        GizmoProperties properties = billboardText(text, new Vec3(x, y, z), TextGizmo.Style.forColor(color).withScale(scale).withLeftAlignment(0.5F));
        properties.setAlwaysOnTop();
        return properties;
    }
 
    public static GizmoProperties billboardText(String name, Vec3 pos, TextGizmo.Style style) {
        return addGizmo(new TextGizmo(pos, name, style));
    }
 
    public static class TemporaryCollection implements AutoCloseable {
        private final @Nullable GizmoCollector old = Gizmos.collector.get();
        private boolean closed;
 
        private TemporaryCollection() {
        }
 
        @Override
        public void close() {
            if (!this.closed) {
                this.closed = true;
                Gizmos.collector.set(this.old);
            }
        }
    }
}

引用的其他类

  • BlockPos

    • 引用位置: 参数
  • Direction

    • 引用位置: 参数
  • ArrowGizmo

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

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

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

    • 引用位置: 参数
  • GizmoCollector

    • 引用位置: 参数/字段
  • GizmoProperties

    • 引用位置: 返回值
  • GizmoStyle

    • 引用位置: 参数
  • LineGizmo

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

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

    • 引用位置: 方法调用/构造调用
    • 关联成员: RectGizmo(), RectGizmo.fromCuboidFace()
  • TextGizmo

    • 引用位置: 参数/方法调用/构造调用
    • 关联成员: TextGizmo(), TextGizmo.Style.forColor(), TextGizmo.Style.forColorAndCentered()
  • Entity

    • 引用位置: 参数
  • AABB

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

    • 引用位置: 参数/方法调用/构造调用
    • 关联成员: Vec3(), Vec3.atLowerCornerWithOffset()