ChunkBorderRenderer.java

net.minecraft.client.renderer.debug.ChunkBorderRenderer

信息

  • 全限定名:net.minecraft.client.renderer.debug.ChunkBorderRenderer
  • 类型:public class
  • 包:net.minecraft.client.renderer.debug
  • 源码路径:src/main/java/net/minecraft/client/renderer/debug/ChunkBorderRenderer.java
  • 起始行号:L17
  • 实现:DebugRenderer.SimpleDebugRenderer
  • 职责:

    TODO

字段/常量

  • THICK_WIDTH

    • 类型: float
    • 修饰符: private static final
    • 源码定位: L18
    • 说明:

      TODO

  • THIN_WIDTH

    • 类型: float
    • 修饰符: private static final
    • 源码定位: L19
    • 说明:

      TODO

  • minecraft

    • 类型: Minecraft
    • 修饰符: private final
    • 源码定位: L20
    • 说明:

      TODO

  • CELL_BORDER

    • 类型: int
    • 修饰符: private static final
    • 源码定位: L21
    • 说明:

      TODO

  • YELLOW

    • 类型: int
    • 修饰符: private static final
    • 源码定位: L22
    • 说明:

      TODO

  • MAJOR_LINES

    • 类型: int
    • 修饰符: private static final
    • 源码定位: L23
    • 说明:

      TODO

内部类/嵌套类型

构造器

public ChunkBorderRenderer(Minecraft minecraft) @ L25

  • 构造器名:ChunkBorderRenderer
  • 源码定位:L25
  • 修饰符:public

参数:

  • minecraft: Minecraft

说明:

TODO

方法

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

public void emitGizmos(double camX, double camY, double camZ, DebugValueAccess debugValues, Frustum frustum, float partialTicks) @ L29

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

参数:

  • camX: double
  • camY: double
  • camZ: double
  • debugValues: DebugValueAccess
  • frustum: Frustum
  • partialTicks: float

说明:

TODO

代码

@OnlyIn(Dist.CLIENT)
public class ChunkBorderRenderer implements DebugRenderer.SimpleDebugRenderer {
    private static final float THICK_WIDTH = 4.0F;
    private static final float THIN_WIDTH = 1.0F;
    private final Minecraft minecraft;
    private static final int CELL_BORDER = ARGB.color(255, 0, 155, 155);
    private static final int YELLOW = ARGB.color(255, 255, 255, 0);
    private static final int MAJOR_LINES = ARGB.colorFromFloat(1.0F, 0.25F, 0.25F, 1.0F);
 
    public ChunkBorderRenderer(Minecraft minecraft) {
        this.minecraft = minecraft;
    }
 
    @Override
    public void emitGizmos(double camX, double camY, double camZ, DebugValueAccess debugValues, Frustum frustum, float partialTicks) {
        Entity cameraEntity = this.minecraft.getCameraEntity();
        float ymin = this.minecraft.level.getMinY();
        float ymax = this.minecraft.level.getMaxY() + 1;
        SectionPos cameraPos = SectionPos.of(cameraEntity.blockPosition());
        double xstart = cameraPos.minBlockX();
        double zstart = cameraPos.minBlockZ();
 
        for (int x = -16; x <= 32; x += 16) {
            for (int z = -16; z <= 32; z += 16) {
                Gizmos.line(new Vec3(xstart + x, ymin, zstart + z), new Vec3(xstart + x, ymax, zstart + z), ARGB.colorFromFloat(0.5F, 1.0F, 0.0F, 0.0F), 4.0F);
            }
        }
 
        for (int x = 2; x < 16; x += 2) {
            int color = x % 4 == 0 ? CELL_BORDER : YELLOW;
            Gizmos.line(new Vec3(xstart + x, ymin, zstart), new Vec3(xstart + x, ymax, zstart), color, 1.0F);
            Gizmos.line(new Vec3(xstart + x, ymin, zstart + 16.0), new Vec3(xstart + x, ymax, zstart + 16.0), color, 1.0F);
        }
 
        for (int z = 2; z < 16; z += 2) {
            int color = z % 4 == 0 ? CELL_BORDER : YELLOW;
            Gizmos.line(new Vec3(xstart, ymin, zstart + z), new Vec3(xstart, ymax, zstart + z), color, 1.0F);
            Gizmos.line(new Vec3(xstart + 16.0, ymin, zstart + z), new Vec3(xstart + 16.0, ymax, zstart + z), color, 1.0F);
        }
 
        for (int y = this.minecraft.level.getMinY(); y <= this.minecraft.level.getMaxY() + 1; y += 2) {
            float yline = y;
            int color = y % 8 == 0 ? CELL_BORDER : YELLOW;
            Gizmos.line(new Vec3(xstart, yline, zstart), new Vec3(xstart, yline, zstart + 16.0), color, 1.0F);
            Gizmos.line(new Vec3(xstart, yline, zstart + 16.0), new Vec3(xstart + 16.0, yline, zstart + 16.0), color, 1.0F);
            Gizmos.line(new Vec3(xstart + 16.0, yline, zstart + 16.0), new Vec3(xstart + 16.0, yline, zstart), color, 1.0F);
            Gizmos.line(new Vec3(xstart + 16.0, yline, zstart), new Vec3(xstart, yline, zstart), color, 1.0F);
        }
 
        for (int x = 0; x <= 16; x += 16) {
            for (int z = 0; z <= 16; z += 16) {
                Gizmos.line(new Vec3(xstart + x, ymin, zstart + z), new Vec3(xstart + x, ymax, zstart + z), MAJOR_LINES, 4.0F);
            }
        }
 
        Gizmos.cuboid(
                new AABB(
                    cameraPos.minBlockX(),
                    cameraPos.minBlockY(),
                    cameraPos.minBlockZ(),
                    cameraPos.maxBlockX() + 1,
                    cameraPos.maxBlockY() + 1,
                    cameraPos.maxBlockZ() + 1
                ),
                GizmoStyle.stroke(MAJOR_LINES, 1.0F)
            )
            .setAlwaysOnTop();
 
        for (int y = this.minecraft.level.getMinY(); y <= this.minecraft.level.getMaxY() + 1; y += 16) {
            Gizmos.line(new Vec3(xstart, y, zstart), new Vec3(xstart, y, zstart + 16.0), MAJOR_LINES, 4.0F);
            Gizmos.line(new Vec3(xstart, y, zstart + 16.0), new Vec3(xstart + 16.0, y, zstart + 16.0), MAJOR_LINES, 4.0F);
            Gizmos.line(new Vec3(xstart + 16.0, y, zstart + 16.0), new Vec3(xstart + 16.0, y, zstart), MAJOR_LINES, 4.0F);
            Gizmos.line(new Vec3(xstart + 16.0, y, zstart), new Vec3(xstart, y, zstart), MAJOR_LINES, 4.0F);
        }
    }
}

引用的其他类

  • Minecraft

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

    • 引用位置: 参数
  • DebugRenderer

    • 引用位置: 实现
  • SectionPos

    • 引用位置: 方法调用
    • 关联成员: SectionPos.of()
  • GizmoStyle

    • 引用位置: 方法调用
    • 关联成员: GizmoStyle.stroke()
  • Gizmos

    • 引用位置: 方法调用
    • 关联成员: Gizmos.cuboid(), Gizmos.line()
  • ARGB

    • 引用位置: 方法调用
    • 关联成员: ARGB.color(), ARGB.colorFromFloat()
  • DebugValueAccess

    • 引用位置: 参数
  • AABB

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

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