LightSectionDebugRenderer.java
net.minecraft.client.renderer.debug.LightSectionDebugRenderer
信息
- 全限定名:net.minecraft.client.renderer.debug.LightSectionDebugRenderer
- 类型:public class
- 包:net.minecraft.client.renderer.debug
- 源码路径:src/main/java/net/minecraft/client/renderer/debug/LightSectionDebugRenderer.java
- 起始行号:L24
- 实现:DebugRenderer.SimpleDebugRenderer
- 职责:
TODO
字段/常量
-
REFRESH_INTERVAL- 类型:
Duration - 修饰符:
private static final - 源码定位:
L25 - 说明:
TODO
- 类型:
-
RADIUS- 类型:
int - 修饰符:
private static final - 源码定位:
L26 - 说明:
TODO
- 类型:
-
LIGHT_AND_BLOCKS_COLOR- 类型:
int - 修饰符:
private static final - 源码定位:
L27 - 说明:
TODO
- 类型:
-
LIGHT_ONLY_COLOR- 类型:
int - 修饰符:
private static final - 源码定位:
L28 - 说明:
TODO
- 类型:
-
minecraft- 类型:
Minecraft - 修饰符:
private final - 源码定位:
L29 - 说明:
TODO
- 类型:
-
lightLayer- 类型:
LightLayer - 修饰符:
private final - 源码定位:
L30 - 说明:
TODO
- 类型:
-
lastUpdateTime- 类型:
Instant - 修饰符:
private - 源码定位:
L31 - 说明:
TODO
- 类型:
-
data- 类型:
LightSectionDebugRenderer.SectionData - 修饰符:
private - 源码定位:
L32 - 说明:
TODO
- 类型:
内部类/嵌套类型
net.minecraft.client.renderer.debug.LightSectionDebugRenderer.SectionData- 类型:
class - 修饰符:
private static final - 源码定位:
L96 - 说明:
TODO
- 类型:
构造器
public LightSectionDebugRenderer(Minecraft minecraft, LightLayer lightLayer) @ L34
- 构造器名:LightSectionDebugRenderer
- 源码定位:L34
- 修饰符:public
参数:
- minecraft: Minecraft
- lightLayer: LightLayer
说明:
TODO
方法
下面的方法块按源码顺序生成。
public void emitGizmos(double camX, double camY, double camZ, DebugValueAccess debugValues, Frustum frustum, float partialTicks) @ L39
- 方法名:emitGizmos
- 源码定位:L39
- 返回类型:void
- 修饰符:public
参数:
- camX: double
- camY: double
- camZ: double
- debugValues: DebugValueAccess
- frustum: Frustum
- partialTicks: float
说明:
TODO
private static void renderFaces(DiscreteVoxelShape shape, SectionPos minSection, int color) @ L55
- 方法名:renderFaces
- 源码定位:L55
- 返回类型:void
- 修饰符:private static
参数:
- shape: DiscreteVoxelShape
- minSection: SectionPos
- color: int
说明:
TODO
private static void renderEdges(DiscreteVoxelShape shape, SectionPos minSection, int color) @ L64
- 方法名:renderEdges
- 源码定位:L64
- 返回类型:void
- 修饰符:private static
参数:
- shape: DiscreteVoxelShape
- minSection: SectionPos
- color: int
说明:
TODO
private static void renderFace(Direction direction, int sectionX, int sectionY, int sectionZ, int color) @ L76
- 方法名:renderFace
- 源码定位:L76
- 返回类型:void
- 修饰符:private static
参数:
- direction: Direction
- sectionX: int
- sectionY: int
- sectionZ: int
- color: int
说明:
TODO
private static void renderEdge(int sectionX0, int sectionY0, int sectionZ0, int sectionX1, int sectionY1, int sectionZ1, int color) @ L84
- 方法名:renderEdge
- 源码定位:L84
- 返回类型:void
- 修饰符:private static
参数:
- sectionX0: int
- sectionY0: int
- sectionZ0: int
- sectionX1: int
- sectionY1: int
- sectionZ1: int
- color: int
说明:
TODO
代码
@OnlyIn(Dist.CLIENT)
public class LightSectionDebugRenderer implements DebugRenderer.SimpleDebugRenderer {
private static final Duration REFRESH_INTERVAL = Duration.ofMillis(500L);
private static final int RADIUS = 10;
private static final int LIGHT_AND_BLOCKS_COLOR = ARGB.colorFromFloat(0.25F, 1.0F, 1.0F, 0.0F);
private static final int LIGHT_ONLY_COLOR = ARGB.colorFromFloat(0.125F, 0.25F, 0.125F, 0.0F);
private final Minecraft minecraft;
private final LightLayer lightLayer;
private Instant lastUpdateTime = Instant.now();
private LightSectionDebugRenderer.@Nullable SectionData data;
public LightSectionDebugRenderer(Minecraft minecraft, LightLayer lightLayer) {
this.minecraft = minecraft;
this.lightLayer = lightLayer;
}
@Override
public void emitGizmos(double camX, double camY, double camZ, DebugValueAccess debugValues, Frustum frustum, float partialTicks) {
Instant time = Instant.now();
if (this.data == null || Duration.between(this.lastUpdateTime, time).compareTo(REFRESH_INTERVAL) > 0) {
this.lastUpdateTime = time;
this.data = new LightSectionDebugRenderer.SectionData(
this.minecraft.level.getLightEngine(), SectionPos.of(this.minecraft.player.blockPosition()), 10, this.lightLayer
);
}
renderEdges(this.data.lightAndBlocksShape, this.data.minPos, LIGHT_AND_BLOCKS_COLOR);
renderEdges(this.data.lightShape, this.data.minPos, LIGHT_ONLY_COLOR);
renderFaces(this.data.lightAndBlocksShape, this.data.minPos, LIGHT_AND_BLOCKS_COLOR);
renderFaces(this.data.lightShape, this.data.minPos, LIGHT_ONLY_COLOR);
}
private static void renderFaces(DiscreteVoxelShape shape, SectionPos minSection, int color) {
shape.forAllFaces((direction, x, y, z) -> {
int sectionX = x + minSection.getX();
int sectionY = y + minSection.getY();
int sectionZ = z + minSection.getZ();
renderFace(direction, sectionX, sectionY, sectionZ, color);
});
}
private static void renderEdges(DiscreteVoxelShape shape, SectionPos minSection, int color) {
shape.forAllEdges((x0, y0, z0, x1, y1, z1) -> {
int sectionX0 = x0 + minSection.getX();
int sectionY0 = y0 + minSection.getY();
int sectionZ0 = z0 + minSection.getZ();
int sectionX1 = x1 + minSection.getX();
int sectionY1 = y1 + minSection.getY();
int sectionZ1 = z1 + minSection.getZ();
renderEdge(sectionX0, sectionY0, sectionZ0, sectionX1, sectionY1, sectionZ1, color);
}, true);
}
private static void renderFace(Direction direction, int sectionX, int sectionY, int sectionZ, int color) {
Vec3 cuboidCornerA = new Vec3(
SectionPos.sectionToBlockCoord(sectionX), SectionPos.sectionToBlockCoord(sectionY), SectionPos.sectionToBlockCoord(sectionZ)
);
Vec3 cuboidCornerB = cuboidCornerA.add(16.0, 16.0, 16.0);
Gizmos.rect(cuboidCornerA, cuboidCornerB, direction, GizmoStyle.fill(color));
}
private static void renderEdge(int sectionX0, int sectionY0, int sectionZ0, int sectionX1, int sectionY1, int sectionZ1, int color) {
double x0 = SectionPos.sectionToBlockCoord(sectionX0);
double y0 = SectionPos.sectionToBlockCoord(sectionY0);
double z0 = SectionPos.sectionToBlockCoord(sectionZ0);
double x1 = SectionPos.sectionToBlockCoord(sectionX1);
double y1 = SectionPos.sectionToBlockCoord(sectionY1);
double z1 = SectionPos.sectionToBlockCoord(sectionZ1);
int opaqueColor = ARGB.opaque(color);
Gizmos.line(new Vec3(x0, y0, z0), new Vec3(x1, y1, z1), opaqueColor);
}
@OnlyIn(Dist.CLIENT)
private static final class SectionData {
private final DiscreteVoxelShape lightAndBlocksShape;
private final DiscreteVoxelShape lightShape;
private final SectionPos minPos;
private SectionData(LevelLightEngine engine, SectionPos centerPos, int radius, LightLayer lightLayer) {
int size = radius * 2 + 1;
this.lightAndBlocksShape = new BitSetDiscreteVoxelShape(size, size, size);
this.lightShape = new BitSetDiscreteVoxelShape(size, size, size);
for (int z = 0; z < size; z++) {
for (int y = 0; y < size; y++) {
for (int x = 0; x < size; x++) {
SectionPos pos = SectionPos.of(centerPos.x() + x - radius, centerPos.y() + y - radius, centerPos.z() + z - radius);
LayerLightSectionStorage.SectionType type = engine.getDebugSectionType(lightLayer, pos);
if (type == LayerLightSectionStorage.SectionType.LIGHT_AND_DATA) {
this.lightAndBlocksShape.fill(x, y, z);
this.lightShape.fill(x, y, z);
} else if (type == LayerLightSectionStorage.SectionType.LIGHT_ONLY) {
this.lightShape.fill(x, y, z);
}
}
}
}
this.minPos = SectionPos.of(centerPos.x() - radius, centerPos.y() - radius, centerPos.z() - radius);
}
}
}引用的其他类
-
- 引用位置:
参数/字段
- 引用位置:
-
- 引用位置:
参数
- 引用位置:
-
- 引用位置:
实现
- 引用位置:
-
- 引用位置:
参数
- 引用位置:
-
- 引用位置:
参数/方法调用 - 关联成员:
SectionPos.of(), SectionPos.sectionToBlockCoord()
- 引用位置:
-
- 引用位置:
方法调用 - 关联成员:
GizmoStyle.fill()
- 引用位置:
-
- 引用位置:
方法调用 - 关联成员:
Gizmos.line(), Gizmos.rect()
- 引用位置:
-
- 引用位置:
方法调用 - 关联成员:
ARGB.colorFromFloat(), ARGB.opaque()
- 引用位置:
-
- 引用位置:
参数
- 引用位置:
-
- 引用位置:
参数/字段
- 引用位置:
-
- 引用位置:
构造调用 - 关联成员:
Vec3()
- 引用位置:
-
- 引用位置:
构造调用 - 关联成员:
BitSetDiscreteVoxelShape()
- 引用位置:
-
- 引用位置:
参数
- 引用位置: