package net.minecraft.client.renderer.debug;

import java.util.Iterator;
import com.mojang.blaze3d.vertex.VertexConsumer;
import net.minecraft.client.renderer.LevelRenderer;
import net.minecraft.client.renderer.RenderType;
import java.util.stream.Collector;
import java.util.stream.Collectors;
import net.minecraft.world.entity.Entity;
import net.minecraft.Util;
import net.minecraft.client.renderer.MultiBufferSource;
import com.mojang.blaze3d.vertex.PoseStack;
import java.util.Collections;
import net.minecraft.world.phys.shapes.VoxelShape;
import java.util.List;
import net.minecraft.client.Minecraft;

public class CollisionBoxRenderer implements DebugRenderer.SimpleDebugRenderer {
    private final Minecraft minecraft;
    private double lastUpdateTime;
    private List<VoxelShape> shapes;
    
    public CollisionBoxRenderer(final Minecraft dbn) {
        this.lastUpdateTime = Double.MIN_VALUE;
        this.shapes = Collections.<VoxelShape>emptyList();
        this.minecraft = dbn;
    }
    
    @Override
    public void render(final PoseStack cyl, final MultiBufferSource dqt, final double double3, final double double4, final double double5) {
        final double double6 = (double)Util.getNanos();
        if (double6 - this.lastUpdateTime > 1.0E8) {
            this.lastUpdateTime = double6;
            final Entity akq12 = this.minecraft.gameRenderer.getMainCamera().getEntity();
            this.shapes = akq12.level.getCollisions(akq12, akq12.getBoundingBox().inflate(6.0), Collections.<Entity>emptySet()).collect(Collectors.toList());
        }
        final VertexConsumer cyo12 = dqt.getBuffer(RenderType.lines());
        for (final VoxelShape cwf14 : this.shapes) {
            LevelRenderer.renderVoxelShape(cyl, cyo12, cwf14, -double3, -double4, -double5, 1.0f, 1.0f, 1.0f, 1.0f);
        }
    }
}
