2025-11-24 22:52:51 +03:00

50 lines
1.8 KiB
Java

/*
* Decompiled with CFR 0.152.
*
* Could not load the following classes:
* com.google.common.collect.ImmutableList
*/
package net.minecraft.client.renderer.debug;
import com.google.common.collect.ImmutableList;
import java.util.Collections;
import java.util.List;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.culling.Frustum;
import net.minecraft.client.renderer.debug.DebugRenderer;
import net.minecraft.gizmos.GizmoStyle;
import net.minecraft.gizmos.Gizmos;
import net.minecraft.util.Util;
import net.minecraft.util.debug.DebugValueAccess;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.phys.AABB;
import net.minecraft.world.phys.shapes.VoxelShape;
public class CollisionBoxRenderer
implements DebugRenderer.SimpleDebugRenderer {
private final Minecraft minecraft;
private double lastUpdateTime = Double.MIN_VALUE;
private List<VoxelShape> shapes = Collections.emptyList();
public CollisionBoxRenderer(Minecraft minecraft) {
this.minecraft = minecraft;
}
@Override
public void emitGizmos(double camX, double camY, double camZ, DebugValueAccess debugValues, Frustum frustum, float partialTicks) {
double time = Util.getNanos();
if (time - this.lastUpdateTime > 1.0E8) {
this.lastUpdateTime = time;
Entity cameraEntity = this.minecraft.gameRenderer.getMainCamera().entity();
this.shapes = ImmutableList.copyOf(cameraEntity.level().getCollisions(cameraEntity, cameraEntity.getBoundingBox().inflate(6.0)));
}
for (VoxelShape shape : this.shapes) {
GizmoStyle style = GizmoStyle.stroke(-1);
for (AABB aabb : shape.toAabbs()) {
Gizmos.cuboid(aabb, style);
}
}
}
}