/*
 * Decompiled with CFR 0.152.
 * 
 * Could not load the following classes:
 *  net.minecraft.class_1297
 *  net.minecraft.class_1299
 *  net.minecraft.class_1657
 *  net.minecraft.class_1835
 *  net.minecraft.class_3489
 *  net.minecraft.class_9362
 */
package meteordevelopment.meteorclient.systems.modules.combat;

import java.util.Set;
import meteordevelopment.meteorclient.settings.BoolSetting;
import meteordevelopment.meteorclient.settings.DoubleSetting;
import meteordevelopment.meteorclient.settings.EntityTypeListSetting;
import meteordevelopment.meteorclient.settings.Setting;
import meteordevelopment.meteorclient.settings.SettingGroup;
import meteordevelopment.meteorclient.systems.friends.Friends;
import meteordevelopment.meteorclient.systems.modules.Categories;
import meteordevelopment.meteorclient.systems.modules.Module;
import meteordevelopment.meteorclient.utils.player.InvUtils;
import net.minecraft.class_1297;
import net.minecraft.class_1299;
import net.minecraft.class_1657;
import net.minecraft.class_1835;
import net.minecraft.class_3489;
import net.minecraft.class_9362;

public class Hitboxes
extends Module {
    private final SettingGroup sgGeneral;
    private final SettingGroup sgWeapon;
    private final Setting<Set<class_1299<?>>> entities;
    private final Setting<Double> value;
    private final Setting<Boolean> ignoreFriends;
    private final Setting<Boolean> onlyOnWeapon;
    private final Setting<Boolean> sword;
    private final Setting<Boolean> axe;
    private final Setting<Boolean> pickaxe;
    private final Setting<Boolean> shovel;
    private final Setting<Boolean> hoe;
    private final Setting<Boolean> mace;
    private final Setting<Boolean> spear;
    private final Setting<Boolean> trident;

    public Hitboxes() {
        super(Categories.PvP, "hitboxes", "Expands an entity's hitboxes.");
        this.sgGeneral = this.settings.getDefaultGroup();
        this.sgWeapon = this.settings.createGroup("Weapon Options");
        this.entities = this.sgGeneral.add(((EntityTypeListSetting.Builder)((EntityTypeListSetting.Builder)new EntityTypeListSetting.Builder().name("entities")).description("Which entities to target.")).defaultValue(class_1299.field_6097).build());
        this.value = this.sgGeneral.add(((DoubleSetting.Builder)((DoubleSetting.Builder)new DoubleSetting.Builder().name("expand")).description("How much to expand the hitbox of the entity.")).defaultValue(0.5).build());
        this.ignoreFriends = this.sgGeneral.add(((BoolSetting.Builder)((BoolSetting.Builder)((BoolSetting.Builder)new BoolSetting.Builder().name("ignore-friends")).description("Doesn't expand the hitboxes of friends.")).defaultValue(true)).build());
        this.onlyOnWeapon = this.sgWeapon.add(((BoolSetting.Builder)((BoolSetting.Builder)((BoolSetting.Builder)new BoolSetting.Builder().name("only-on-weapon")).description("Only modifies hitbox when holding a weapon in hand.")).defaultValue(false)).build());
        this.sword = this.sgWeapon.add(((BoolSetting.Builder)((BoolSetting.Builder)((BoolSetting.Builder)((BoolSetting.Builder)new BoolSetting.Builder().name("sword")).description("Enable when holding a sword.")).defaultValue(true)).visible(this.onlyOnWeapon::get)).build());
        this.axe = this.sgWeapon.add(((BoolSetting.Builder)((BoolSetting.Builder)((BoolSetting.Builder)((BoolSetting.Builder)new BoolSetting.Builder().name("axe")).description("Enable when holding an axe.")).defaultValue(true)).visible(this.onlyOnWeapon::get)).build());
        this.pickaxe = this.sgWeapon.add(((BoolSetting.Builder)((BoolSetting.Builder)((BoolSetting.Builder)((BoolSetting.Builder)new BoolSetting.Builder().name("pickaxe")).description("Enable when holding a pickaxe.")).defaultValue(true)).visible(this.onlyOnWeapon::get)).build());
        this.shovel = this.sgWeapon.add(((BoolSetting.Builder)((BoolSetting.Builder)((BoolSetting.Builder)((BoolSetting.Builder)new BoolSetting.Builder().name("shovel")).description("Enable when holding a shovel.")).defaultValue(true)).visible(this.onlyOnWeapon::get)).build());
        this.hoe = this.sgWeapon.add(((BoolSetting.Builder)((BoolSetting.Builder)((BoolSetting.Builder)((BoolSetting.Builder)new BoolSetting.Builder().name("hoe")).description("Enable when holding a hoe.")).defaultValue(true)).visible(this.onlyOnWeapon::get)).build());
        this.mace = this.sgWeapon.add(((BoolSetting.Builder)((BoolSetting.Builder)((BoolSetting.Builder)((BoolSetting.Builder)new BoolSetting.Builder().name("mace")).description("Enable when holding a mace.")).defaultValue(true)).visible(this.onlyOnWeapon::get)).build());
        this.spear = this.sgWeapon.add(((BoolSetting.Builder)((BoolSetting.Builder)((BoolSetting.Builder)((BoolSetting.Builder)new BoolSetting.Builder().name("spear")).description("Enable when holding a spear.")).defaultValue(true)).visible(this.onlyOnWeapon::get)).build());
        this.trident = this.sgWeapon.add(((BoolSetting.Builder)((BoolSetting.Builder)((BoolSetting.Builder)((BoolSetting.Builder)new BoolSetting.Builder().name("trident")).description("Enable when holding a trident.")).defaultValue(true)).visible(this.onlyOnWeapon::get)).build());
    }

    public double getEntityValue(class_1297 entity) {
        block5: {
            block4: {
                if (!this.isActive() || !this.testWeapon()) break block4;
                if (!this.ignoreFriends.get().booleanValue() || !(entity instanceof class_1657)) break block5;
                class_1657 playerEntity = (class_1657)entity;
                if (!Friends.get().isFriend(playerEntity)) break block5;
            }
            return 0.0;
        }
        if (this.entities.get().contains(entity.method_5864())) {
            return this.value.get();
        }
        return 0.0;
    }

    private boolean testWeapon() {
        if (!this.onlyOnWeapon.get().booleanValue()) {
            return true;
        }
        return InvUtils.testInMainHand(itemStack -> {
            if (this.sword.get().booleanValue() && itemStack.method_31573(class_3489.field_42611)) {
                return true;
            }
            if (this.axe.get().booleanValue() && itemStack.method_31573(class_3489.field_42612)) {
                return true;
            }
            if (this.pickaxe.get().booleanValue() && itemStack.method_31573(class_3489.field_42614)) {
                return true;
            }
            if (this.shovel.get().booleanValue() && itemStack.method_31573(class_3489.field_42615)) {
                return true;
            }
            if (this.hoe.get().booleanValue() && itemStack.method_31573(class_3489.field_42613)) {
                return true;
            }
            if (this.mace.get().booleanValue() && itemStack.method_7909() instanceof class_9362) {
                return true;
            }
            if (this.spear.get().booleanValue() && itemStack.method_31573(class_3489.field_63257)) {
                return true;
            }
            return this.trident.get() != false && itemStack.method_7909() instanceof class_1835;
        });
    }
}

