/*
 * Decompiled with CFR 0.152.
 * 
 * Could not load the following classes:
 *  meteordevelopment.orbit.EventHandler
 *  net.minecraft.class_1297
 *  net.minecraft.class_1657
 *  net.minecraft.class_3532
 */
package meteordevelopment.meteorclient.systems.modules.render;

import meteordevelopment.meteorclient.events.render.Render3DEvent;
import meteordevelopment.meteorclient.renderer.ShapeMode;
import meteordevelopment.meteorclient.settings.BoolSetting;
import meteordevelopment.meteorclient.settings.ColorSetting;
import meteordevelopment.meteorclient.settings.DoubleSetting;
import meteordevelopment.meteorclient.settings.IntSetting;
import meteordevelopment.meteorclient.settings.Setting;
import meteordevelopment.meteorclient.settings.SettingGroup;
import meteordevelopment.meteorclient.systems.modules.Categories;
import meteordevelopment.meteorclient.systems.modules.Module;
import meteordevelopment.meteorclient.utils.render.RenderUtils;
import meteordevelopment.meteorclient.utils.render.color.Color;
import meteordevelopment.meteorclient.utils.render.color.SettingColor;
import meteordevelopment.orbit.EventHandler;
import net.minecraft.class_1297;
import net.minecraft.class_1657;
import net.minecraft.class_3532;

public class PlayerESP
extends Module {
    private final SettingGroup sgGeneral;
    private final Setting<SettingColor> color;
    private final Setting<Integer> alpha;
    private final Setting<Double> range;
    private final Setting<Boolean> tracers;

    public PlayerESP() {
        super(Categories.Render, "player-esp", "Renders players through walls.");
        this.sgGeneral = this.settings.getDefaultGroup();
        this.color = this.sgGeneral.add(((ColorSetting.Builder)((ColorSetting.Builder)new ColorSetting.Builder().name("color")).description("The color of the player boxes.")).defaultValue(new SettingColor(0, 124, 249)).build());
        this.alpha = this.sgGeneral.add(((IntSetting.Builder)((IntSetting.Builder)((IntSetting.Builder)new IntSetting.Builder().name("alpha")).description("The alpha of the boxes.")).defaultValue(100)).min(0).max(255).build());
        this.range = this.sgGeneral.add(((DoubleSetting.Builder)((DoubleSetting.Builder)new DoubleSetting.Builder().name("range")).description("Maximum render distance for players.")).defaultValue(256.0).min(32.0).max(512.0).sliderMax(512.0).build());
        this.tracers = this.sgGeneral.add(((BoolSetting.Builder)((BoolSetting.Builder)((BoolSetting.Builder)new BoolSetting.Builder().name("tracers")).description("Draws a line from your player to the other.")).defaultValue(false)).build());
    }

    @EventHandler
    private void onRender(Render3DEvent event) {
        if (this.mc.field_1687 == null || this.mc.field_1724 == null) {
            return;
        }
        double maxRangeSq = this.range.get() * this.range.get();
        for (class_1657 player : this.mc.field_1687.method_18456()) {
            if (player == this.mc.field_1724 || this.mc.field_1724.method_5858((class_1297)player) > maxRangeSq) continue;
            double x = class_3532.method_16436((double)event.tickDelta, (double)player.field_6014, (double)player.method_23317());
            double y = class_3532.method_16436((double)event.tickDelta, (double)player.field_6036, (double)player.method_23318());
            double z = class_3532.method_16436((double)event.tickDelta, (double)player.field_5969, (double)player.method_23321());
            Color c = this.color.get();
            Color boxColor = new Color(c.r, c.g, c.b, this.alpha.get());
            event.renderer.box(x - 0.3, y, z - 0.3, x + 0.3, y + 2.0, z + 0.3, boxColor, null, ShapeMode.Both, 0);
            if (!this.tracers.get().booleanValue()) continue;
            Color tracerColor = new Color(c.r, c.g, c.b, 255);
            event.renderer.line(RenderUtils.center.field_1352, RenderUtils.center.field_1351, RenderUtils.center.field_1350, x, y + 1.0, z, tracerColor);
        }
    }
}

