/*
 * Decompiled with CFR 0.152.
 * 
 * Could not load the following classes:
 *  meteordevelopment.orbit.EventHandler
 *  net.minecraft.class_1657
 *  net.minecraft.class_1937
 *  net.minecraft.class_2680
 */
package meteordevelopment.meteorclient.systems.modules.world;

import meteordevelopment.meteorclient.events.entity.player.BreakBlockEvent;
import meteordevelopment.meteorclient.events.entity.player.PlaceBlockEvent;
import meteordevelopment.meteorclient.settings.BoolSetting;
import meteordevelopment.meteorclient.settings.Setting;
import meteordevelopment.meteorclient.settings.SettingGroup;
import meteordevelopment.meteorclient.systems.modules.Categories;
import meteordevelopment.meteorclient.systems.modules.Module;
import meteordevelopment.orbit.EventHandler;
import net.minecraft.class_1657;
import net.minecraft.class_1937;
import net.minecraft.class_2680;

public class NoGhostBlocks
extends Module {
    private final SettingGroup sgGeneral;
    private final Setting<Boolean> breaking;
    public final Setting<Boolean> placing;

    public NoGhostBlocks() {
        super(Categories.World, "no-ghost-blocks", "Attempts to prevent ghost blocks arising.");
        this.sgGeneral = this.settings.getDefaultGroup();
        this.breaking = this.sgGeneral.add(((BoolSetting.Builder)((BoolSetting.Builder)((BoolSetting.Builder)new BoolSetting.Builder().name("breaking")).description("Whether to apply for block breaking actions.")).defaultValue(true)).build());
        this.placing = this.sgGeneral.add(((BoolSetting.Builder)((BoolSetting.Builder)((BoolSetting.Builder)new BoolSetting.Builder().name("placing")).description("Whether to apply for block placement actions.")).defaultValue(true)).build());
    }

    @EventHandler
    private void onBreakBlock(BreakBlockEvent event) {
        if (this.mc.method_1542() || !this.breaking.get().booleanValue()) {
            return;
        }
        event.cancel();
        class_2680 blockState = this.mc.field_1687.method_8320(event.blockPos);
        blockState.method_26204().method_9576((class_1937)this.mc.field_1687, event.blockPos, blockState, (class_1657)this.mc.field_1724);
    }

    @EventHandler
    private void onPlaceBlock(PlaceBlockEvent event) {
        if (!this.placing.get().booleanValue()) {
            return;
        }
        event.cancel();
    }
}

