ChunkBorderRenderer .java

net.minecraft.client.renderer.debug.ChunkBorderRenderer (class): members: CELL_BORDER, MAJOR_LINES, THICK_WIDTH, THIN_WIDTH, YELLOW, frustum, emitGizmos.

net.minecraft.client.renderer.debugclass89 linesclient3.9 KB

Implements

API Surface (1)

void emitGizmos(final double camX, final double camY, final double camZ, final DebugValueAccess debugValues, final Frustum frustum, final float partialTicks)

Fields & Constants (7)

THICK_WIDTH
THIN_WIDTH
CELL_BORDER
YELLOW
MAJOR_LINES
minecraft
frustum

Full Source

ChunkBorderRenderer.java89 lines · Minecraft 26.3 · verbatim
1
package net.minecraft.client.renderer.debug;
2
3
import net.fabricmc.api.EnvType;
4
import net.fabricmc.api.Environment;
5
import net.minecraft.client.Minecraft;
6
import net.minecraft.client.renderer.culling.Frustum;
7
import net.minecraft.core.SectionPos;
8
import net.minecraft.gizmos.GizmoStyle;
9
import net.minecraft.gizmos.Gizmos;
10
import net.minecraft.util.ARGB;
11
import net.minecraft.util.debug.DebugValueAccess;
12
import net.minecraft.world.entity.Entity;
13
import net.minecraft.world.phys.AABB;
14
import net.minecraft.world.phys.Vec3;
15
16
@Environment(EnvType.CLIENT)
17
public class ChunkBorderRenderer implements DebugRenderer.SimpleDebugRenderer {
18
	private static final float THICK_WIDTH = 4.0F;
19
	private static final float THIN_WIDTH = 1.0F;
20
	private final Minecraft minecraft;
21
	private static final int CELL_BORDER = ARGB.color(255, 0, 155, 155);
22
	private static final int YELLOW = ARGB.color(255, 255, 255, 0);
23
	private static final int MAJOR_LINES = ARGB.colorFromFloat(1.0F, 0.25F, 0.25F, 1.0F);
24
25
	public ChunkBorderRenderer(final Minecraft minecraft) {
26
		this.minecraft = minecraft;
27
	}
28
29
	@Override
30
	public void emitGizmos(
31
		final double camX, final double camY, final double camZ, final DebugValueAccess debugValues, final Frustum frustum, final float partialTicks
32
	) {
33
		Entity cameraEntity = this.minecraft.getCameraEntity();
34
		float ymin = this.minecraft.level.getMinY();
35
		float ymax = this.minecraft.level.getMaxY() + 1;
36
		SectionPos cameraPos = SectionPos.of(cameraEntity.blockPosition());
37
		double xstart = cameraPos.minBlockX();
38
		double zstart = cameraPos.minBlockZ();
39
40
		for (int x = -16; x <= 32; x += 16) {
41
			for (int z = -16; z <= 32; z += 16) {
42
				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);
43
			}
44
		}
45
46
		for (int x = 2; x < 16; x += 2) {
47
			int color = x % 4 == 0 ? CELL_BORDER : YELLOW;
48
			Gizmos.line(new Vec3(xstart + x, ymin, zstart), new Vec3(xstart + x, ymax, zstart), color, 1.0F);
49
			Gizmos.line(new Vec3(xstart + x, ymin, zstart + 16.0), new Vec3(xstart + x, ymax, zstart + 16.0), color, 1.0F);
50
		}
51
52
		for (int z = 2; z < 16; z += 2) {
53
			int color = z % 4 == 0 ? CELL_BORDER : YELLOW;
54
			Gizmos.line(new Vec3(xstart, ymin, zstart + z), new Vec3(xstart, ymax, zstart + z), color, 1.0F);
55
			Gizmos.line(new Vec3(xstart + 16.0, ymin, zstart + z), new Vec3(xstart + 16.0, ymax, zstart + z), color, 1.0F);
56
		}
57
58
		for (int y = this.minecraft.level.getMinY(); y <= this.minecraft.level.getMaxY() + 1; y += 2) {
59
			float yline = y;
60
			int color = y % 8 == 0 ? CELL_BORDER : YELLOW;
61
			Gizmos.line(new Vec3(xstart, yline, zstart), new Vec3(xstart, yline, zstart + 16.0), color, 1.0F);
62
			Gizmos.line(new Vec3(xstart, yline, zstart + 16.0), new Vec3(xstart + 16.0, yline, zstart + 16.0), color, 1.0F);
63
			Gizmos.line(new Vec3(xstart + 16.0, yline, zstart + 16.0), new Vec3(xstart + 16.0, yline, zstart), color, 1.0F);
64
			Gizmos.line(new Vec3(xstart + 16.0, yline, zstart), new Vec3(xstart, yline, zstart), color, 1.0F);
65
		}
66
67
		for (int x = 0; x <= 16; x += 16) {
68
			for (int z = 0; z <= 16; z += 16) {
69
				Gizmos.line(new Vec3(xstart + x, ymin, zstart + z), new Vec3(xstart + x, ymax, zstart + z), MAJOR_LINES, 4.0F);
70
			}
71
		}
72
73
		Gizmos.cuboid(
74
				new AABB(
75
					cameraPos.minBlockX(), cameraPos.minBlockY(), cameraPos.minBlockZ(), cameraPos.maxBlockX() + 1, cameraPos.maxBlockY() + 1, cameraPos.maxBlockZ() + 1
76
				),
77
				GizmoStyle.stroke(MAJOR_LINES, 1.0F)
78
			)
79
			.setAlwaysOnTop();
80
81
		for (int y = this.minecraft.level.getMinY(); y <= this.minecraft.level.getMaxY() + 1; y += 16) {
82
			Gizmos.line(new Vec3(xstart, y, zstart), new Vec3(xstart, y, zstart + 16.0), MAJOR_LINES, 4.0F);
83
			Gizmos.line(new Vec3(xstart, y, zstart + 16.0), new Vec3(xstart + 16.0, y, zstart + 16.0), MAJOR_LINES, 4.0F);
84
			Gizmos.line(new Vec3(xstart + 16.0, y, zstart + 16.0), new Vec3(xstart + 16.0, y, zstart), MAJOR_LINES, 4.0F);
85
			Gizmos.line(new Vec3(xstart + 16.0, y, zstart), new Vec3(xstart, y, zstart), MAJOR_LINES, 4.0F);
86
		}
87
	}
88
}
89

Decompiled Minecraft 26.3 source of ChunkBorderRenderer (net/minecraft/client/renderer/debug/ChunkBorderRenderer.java) with Mojang official mappings, stored verbatim on the site.