package net.minecraft.client.renderer.debug;

import net.minecraft.client.Camera;
import net.minecraft.core.Vec3i;
import net.minecraft.core.BlockPos;
import com.mojang.blaze3d.systems.RenderSystem;
import net.minecraft.client.renderer.MultiBufferSource;
import com.mojang.blaze3d.vertex.PoseStack;
import com.google.common.collect.Maps;
import java.util.List;
import java.util.Map;
import net.minecraft.client.Minecraft;

public class GoalSelectorDebugRenderer implements DebugRenderer.SimpleDebugRenderer {
    private final Minecraft minecraft;
    private final Map<Integer, List<DebugGoal>> goalSelectors;
    
    @Override
    public void clear() {
        this.goalSelectors.clear();
    }
    
    public void addGoalSelector(final int integer, final List<DebugGoal> list) {
        this.goalSelectors.put(integer, list);
    }
    
    public GoalSelectorDebugRenderer(final Minecraft dlx) {
        this.goalSelectors = Maps.newHashMap();
        this.minecraft = dlx;
    }
    
    @Override
    public void render(final PoseStack dhl, final MultiBufferSource ebz, final double double3, final double double4, final double double5) {
        final Camera dlj10 = this.minecraft.gameRenderer.getMainCamera();
        RenderSystem.pushMatrix();
        RenderSystem.enableBlend();
        RenderSystem.defaultBlendFunc();
        RenderSystem.disableTexture();
        final BlockPos fu11 = new BlockPos(dlj10.getPosition().x, 0.0, dlj10.getPosition().z);
        int integer4;
        DebugGoal a5;
        final Vec3i vec3i;
        double double6;
        double double7;
        double double8;
        int integer5;
        this.goalSelectors.forEach((integer, list) -> {
            for (integer4 = 0; integer4 < list.size(); ++integer4) {
                a5 = list.get(integer4);
                if (vec3i.closerThan(a5.pos, 160.0)) {
                    double6 = a5.pos.getX() + 0.5;
                    double7 = a5.pos.getY() + 2.0 + integer4 * 0.25;
                    double8 = a5.pos.getZ() + 0.5;
                    integer5 = (a5.isRunning ? -16711936 : -3355444);
                    DebugRenderer.renderFloatingText(a5.name, double6, double7, double8, integer5);
                }
            }
            return;
        });
        RenderSystem.enableDepthTest();
        RenderSystem.enableTexture();
        RenderSystem.popMatrix();
    }
    
    public static class DebugGoal {
        public final BlockPos pos;
        public final int priority;
        public final String name;
        public final boolean isRunning;
        
        public DebugGoal(final BlockPos fu, final int integer, final String string, final boolean boolean4) {
            this.pos = fu;
            this.priority = integer;
            this.name = string;
            this.isRunning = boolean4;
        }
    }
}
