GoalSelectorDebugRenderer .java

net.minecraft.client.renderer.debug.GoalSelectorDebugRenderer (class, 45 lines): members: MAX_RENDER_DIST, frustum, emitGizmos, minecraft. imports: Gizmos.

net.minecraft.client.renderer.debugclass45 linesclient1.7 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 (3)

MAX_RENDER_DIST
minecraft
frustum

Full Source

GoalSelectorDebugRenderer.java45 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.Camera;
6
import net.minecraft.client.Minecraft;
7
import net.minecraft.client.renderer.culling.Frustum;
8
import net.minecraft.core.BlockPos;
9
import net.minecraft.gizmos.Gizmos;
10
import net.minecraft.gizmos.TextGizmo.Style;
11
import net.minecraft.util.debug.DebugSubscriptions;
12
import net.minecraft.util.debug.DebugValueAccess;
13
import net.minecraft.util.debug.DebugGoalInfo.DebugGoal;
14
import net.minecraft.world.phys.Vec3;
15
16
@Environment(EnvType.CLIENT)
17
public class GoalSelectorDebugRenderer implements DebugRenderer.SimpleDebugRenderer {
18
	private static final int MAX_RENDER_DIST = 160;
19
	private final Minecraft minecraft;
20
21
	public GoalSelectorDebugRenderer(final Minecraft minecraft) {
22
		this.minecraft = minecraft;
23
	}
24
25
	@Override
26
	public void emitGizmos(
27
		final double camX, final double camY, final double camZ, final DebugValueAccess debugValues, final Frustum frustum, final float partialTicks
28
	) {
29
		Camera camera = this.minecraft.gameRenderer.mainCamera();
30
		BlockPos playerPos = BlockPos.containing(camera.position().x, 0.0, camera.position().z);
31
		debugValues.forEachEntity(DebugSubscriptions.GOAL_SELECTORS, (entity, goalInfo) -> {
32
			if (playerPos.closerThan(entity.blockPosition(), 160.0)) {
33
				for (int i = 0; i < goalInfo.goals().size(); i++) {
34
					DebugGoal goal = goalInfo.goals().get(i);
35
					double x = entity.getBlockX() + 0.5;
36
					double y = entity.getY() + 2.0 + i * 0.25;
37
					double z = entity.getBlockZ() + 0.5;
38
					int color = goal.isRunning() ? -16711936 : -3355444;
39
					Gizmos.billboardText(goal.name(), new Vec3(x, y, z), Style.forColorAndCentered(color));
40
				}
41
			}
42
		});
43
	}
44
}
45

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