| 1 | /*
|
| 2 | * This file is part of the Meteor Client distribution (https://github.com/MeteorDevelopment/meteor-client).
|
| 3 | * Copyright (c) Meteor Development.
|
| 4 | */
|
| 5 |
|
| 6 | package meteordevelopment.meteorclient.systems.modules.world;
|
| 7 |
|
| 8 | import meteordevelopment.meteorclient.events.entity.player.BreakBlockEvent;
|
| 9 | import meteordevelopment.meteorclient.events.entity.player.PlaceBlockEvent;
|
| 10 | import meteordevelopment.meteorclient.settings.BoolSetting;
|
| 11 | import meteordevelopment.meteorclient.settings.Setting;
|
| 12 | import meteordevelopment.meteorclient.settings.SettingGroup;
|
| 13 | import meteordevelopment.meteorclient.systems.modules.Categories;
|
| 14 | import meteordevelopment.meteorclient.systems.modules.Module;
|
| 15 | import meteordevelopment.orbit.EventHandler;
|
| 16 | import net.minecraft.world.level.block.state.BlockState;
|
| 17 |
|
| 18 | public class NoGhostBlocks extends Module {
|
| 19 | private final SettingGroup sgGeneral = settings.getDefaultGroup();
|
| 20 |
|
| 21 | private final Setting<Boolean> breaking = sgGeneral.add(new BoolSetting.Builder()
|
| 22 | .name("breaking")
|
| 23 | .description("Whether to apply for block breaking actions.")
|
| 24 | .defaultValue(true)
|
| 25 | .build()
|
| 26 | );
|
| 27 |
|
| 28 | public final Setting<Boolean> placing = sgGeneral.add(new BoolSetting.Builder()
|
| 29 | .name("placing")
|
| 30 | .description("Whether to apply for block placement actions.")
|
| 31 | .defaultValue(true)
|
| 32 | .build()
|
| 33 | );
|
| 34 |
|
| 35 | public NoGhostBlocks() {
|
| 36 | super(Categories.World, "no-ghost-blocks", "Attempts to prevent ghost blocks arising.");
|
| 37 | }
|
| 38 |
|
| 39 | @EventHandler
|
| 40 | private void onBreakBlock(BreakBlockEvent event) {
|
| 41 | if (mc.isLocalServer() || !breaking.get()) return;
|
| 42 |
|
| 43 | event.cancel();
|
| 44 |
|
| 45 | BlockState blockState = mc.level.getBlockState(event.blockPos);
|
| 46 | blockState.getBlock().playerWillDestroy(mc.level, event.blockPos, blockState, mc.player);
|
| 47 | }
|
| 48 |
|
| 49 | @EventHandler
|
| 50 | private void onPlaceBlock(PlaceBlockEvent event) {
|
| 51 | if (!placing.get()) return;
|
| 52 |
|
| 53 | event.cancel();
|
| 54 | }
|
| 55 | }
|
| 56 |
|