| 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.multiplayer.ClientLevel;
|
| 7 | import net.minecraft.client.renderer.culling.Frustum;
|
| 8 | import net.minecraft.gizmos.GizmoStyle;
|
| 9 | import net.minecraft.gizmos.Gizmos;
|
| 10 | import net.minecraft.util.ARGB;
|
| 11 | import net.minecraft.util.debug.DebugSubscriptions;
|
| 12 | import net.minecraft.util.debug.DebugValueAccess;
|
| 13 | import net.minecraft.world.phys.AABB;
|
| 14 | import net.minecraft.world.phys.Vec3;
|
| 15 |
|
| 16 | @Environment(EnvType.CLIENT)
|
| 17 | public class BreezeDebugRenderer implements DebugRenderer.SimpleDebugRenderer {
|
| 18 | private static final int JUMP_TARGET_LINE_COLOR = ARGB.color(255, 255, 100, 255);
|
| 19 | private static final int TARGET_LINE_COLOR = ARGB.color(255, 100, 255, 255);
|
| 20 | private static final int INNER_CIRCLE_COLOR = ARGB.color(255, 0, 255, 0);
|
| 21 | private static final int MIDDLE_CIRCLE_COLOR = ARGB.color(255, 255, 165, 0);
|
| 22 | private static final int OUTER_CIRCLE_COLOR = ARGB.color(255, 255, 0, 0);
|
| 23 | private final Minecraft minecraft;
|
| 24 |
|
| 25 | public BreezeDebugRenderer(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 | ClientLevel level = this.minecraft.level;
|
| 34 | debugValues.forEachEntity(
|
| 35 | DebugSubscriptions.BREEZES,
|
| 36 | (entity, info) -> {
|
| 37 | info.attackTarget()
|
| 38 | .map(level::getEntity)
|
| 39 | .map(targetEntity -> targetEntity.getPosition(this.minecraft.getDeltaTracker().getGameTimeDeltaPartialTick(true)))
|
| 40 | .ifPresent(attackTargetPosition -> {
|
| 41 | Gizmos.arrow(entity.position(), attackTargetPosition, TARGET_LINE_COLOR);
|
| 42 | Vec3 drawCenter = attackTargetPosition.add(0.0, 0.01F, 0.0);
|
| 43 | Gizmos.circle(drawCenter, 4.0F, GizmoStyle.stroke(INNER_CIRCLE_COLOR));
|
| 44 | Gizmos.circle(drawCenter, 8.0F, GizmoStyle.stroke(MIDDLE_CIRCLE_COLOR));
|
| 45 | Gizmos.circle(drawCenter, 24.0F, GizmoStyle.stroke(OUTER_CIRCLE_COLOR));
|
| 46 | });
|
| 47 | info.jumpTarget().ifPresent(blockPos -> {
|
| 48 | Gizmos.arrow(entity.position(), Vec3.atCenterOf(blockPos), JUMP_TARGET_LINE_COLOR);
|
| 49 | Gizmos.cuboid(AABB.unitCubeFromLowerCorner(Vec3.atLowerCornerOf(blockPos)), GizmoStyle.fill(ARGB.colorFromFloat(1.0F, 1.0F, 0.0F, 0.0F)));
|
| 50 | });
|
| 51 | }
|
| 52 | );
|
| 53 | }
|
| 54 | }
|
| 55 |
|