/*
 * Decompiled with CFR 0.152.
 * 
 * Could not load the following classes:
 *  it.unimi.dsi.fastutil.objects.ObjectOpenHashSet
 *  meteordevelopment.orbit.EventHandler
 *  net.minecraft.class_1268
 *  net.minecraft.class_1297
 *  net.minecraft.class_1922
 *  net.minecraft.class_2248
 *  net.minecraft.class_2338
 *  net.minecraft.class_2338$class_2339
 *  net.minecraft.class_2350
 *  net.minecraft.class_238
 *  net.minecraft.class_2382
 *  net.minecraft.class_239
 *  net.minecraft.class_239$class_240
 *  net.minecraft.class_243
 *  net.minecraft.class_2596
 *  net.minecraft.class_2846
 *  net.minecraft.class_2846$class_2847
 *  net.minecraft.class_2879
 *  net.minecraft.class_3959
 *  net.minecraft.class_3959$class_242
 *  net.minecraft.class_3959$class_3960
 *  net.minecraft.class_3965
 */
package meteordevelopment.meteorclient.systems.modules.world;

import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.Set;
import meteordevelopment.meteorclient.events.entity.player.BlockBreakingCooldownEvent;
import meteordevelopment.meteorclient.events.meteor.KeyEvent;
import meteordevelopment.meteorclient.events.meteor.MouseClickEvent;
import meteordevelopment.meteorclient.events.render.Render3DEvent;
import meteordevelopment.meteorclient.events.world.TickEvent;
import meteordevelopment.meteorclient.renderer.ShapeMode;
import meteordevelopment.meteorclient.settings.BlockListSetting;
import meteordevelopment.meteorclient.settings.BoolSetting;
import meteordevelopment.meteorclient.settings.ColorSetting;
import meteordevelopment.meteorclient.settings.DoubleSetting;
import meteordevelopment.meteorclient.settings.EnumSetting;
import meteordevelopment.meteorclient.settings.IntSetting;
import meteordevelopment.meteorclient.settings.KeybindSetting;
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.Utils;
import meteordevelopment.meteorclient.utils.misc.Keybind;
import meteordevelopment.meteorclient.utils.misc.Names;
import meteordevelopment.meteorclient.utils.misc.input.KeyAction;
import meteordevelopment.meteorclient.utils.player.PlayerUtils;
import meteordevelopment.meteorclient.utils.player.Rotations;
import meteordevelopment.meteorclient.utils.render.RenderUtils;
import meteordevelopment.meteorclient.utils.render.color.SettingColor;
import meteordevelopment.meteorclient.utils.world.BlockIterator;
import meteordevelopment.meteorclient.utils.world.BlockUtils;
import meteordevelopment.orbit.EventHandler;
import net.minecraft.class_1268;
import net.minecraft.class_1297;
import net.minecraft.class_1922;
import net.minecraft.class_2248;
import net.minecraft.class_2338;
import net.minecraft.class_2350;
import net.minecraft.class_238;
import net.minecraft.class_2382;
import net.minecraft.class_239;
import net.minecraft.class_243;
import net.minecraft.class_2596;
import net.minecraft.class_2846;
import net.minecraft.class_2879;
import net.minecraft.class_3959;
import net.minecraft.class_3965;

