anti-bed module

anti-bed: Minecraft 26.3 cheat module, full source for every implementation (1 client: Meteor Client).

1 implementationCombat

Clients with this module

Full module source: 1 implementation

Every implementation below is the complete module file, verbatim. Expand a client to read its code.

Meteor ClientCombatsrc/main/java/meteordevelopment/meteorclient/systems/modules/combat/AntiBed.javaJava · 101 lines · 4.2 KB

Places string to prevent beds being placed on you.

Settingsplace-string-topplace-string-middleplace-string-bottomonly-in-hole
AntiBed.javaJava · Minecraft 26.2 · 101 lines · 4.2 KB · complete file, verbatimOriginal ↗
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.combat;
7
8
import meteordevelopment.meteorclient.events.world.TickEvent;
9
import meteordevelopment.meteorclient.settings.BoolSetting;
10
import meteordevelopment.meteorclient.settings.Setting;
11
import meteordevelopment.meteorclient.settings.SettingGroup;
12
import meteordevelopment.meteorclient.systems.modules.Categories;
13
import meteordevelopment.meteorclient.systems.modules.Module;
14
import meteordevelopment.meteorclient.utils.player.InvUtils;
15
import meteordevelopment.meteorclient.utils.player.PlayerUtils;
16
import meteordevelopment.meteorclient.utils.player.Rotations;
17
import meteordevelopment.meteorclient.utils.world.BlockUtils;
18
import meteordevelopment.orbit.EventHandler;
19
import net.minecraft.core.BlockPos;
20
import net.minecraft.core.Direction;
21
import net.minecraft.network.protocol.game.ServerboundPlayerActionPacket;
22
import net.minecraft.network.protocol.game.ServerboundSwingPacket;
23
import net.minecraft.world.InteractionHand;
24
import net.minecraft.world.item.Items;
25
import net.minecraft.world.level.block.BedBlock;
26
27
public class AntiBed extends Module {
28
    private final SettingGroup sgGeneral = settings.getDefaultGroup();
29
30
    private final Setting<Boolean> placeStringTop = sgGeneral.add(new BoolSetting.Builder()
31
        .name("place-string-top")
32
        .description("Places string above you.")
33
        .defaultValue(false)
34
        .build()
35
    );
36
37
    private final Setting<Boolean> placeStringMiddle = sgGeneral.add(new BoolSetting.Builder()
38
        .name("place-string-middle")
39
        .description("Places string in your upper hitbox.")
40
        .defaultValue(true)
41
        .build()
42
    );
43
44
    private final Setting<Boolean> placeStringBottom = sgGeneral.add(new BoolSetting.Builder()
45
        .name("place-string-bottom")
46
        .description("Places string at your feet.")
47
        .defaultValue(false)
48
        .build()
49
    );
50
51
    private final Setting<Boolean> onlyInHole = sgGeneral.add(new BoolSetting.Builder()
52
        .name("only-in-hole")
53
        .description("Only functions when you are standing in a hole.")
54
        .defaultValue(true)
55
        .build()
56
    );
57
58
    private boolean breaking;
59
60
    public AntiBed() {
61
        super(Categories.Combat, "anti-bed", "Places string to prevent beds being placed on you.");
62
    }
63
64
    @EventHandler
65
    private void onTick(TickEvent.Pre event) {
66
        if (onlyInHole.get() && !PlayerUtils.isInHole(true)) return;
67
68
        // Checking for and maybe breaking bed
69
        BlockPos head = mc.player.blockPosition().above();
70
71
        if (mc.level.getBlockState(head).getBlock() instanceof BedBlock && !breaking) {
72
            Rotations.rotate(Rotations.getYaw(head), Rotations.getPitch(head), 50, () -> sendMinePackets(head));
73
            breaking = true;
74
        } else if (breaking) {
75
            Rotations.rotate(Rotations.getYaw(head), Rotations.getPitch(head), 50, () -> sendStopPackets(head));
76
            breaking = false;
77
        }
78
79
        // String placement
80
        if (placeStringTop.get()) place(mc.player.blockPosition().above(2));
81
        if (placeStringMiddle.get()) place(mc.player.blockPosition().above(1));
82
        if (placeStringBottom.get()) place(mc.player.blockPosition());
83
    }
84
85
    private void place(BlockPos blockPos) {
86
        if (mc.level.getBlockState(blockPos).getBlock().asItem() != Items.STRING) {
87
            BlockUtils.place(blockPos, InvUtils.findInHotbar(Items.STRING), 50, false);
88
        }
89
    }
90
91
    private void sendMinePackets(BlockPos blockPos) {
92
        mc.gameMode.startPrediction(mc.level, sequence -> new ServerboundPlayerActionPacket(ServerboundPlayerActionPacket.Action.START_DESTROY_BLOCK, blockPos, Direction.UP, sequence));
93
        mc.gameMode.startPrediction(mc.level, sequence -> new ServerboundPlayerActionPacket(ServerboundPlayerActionPacket.Action.STOP_DESTROY_BLOCK, blockPos, Direction.UP, sequence));
94
    }
95
96
    private void sendStopPackets(BlockPos blockPos) {
97
        mc.getConnection().send(new ServerboundPlayerActionPacket(ServerboundPlayerActionPacket.Action.ABORT_DESTROY_BLOCK, blockPos, Direction.UP));
98
        mc.getConnection().send(new ServerboundSwingPacket(InteractionHand.MAIN_HAND));
99
    }
100
}
101