/*
 * Decompiled with CFR 0.152.
 * 
 * Could not load the following classes:
 *  meteordevelopment.orbit.EventHandler
 *  net.minecraft.class_1294
 *  net.minecraft.class_1297
 *  net.minecraft.class_1297$class_5529
 *  net.minecraft.class_1511
 *  net.minecraft.class_1799
 *  net.minecraft.class_1802
 *  net.minecraft.class_239
 *  net.minecraft.class_2824
 *  net.minecraft.class_3966
 */
package meteordevelopment.meteorclient.systems.modules.donut;

import meteordevelopment.meteorclient.events.packets.PacketEvent;
import meteordevelopment.meteorclient.systems.modules.Categories;
import meteordevelopment.meteorclient.systems.modules.Module;
import meteordevelopment.orbit.EventHandler;
import net.minecraft.class_1294;
import net.minecraft.class_1297;
import net.minecraft.class_1511;
import net.minecraft.class_1799;
import net.minecraft.class_1802;
import net.minecraft.class_239;
import net.minecraft.class_2824;
import net.minecraft.class_3966;

public class CrystalOptim
extends Module {
    public CrystalOptim() {
        super(Categories.Donut, "Crystal Optim", "Client-side crystal removal for faster crystals.");
    }

    @EventHandler
    private void onSendPacket(PacketEvent.Send event) {
        class_3966 entityHitResult;
        class_1297 entity;
        class_239 hitResult;
        if (event.packet instanceof class_2824 && (hitResult = this.mc.field_1765) instanceof class_3966 && (entity = (entityHitResult = (class_3966)hitResult).method_17782()) instanceof class_1511) {
            int strengthLvl;
            class_1511 crystal = (class_1511)entity;
            boolean weakness = this.mc.field_1724.method_6059(class_1294.field_5911);
            int weaknessLvl = weakness ? this.mc.field_1724.method_6112(class_1294.field_5911).method_5578() : -1;
            boolean strength = this.mc.field_1724.method_6059(class_1294.field_5910);
            int n = strengthLvl = strength ? this.mc.field_1724.method_6112(class_1294.field_5910).method_5578() : -1;
            if (weakness && strengthLvl <= weaknessLvl && !this.isTool(this.mc.field_1724.method_6047())) {
                return;
            }
            crystal.method_31472();
            crystal.method_31745(class_1297.class_5529.field_26998);
        }
    }

    private boolean isTool(class_1799 stack) {
        if (stack.method_7960()) {
            return false;
        }
        return stack.method_7909() == class_1802.field_8377 || stack.method_7909() == class_1802.field_22024 || stack.method_7909() == class_1802.field_8556 || stack.method_7909() == class_1802.field_22025 || stack.method_7909() == class_1802.field_8802 || stack.method_7909() == class_1802.field_22022 || stack.method_7909() == class_1802.field_8250 || stack.method_7909() == class_1802.field_22023;
    }
}

