/*
 * 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_243
 */
package meteordevelopment.meteorclient.systems.modules.donut;

import meteordevelopment.meteorclient.events.render.Render3DEvent;
import meteordevelopment.meteorclient.renderer.ShapeMode;
import meteordevelopment.meteorclient.settings.BoolSetting;
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.orbit.EventHandler;
import net.minecraft.class_1297;
import net.minecraft.class_1657;
import net.minecraft.class_243;

public class DonutPlayerEsp
extends Module {
    private final SettingGroup sgGeneral;
    private final Setting<Integer> alpha;
    private final Setting<Integer> range;
    private final Setting<Boolean> tracers;

    public DonutPlayerEsp() {
        super(Categories.Donut, "Player esp", "Renders players through walls.");
        this.sgGeneral = this.settings.getDefaultGroup();
        this.alpha = this.sgGeneral.add(((IntSetting.Builder)((IntSetting.Builder)((IntSetting.Builder)new IntSetting.Builder().name("alpha")).description("ESP alpha.")).defaultValue(100)).range(0, 255).sliderRange(0, 255).build());
        this.range = this.sgGeneral.add(((IntSetting.Builder)((IntSetting.Builder)((IntSetting.Builder)new IntSetting.Builder().name("range")).description("Maximum render distance for players.")).defaultValue(256)).range(32, 512).sliderRange(32, 512).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 onRender3D(Render3DEvent event) {
        if (this.mc.field_1687 == null || this.mc.field_1724 == null) {
            return;
        }
        double maxRangeSq = (double)this.range.get().intValue() * (double)this.range.get().intValue();
        Color side = new Color(147, 0, 211, this.alpha.get());
        Color line = new Color(147, 0, 211, 255);
        for (class_1657 player : this.mc.field_1687.method_18456()) {
            if (player == this.mc.field_1724 || player.method_5858((class_1297)this.mc.field_1724) > maxRangeSq) continue;
            class_243 p = player.method_30950(event.tickDelta);
            double x = p.field_1352;
            double y = p.field_1351;
            double z = p.field_1350;
            event.renderer.box(x - 0.3, y, z - 0.3, x + 0.3, y + 2.0, z + 0.3, side, line, ShapeMode.Both, 0);
            if (!this.tracers.get().booleanValue()) continue;
            event.renderer.line(RenderUtils.center.field_1352, RenderUtils.center.field_1351, RenderUtils.center.field_1350, x, y + 1.0, z, line);
        }
    }
}

