package net.minecraft.client.renderer.debug;

import java.util.Iterator;
import com.mojang.blaze3d.vertex.VertexConsumer;
import net.minecraft.world.entity.Entity;
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.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 dlx) {
        this.lastUpdateTime = Double.MIN_VALUE;
        this.shapes = Collections.<VoxelShape>emptyList();
        this.minecraft = dlx;
    }
    
    @Override
    public void render(final PoseStack dhl, final MultiBufferSource ebz, 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 aom12 = this.minecraft.gameRenderer.getMainCamera().getEntity();
            this.shapes = aom12.level.getCollisions(aom12, aom12.getBoundingBox().inflate(6.0), aom -> true).collect(Collectors.toList());
        }
        final VertexConsumer dhp12 = ebz.getBuffer(RenderType.lines());
        for (final VoxelShape dfg14 : this.shapes) {
            LevelRenderer.renderVoxelShape(dhl, dhp12, dfg14, -double3, -double4, -double5, 1.0f, 1.0f, 1.0f, 1.0f);
        }
    }
}
