/*
 * Decompiled with CFR 0.152.
 * 
 * Could not load the following classes:
 *  meteordevelopment.orbit.EventHandler
 *  net.minecraft.class_1268
 *  net.minecraft.class_1269
 *  net.minecraft.class_1297
 *  net.minecraft.class_1657
 *  net.minecraft.class_1747
 *  net.minecraft.class_1839
 *  net.minecraft.class_1922
 *  net.minecraft.class_1937
 *  net.minecraft.class_2338
 *  net.minecraft.class_2350
 *  net.minecraft.class_2350$class_2351
 *  net.minecraft.class_239$class_240
 *  net.minecraft.class_243
 *  net.minecraft.class_2596
 *  net.minecraft.class_265
 *  net.minecraft.class_2680
 *  net.minecraft.class_2828$class_2829
 *  net.minecraft.class_2828$class_5911
 *  net.minecraft.class_3959
 *  net.minecraft.class_3959$class_242
 *  net.minecraft.class_3959$class_3960
 *  net.minecraft.class_3965
 *  net.minecraft.class_3966
 *  net.minecraft.class_4184
 */
package meteordevelopment.meteorclient.systems.modules.movement;

import meteordevelopment.meteorclient.events.world.TickEvent;
import meteordevelopment.meteorclient.systems.modules.Categories;
import meteordevelopment.meteorclient.systems.modules.Module;
import meteordevelopment.orbit.EventHandler;
import net.minecraft.class_1268;
import net.minecraft.class_1269;
import net.minecraft.class_1297;
import net.minecraft.class_1657;
import net.minecraft.class_1747;
import net.minecraft.class_1839;
import net.minecraft.class_1922;
import net.minecraft.class_1937;
import net.minecraft.class_2338;
import net.minecraft.class_2350;
import net.minecraft.class_239;
import net.minecraft.class_243;
import net.minecraft.class_2596;
import net.minecraft.class_265;
import net.minecraft.class_2680;
import net.minecraft.class_2828;
import net.minecraft.class_3959;
import net.minecraft.class_3965;
import net.minecraft.class_3966;
import net.minecraft.class_4184;

public class ClickTP
extends Module {
    public ClickTP() {
        super(Categories.Movement, "click-tp", "Teleports you to the block you click on.");
    }

    @EventHandler
    private void onTick(TickEvent.Post event) {
        class_243 direction;
        class_243 targetPos;
        class_4184 camera;
        class_243 cameraPos;
        class_3959 context;
        class_3965 hitResult;
        if (this.mc.field_1724.method_31548().method_7391().method_7976() != class_1839.field_8952) {
            return;
        }
        if (!this.mc.field_1690.field_1904.method_1434()) {
            return;
        }
        if (this.mc.field_1765 != null) {
            if (this.mc.field_1765.method_17783() == class_239.class_240.field_1331 && this.mc.field_1724.method_7287(((class_3966)this.mc.field_1765).method_17782(), class_1268.field_5808) != class_1269.field_5811) {
                return;
            }
            if (this.mc.field_1765.method_17783() == class_239.class_240.field_1332 && this.mc.field_1724.method_6047().method_7909() instanceof class_1747) {
                return;
            }
        }
        if ((hitResult = this.mc.field_1687.method_17742(context = new class_3959(cameraPos = (camera = this.mc.field_1773.method_19418()).method_71156(), targetPos = cameraPos.method_1019(direction = class_243.method_1030((float)camera.method_19329(), (float)camera.method_19330()).method_1021(210.0)), class_3959.class_3960.field_17559, class_3959.class_242.field_1348, (class_1297)this.mc.field_1724))).method_17783() == class_239.class_240.field_1332) {
            class_2338 pos = hitResult.method_17777();
            class_2350 side = hitResult.method_17780();
            if (this.mc.field_1687.method_8320(pos).method_55781((class_1937)this.mc.field_1687, (class_1657)this.mc.field_1724, hitResult) != class_1269.field_5811) {
                return;
            }
            class_2680 state = this.mc.field_1687.method_8320(pos);
            class_265 shape = state.method_26220((class_1922)this.mc.field_1687, pos);
            if (shape.method_1110()) {
                shape = state.method_26218((class_1922)this.mc.field_1687, pos);
            }
            double height = shape.method_1110() ? 1.0 : shape.method_1105(class_2350.class_2351.field_11052);
            class_243 newPos = new class_243((double)pos.method_10263() + 0.5 + (double)side.method_10148(), (double)pos.method_10264() + height, (double)pos.method_10260() + 0.5 + (double)side.method_10165());
            int packetsRequired = (int)Math.ceil(this.mc.field_1724.method_73189().method_1022(newPos) / 10.0) - 1;
            if (packetsRequired > 19) {
                packetsRequired = 0;
            }
            for (int packetNumber = 0; packetNumber < packetsRequired; ++packetNumber) {
                this.mc.field_1724.field_3944.method_52787((class_2596)new class_2828.class_5911(true, true));
            }
            this.mc.field_1724.field_3944.method_52787((class_2596)new class_2828.class_2829(newPos.field_1352, newPos.field_1351, newPos.field_1350, true, true));
            this.mc.field_1724.method_33574(newPos);
        }
    }
}