public class Nuker
extends Module {
    private final SettingGroup sgGeneral;
    private final SettingGroup sgWhitelist;
    private final SettingGroup sgRender;
    private final Setting<Shape> shape;
    private final Setting<Mode> mode;
    private final Setting<Double> range;
    private final Setting<Integer> range_up;
    private final Setting<Integer> range_down;
    private final Setting<Integer> range_left;
    private final Setting<Integer> range_right;
    private final Setting<Integer> range_forward;
    private final Setting<Integer> range_back;
    private final Setting<Double> wallsRange;
    private final Setting<Integer> delay;
    private final Setting<Integer> maxBlocksPerTick;
    private final Setting<SortMode> sortMode;
    private final Setting<Boolean> packetMine;
    private final Setting<Boolean> suitableTools;
    private final Setting<Boolean> interact;
    private final Setting<Boolean> rotate;
    private final Setting<ListMode> listMode;
    private final Setting<List<class_2248>> blacklist;
    private final Setting<List<class_2248>> whitelist;
    private final Setting<Keybind> selectBlockBind;
    private final Setting<Boolean> swing;
    private final Setting<Boolean> enableRenderBounding;
    private final Setting<ShapeMode> shapeModeBox;
    private final Setting<SettingColor> sideColorBox;
    private final Setting<SettingColor> lineColorBox;
    private final Setting<Boolean> enableRenderBreaking;
    private final Setting<ShapeMode> shapeModeBreak;
    private final Setting<SettingColor> sideColor;
    private final Setting<SettingColor> lineColor;
    private final List<class_2338> blocks;
    private final Set<class_2338> interacted;
    private boolean firstBlock;
    private final class_2338.class_2339 lastBlockPos;
    private int timer;
    private int noBlockTimer;
    private final class_2338.class_2339 pos1;
    private final class_2338.class_2339 pos2;
    int maxh;
    int maxv;

    public Nuker() {
        super(Categories.World, "nuker", "Breaks blocks around you.");
        this.sgGeneral = this.settings.getDefaultGroup();
        this.sgWhitelist = this.settings.createGroup("Whitelist");
        this.sgRender = this.settings.createGroup("Render");
        this.shape = this.sgGeneral.add(((EnumSetting.Builder)((EnumSetting.Builder)((EnumSetting.Builder)new EnumSetting.Builder().name("shape")).description("The shape of nuking algorithm.")).defaultValue(Shape.Sphere)).build());
        this.mode = this.sgGeneral.add(((EnumSetting.Builder)((EnumSetting.Builder)((EnumSetting.Builder)new EnumSetting.Builder().name("mode")).description("The way the blocks are broken.")).defaultValue(Mode.Flatten)).build());
        this.range = this.sgGeneral.add(((DoubleSetting.Builder)((DoubleSetting.Builder)((DoubleSetting.Builder)new DoubleSetting.Builder().name("range")).description("The break range.")).defaultValue(4.0).min(0.0).visible(() -> this.shape.get() != Shape.Cube)).build());
        this.range_up = this.sgGeneral.add(((IntSetting.Builder)((IntSetting.Builder)((IntSetting.Builder)((IntSetting.Builder)new IntSetting.Builder().name("up")).description("The break range.")).defaultValue(1)).min(0).visible(() -> this.shape.get() == Shape.Cube)).build());
        this.range_down = this.sgGeneral.add(((IntSetting.Builder)((IntSetting.Builder)((IntSetting.Builder)((IntSetting.Builder)new IntSetting.Builder().name("down")).description("The break range.")).defaultValue(1)).min(0).visible(() -> this.shape.get() == Shape.Cube)).build());
        this.range_left = this.sgGeneral.add(((IntSetting.Builder)((IntSetting.Builder)((IntSetting.Builder)((IntSetting.Builder)new IntSetting.Builder().name("left")).description("The break range.")).defaultValue(1)).min(0).visible(() -> this.shape.get() == Shape.Cube)).build());
        this.range_right = this.sgGeneral.add(((IntSetting.Builder)((IntSetting.Builder)((IntSetting.Builder)((IntSetting.Builder)new IntSetting.Builder().name("right")).description("The break range.")).defaultValue(1)).min(0).visible(() -> this.shape.get() == Shape.Cube)).build());
        this.range_forward = this.sgGeneral.add(((IntSetting.Builder)((IntSetting.Builder)((IntSetting.Builder)((IntSetting.Builder)new IntSetting.Builder().name("forward")).description("The break range.")).defaultValue(1)).min(0).visible(() -> this.shape.get() == Shape.Cube)).build());
        this.range_back = this.sgGeneral.add(((IntSetting.Builder)((IntSetting.Builder)((IntSetting.Builder)((IntSetting.Builder)new IntSetting.Builder().name("back")).description("The break range.")).defaultValue(1)).min(0).visible(() -> this.shape.get() == Shape.Cube)).build());
        this.wallsRange = this.sgGeneral.add(((DoubleSetting.Builder)((DoubleSetting.Builder)new DoubleSetting.Builder().name("walls-range")).description("Range in which to break when behind blocks.")).defaultValue(4.0).min(0.0).sliderMax(6.0).build());
        this.delay = this.sgGeneral.add(((IntSetting.Builder)((IntSetting.Builder)((IntSetting.Builder)new IntSetting.Builder().name("delay")).description("Delay in ticks between breaking blocks.")).defaultValue(0)).build());
        this.maxBlocksPerTick = this.sgGeneral.add(((IntSetting.Builder)((IntSetting.Builder)((IntSetting.Builder)new IntSetting.Builder().name("max-blocks-per-tick")).description("Maximum blocks to try to break per tick. Useful when insta mining.")).defaultValue(1)).min(1).build());
        this.sortMode = this.sgGeneral.add(((EnumSetting.Builder)((EnumSetting.Builder)((EnumSetting.Builder)new EnumSetting.Builder().name("sort-mode")).description("The blocks you want to mine first.")).defaultValue(SortMode.Closest)).build());
        this.packetMine = this.sgGeneral.add(((BoolSetting.Builder)((BoolSetting.Builder)((BoolSetting.Builder)new BoolSetting.Builder().name("packet-mine")).description("Attempt to instamine everything at once.")).defaultValue(false)).build());
        this.suitableTools = this.sgGeneral.add(((BoolSetting.Builder)((BoolSetting.Builder)((BoolSetting.Builder)new BoolSetting.Builder().name("only-suitable-tools")).description("Only mines when using an appropriate for the block.")).defaultValue(false)).build());
        this.interact = this.sgGeneral.add(((BoolSetting.Builder)((BoolSetting.Builder)((BoolSetting.Builder)new BoolSetting.Builder().name("interact")).description("Interacts with the block instead of mining.")).defaultValue(false)).build());
        this.rotate = this.sgGeneral.add(((BoolSetting.Builder)((BoolSetting.Builder)((BoolSetting.Builder)new BoolSetting.Builder().name("rotate")).description("Rotates server-side to the block being mined.")).defaultValue(true)).build());
        this.listMode = this.sgWhitelist.add(((EnumSetting.Builder)((EnumSetting.Builder)((EnumSetting.Builder)new EnumSetting.Builder().name("list-mode")).description("Selection mode.")).defaultValue(ListMode.Blacklist)).build());
        this.blacklist = this.sgWhitelist.add(((BlockListSetting.Builder)((BlockListSetting.Builder)((BlockListSetting.Builder)new BlockListSetting.Builder().name("blacklist")).description("The blocks you don't want to mine.")).visible(() -> this.listMode.get() == ListMode.Blacklist)).build());
        this.whitelist = this.sgWhitelist.add(((BlockListSetting.Builder)((BlockListSetting.Builder)((BlockListSetting.Builder)new BlockListSetting.Builder().name("whitelist")).description("The blocks you want to mine.")).visible(() -> this.listMode.get() == ListMode.Whitelist)).build());
        this.selectBlockBind = this.sgWhitelist.add(((KeybindSetting.Builder)((KeybindSetting.Builder)((KeybindSetting.Builder)new KeybindSetting.Builder().name("select-block-bind")).description("Adds targeted block to list when this button is pressed.")).defaultValue(Keybind.none())).build());
        this.swing = this.sgRender.add(((BoolSetting.Builder)((BoolSetting.Builder)((BoolSetting.Builder)new BoolSetting.Builder().name("swing")).description("Whether to swing hand client-side.")).defaultValue(true)).build());
        this.enableRenderBounding = this.sgRender.add(((BoolSetting.Builder)((BoolSetting.Builder)((BoolSetting.Builder)new BoolSetting.Builder().name("bounding-box")).description("Enable rendering bounding box for Cube and Uniform Cube.")).defaultValue(true)).build());
        this.shapeModeBox = this.sgRender.add(((EnumSetting.Builder)((EnumSetting.Builder)((EnumSetting.Builder)new EnumSetting.Builder().name("nuke-box-mode")).description("How the shape for the bounding box is rendered.")).defaultValue(ShapeMode.Both)).build());
        this.sideColorBox = this.sgRender.add(((ColorSetting.Builder)((ColorSetting.Builder)new ColorSetting.Builder().name("side-color")).description("The side color of the bounding box.")).defaultValue(new SettingColor(16, 106, 144, 100)).build());
        this.lineColorBox = this.sgRender.add(((ColorSetting.Builder)((ColorSetting.Builder)new ColorSetting.Builder().name("line-color")).description("The line color of the bounding box.")).defaultValue(new SettingColor(16, 106, 144, 255)).build());
        this.enableRenderBreaking = this.sgRender.add(((BoolSetting.Builder)((BoolSetting.Builder)((BoolSetting.Builder)new BoolSetting.Builder().name("broken-blocks")).description("Enable rendering bounding box for Cube and Uniform Cube.")).defaultValue(true)).build());
        this.shapeModeBreak = this.sgRender.add(((EnumSetting.Builder)((EnumSetting.Builder)((EnumSetting.Builder)((EnumSetting.Builder)new EnumSetting.Builder().name("nuke-block-mode")).description("How the shapes for broken blocks are rendered.")).defaultValue(ShapeMode.Both)).visible(this.enableRenderBreaking::get)).build());
        this.sideColor = this.sgRender.add(((ColorSetting.Builder)((ColorSetting.Builder)((ColorSetting.Builder)new ColorSetting.Builder().name("side-color")).description("The side color of the target block rendering.")).defaultValue(new SettingColor(255, 0, 0, 80)).visible(this.enableRenderBreaking::get)).build());
        this.lineColor = this.sgRender.add(((ColorSetting.Builder)((ColorSetting.Builder)((ColorSetting.Builder)new ColorSetting.Builder().name("line-color")).description("The line color of the target block rendering.")).defaultValue(new SettingColor(255, 0, 0, 255)).visible(this.enableRenderBreaking::get)).build());
        this.blocks = new ArrayList<class_2338>();
        this.interacted = new ObjectOpenHashSet();
        this.lastBlockPos = new class_2338.class_2339();
        this.pos1 = new class_2338.class_2339();
        this.pos2 = new class_2338.class_2339();
        this.maxh = 0;
        this.maxv = 0;
    }

    @Override
    public void onActivate() {
        this.firstBlock = true;
        this.timer = 0;
        this.noBlockTimer = 0;
        this.interacted.clear();
    }

    @EventHandler
    private void onRender(Render3DEvent event) {
        if (this.enableRenderBounding.get().booleanValue() && this.shape.get() != Shape.Sphere && this.mode.get() != Mode.Smash) {
            int minX = Math.min(this.pos1.method_10263(), this.pos2.method_10263());
            int minY = Math.min(this.pos1.method_10264(), this.pos2.method_10264());
            int minZ = Math.min(this.pos1.method_10260(), this.pos2.method_10260());
            int maxX = Math.max(this.pos1.method_10263(), this.pos2.method_10263());
            int maxY = Math.max(this.pos1.method_10264(), this.pos2.method_10264());
            int maxZ = Math.max(this.pos1.method_10260(), this.pos2.method_10260());
            event.renderer.box(minX, minY, minZ, maxX, maxY, maxZ, this.sideColorBox.get(), this.lineColorBox.get(), this.shapeModeBox.get(), 0);
        }
    }

    @EventHandler
    private void onMouseClick(MouseClickEvent event) {
        if (event.action == KeyAction.Press) {
            this.addTargetedBlockToList();
        }
    }

    @EventHandler
    private void onKey(KeyEvent event) {
        if (event.action == KeyAction.Press) {
            this.addTargetedBlockToList();
        }
    }

    @EventHandler
    private void onTickPre(TickEvent.Pre event) {
        if (this.timer > 0) {
            --this.timer;
            return;
        }
        double pX = this.mc.field_1724.method_23317();
        double pY = this.mc.field_1724.method_23318();
        double pZ = this.mc.field_1724.method_23321();
        double rangeSq = Math.pow(this.range.get(), 2.0);
        class_2338 playerBlockPos = this.mc.field_1724.method_24515();
        if (this.shape.get() == Shape.UniformCube) {
            this.range.set(Double.valueOf(Math.round(this.range.get())));
        }
        double pX_ = pX;
        double pZ_ = pZ;
        int r = (int)Math.round(this.range.get());
        if (this.shape.get() == Shape.UniformCube) {
            this.pos1.method_10102((pX_ += 1.0) - (double)r, pY - (double)r + 1.0, pZ - (double)r + 1.0);
            this.pos2.method_10102(pX_ + (double)r - 1.0, pY + (double)r, pZ + (double)r);
            this.maxh = 0;
            this.maxv = 0;
        } else {
            class_2350 direction = this.mc.field_1724.method_5735();
            switch (direction) {
                case field_11035: {
                    this.pos1.method_10102((pX_ += 1.0) - (double)(this.range_right.get() + 1), Math.ceil(pY) - (double)this.range_down.get().intValue(), (pZ_ += 1.0) - (double)(this.range_back.get() + 1));
                    this.pos2.method_10102(pX_ + (double)this.range_left.get().intValue(), Math.ceil(pY + (double)this.range_up.get().intValue() + 1.0), pZ_ + (double)this.range_forward.get().intValue());
                    break;
                }
                case field_11039: {
                    this.pos1.method_10102(pX_ - (double)this.range_forward.get().intValue(), Math.ceil(pY) - (double)this.range_down.get().intValue(), pZ_ - (double)this.range_right.get().intValue());
                    this.pos2.method_10102(pX_ + (double)this.range_back.get().intValue() + 1.0, Math.ceil(pY + (double)this.range_up.get().intValue() + 1.0), pZ_ + (double)this.range_left.get().intValue() + 1.0);
                    break;
                }
                case field_11043: {
                    this.pos1.method_10102((pX_ += 1.0) - (double)(this.range_left.get() + 1), Math.ceil(pY) - (double)this.range_down.get().intValue(), (pZ_ += 1.0) - (double)(this.range_forward.get() + 1));
                    this.pos2.method_10102(pX_ + (double)this.range_right.get().intValue(), Math.ceil(pY + (double)this.range_up.get().intValue() + 1.0), pZ_ + (double)this.range_back.get().intValue());
                    break;
                }
                case field_11034: {
                    this.pos1.method_10102((pX_ += 1.0) - (double)(this.range_back.get() + 1), Math.ceil(pY) - (double)this.range_down.get().intValue(), pZ_ - (double)this.range_left.get().intValue());
                    this.pos2.method_10102(pX_ + (double)this.range_forward.get().intValue(), Math.ceil(pY + (double)this.range_up.get().intValue() + 1.0), pZ_ + (double)this.range_right.get().intValue() + 1.0);
                    break;
                }
                case field_11036: 
                case field_11033: {
                    this.pos1.method_10102(pX_ - (double)this.range_right.get().intValue(), Math.ceil(pY) - (double)this.range_down.get().intValue(), pZ_ - (double)this.range_back.get().intValue());
                    this.pos2.method_10102(pX_ + (double)this.range_left.get().intValue(), Math.ceil(pY + (double)this.range_up.get().intValue() + 1.0), pZ_ + (double)this.range_forward.get().intValue());
                }
            }
            this.maxh = 1 + Math.max(Math.max(Math.max(this.range_back.get(), this.range_right.get()), this.range_forward.get()), this.range_left.get());
            this.maxv = 1 + Math.max(this.range_up.get(), this.range_down.get());
        }
        if (this.mode.get() == Mode.Flatten) {
            this.pos1.method_33098((int)Math.floor(pY + 0.5));
        }
        class_238 box = new class_238(this.pos1.method_46558(), this.pos2.method_46558());
        BlockIterator.register(Math.max((int)Math.ceil(this.range.get() + 1.0), this.maxh), Math.max((int)Math.ceil(this.range.get()), this.maxv), (blockPos, blockState) -> {
            class_243 center = blockPos.method_46558();
            switch (this.shape.get().ordinal()) {
                case 2: {
                    if (!(Utils.squaredDistance(pX, pY, pZ, center.method_10216(), center.method_10214(), center.method_10215()) > rangeSq)) break;
                    return;
                }
                case 1: {
                    if (!((double)Nuker.chebyshevDist(playerBlockPos.method_10263(), playerBlockPos.method_10264(), playerBlockPos.method_10260(), blockPos.method_10263(), blockPos.method_10264(), blockPos.method_10260()) >= this.range.get())) break;
                    return;
                }
                case 0: {
                    if (box.method_1006(center)) break;
                    return;
                }
            }
            if (this.mode.get() == Mode.Flatten && (double)blockPos.method_10264() + 0.5 < pY) {
                return;
            }
            if (this.mode.get() == Mode.Smash && blockState.method_26214((class_1922)this.mc.field_1687, blockPos) != 0.0f) {
                return;
            }
            if (this.suitableTools.get().booleanValue() && !this.interact.get().booleanValue() && !this.mc.field_1724.method_6047().method_7951(blockState)) {
                return;
            }
            if (!BlockUtils.canBreak(blockPos, blockState) && !this.interact.get().booleanValue()) {
                return;
            }
            if (this.isOutOfRange((class_2338)blockPos)) {
                return;
            }
            if (this.listMode.get() == ListMode.Whitelist && !this.whitelist.get().contains(blockState.method_26204())) {
                return;
            }
            if (this.listMode.get() == ListMode.Blacklist && this.blacklist.get().contains(blockState.method_26204())) {
                return;
            }
            if (this.interact.get().booleanValue() && this.interacted.contains(blockPos)) {
                return;
            }
            this.blocks.add(blockPos.method_10062());
        });
        BlockIterator.after(() -> {
            if (this.sortMode.get() == SortMode.TopDown) {
                this.blocks.sort(Comparator.comparingDouble(value -> -value.method_10264()));
            } else if (this.sortMode.get() != SortMode.None) {
                this.blocks.sort(Comparator.comparingDouble(value -> Utils.squaredDistance(pX, pY, pZ, (double)value.method_10263() + 0.5, (double)value.method_10264() + 0.5, (double)value.method_10260() + 0.5) * (double)(this.sortMode.get() == SortMode.Closest ? 1 : -1)));
            }
            if (this.blocks.isEmpty()) {
                this.interacted.clear();
                if (this.noBlockTimer++ >= this.delay.get()) {
                    this.firstBlock = true;
                }
                return;
            }
            this.noBlockTimer = 0;
            if (!this.firstBlock && !this.lastBlockPos.equals((Object)this.blocks.getFirst())) {
                this.timer = this.delay.get();
                this.firstBlock = false;
                this.lastBlockPos.method_10101((class_2382)this.blocks.getFirst());
                if (this.timer > 0) {
                    return;
                }
            }
            int count = 0;
            for (class_2338 block : this.blocks) {
                if (count >= this.maxBlocksPerTick.get()) break;
                boolean canInstaMine = BlockUtils.canInstaBreak(block);
                if (this.rotate.get().booleanValue()) {
                    Rotations.rotate(Rotations.getYaw(block), Rotations.getPitch(block), () -> this.breakBlock(block));
                } else {
                    this.breakBlock(block);
                }
                if (this.enableRenderBreaking.get().booleanValue()) {
                    RenderUtils.renderTickingBlock(block, this.sideColor.get(), this.lineColor.get(), this.shapeModeBreak.get(), 0, 8, true, false);
                }
                this.lastBlockPos.method_10101((class_2382)block);
                ++count;
                if (canInstaMine || this.packetMine.get().booleanValue()) continue;
                break;
            }
            this.firstBlock = false;
            this.blocks.clear();
        });
    }

    private void breakBlock(class_2338 blockPos) {
        if (this.interact.get().booleanValue()) {
            BlockUtils.interact(new class_3965(blockPos.method_46558(), BlockUtils.getDirection(blockPos), blockPos, true), class_1268.field_5808, this.swing.get());
            this.interacted.add(blockPos);
        } else if (this.packetMine.get().booleanValue()) {
            this.mc.field_1761.method_41931(this.mc.field_1687, sequence -> new class_2846(class_2846.class_2847.field_12968, blockPos, BlockUtils.getDirection(blockPos), sequence));
            if (this.swing.get().booleanValue()) {
                this.mc.field_1724.method_6104(class_1268.field_5808);
            } else {
                this.mc.method_1562().method_52787((class_2596)new class_2879(class_1268.field_5808));
            }
            this.mc.field_1761.method_41931(this.mc.field_1687, sequence -> new class_2846(class_2846.class_2847.field_12973, blockPos, BlockUtils.getDirection(blockPos), sequence));
        } else {
            BlockUtils.breakBlock(blockPos, this.swing.get());
        }
    }

    private boolean isOutOfRange(class_2338 blockPos) {
        class_243 pos = blockPos.method_46558();
        class_3959 raycastContext = new class_3959(this.mc.field_1724.method_33571(), pos, class_3959.class_3960.field_17558, class_3959.class_242.field_1348, (class_1297)this.mc.field_1724);
        class_3965 result = this.mc.field_1687.method_17742(raycastContext);
        if (result == null || !result.method_17777().equals((Object)blockPos)) {
            return !PlayerUtils.isWithin(pos, (double)this.wallsRange.get());
        }
        return false;
    }

    private void addTargetedBlockToList() {
        if (!this.selectBlockBind.get().isPressed() || this.mc.field_1755 != null) {
            return;
        }
        class_239 hitResult = this.mc.field_1765;
        if (hitResult == null || hitResult.method_17783() != class_239.class_240.field_1332) {
            return;
        }
        class_2338 pos = ((class_3965)hitResult).method_17777();
        class_2248 targetBlock = this.mc.field_1687.method_8320(pos).method_26204();
        List<class_2248> list = this.listMode.get() == ListMode.Whitelist ? this.whitelist.get() : this.blacklist.get();
        String modeName = this.listMode.get().name();
        if (list.contains(targetBlock)) {
            list.remove(targetBlock);
            this.info("Removed " + Names.get(targetBlock) + " from " + modeName, new Object[0]);
        } else {
            list.add(targetBlock);
            this.info("Added " + Names.get(targetBlock) + " to " + modeName, new Object[0]);
        }
    }

    @EventHandler(priority=200)
    private void onBlockBreakingCooldown(BlockBreakingCooldownEvent event) {
        event.cooldown = 0;
    }

    public static int chebyshevDist(int x1, int y1, int z1, int x2, int y2, int z2) {
        int dX = Math.abs(x2 - x1);
        int dY = Math.abs(y2 - y1);
        int dZ = Math.abs(z2 - z1);
        return Math.max(Math.max(dX, dY), dZ);
    }

    public static enum Shape {
        Cube,
        UniformCube,
        Sphere;

    }

    public static enum Mode {
        All,
        Flatten,
        Smash;

    }

    public static enum SortMode {
        None,
        Closest,
        Furthest,
        TopDown;

    }

    public static enum ListMode {
        Whitelist,
        Blacklist;

    }
}

