burrow module

burrow: Minecraft 26.3 cheat module, full source for every implementation (3 clients: Meteor Client, MelaHack (ThunderHack fork), OfflineClient).

3 implementationsCombatCOMBAT

Full module source: 3 implementations

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/Burrow.javaJava · 244 lines · 9.2 KB

Attempts to clip you into a block.

Settingsblock-to-useinstantautomatictrigger-heightrubberband-heighttimeronly-in-holescenterrotate
Burrow.javaJava · Minecraft 26.2 · 244 lines · 9.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.meteor.KeyInputEvent;
9
import meteordevelopment.meteorclient.events.world.TickEvent;
10
import meteordevelopment.meteorclient.settings.*;
11
import meteordevelopment.meteorclient.systems.modules.Categories;
12
import meteordevelopment.meteorclient.systems.modules.Module;
13
import meteordevelopment.meteorclient.systems.modules.Modules;
14
import meteordevelopment.meteorclient.systems.modules.world.Timer;
15
import meteordevelopment.meteorclient.utils.Utils;
16
import meteordevelopment.meteorclient.utils.misc.input.KeyAction;
17
import meteordevelopment.meteorclient.utils.player.FindItemResult;
18
import meteordevelopment.meteorclient.utils.player.InvUtils;
19
import meteordevelopment.meteorclient.utils.player.PlayerUtils;
20
import meteordevelopment.meteorclient.utils.player.Rotations;
21
import meteordevelopment.orbit.EventHandler;
22
import net.minecraft.core.BlockPos;
23
import net.minecraft.core.Direction;
24
import net.minecraft.network.protocol.game.ServerboundMovePlayerPacket;
25
import net.minecraft.network.protocol.game.ServerboundSwingPacket;
26
import net.minecraft.world.InteractionHand;
27
import net.minecraft.world.item.BlockItem;
28
import net.minecraft.world.item.Items;
29
import net.minecraft.world.level.block.AnvilBlock;
30
import net.minecraft.world.level.block.state.BlockState;
31
import net.minecraft.world.phys.BlockHitResult;
32
33
/**
34
 * @author seasnail8169
35
 */
36
public class Burrow extends Module {
37
    private final SettingGroup sgGeneral = settings.getDefaultGroup();
38
39
    private final Setting<Block> block = sgGeneral.add(new EnumSetting.Builder<Block>()
40
        .name("block-to-use")
41
        .description("The block to use for Burrow.")
42
        .defaultValue(Block.EChest)
43
        .build()
44
    );
45
46
    private final Setting<Boolean> instant = sgGeneral.add(new BoolSetting.Builder()
47
        .name("instant")
48
        .description("Jumps with packets rather than vanilla jump.")
49
        .defaultValue(true)
50
        .build()
51
    );
52
53
    private final Setting<Boolean> automatic = sgGeneral.add(new BoolSetting.Builder()
54
        .name("automatic")
55
        .description("Automatically burrows on activate rather than waiting for jump.")
56
        .defaultValue(true)
57
        .build()
58
    );
59
60
    private final Setting<Double> triggerHeight = sgGeneral.add(new DoubleSetting.Builder()
61
        .name("trigger-height")
62
        .description("How high you have to jump before a rubberband is triggered.")
63
        .defaultValue(1.12)
64
        .range(0.01, 1.4)
65
        .sliderRange(0.01, 1.4)
66
        .build()
67
    );
68
69
    private final Setting<Double> rubberbandHeight = sgGeneral.add(new DoubleSetting.Builder()
70
        .name("rubberband-height")
71
        .description("How far to attempt to cause rubberband.")
72
        .defaultValue(12)
73
        .sliderMin(-30)
74
        .sliderMax(30)
75
        .build()
76
    );
77
78
    private final Setting<Double> timer = sgGeneral.add(new DoubleSetting.Builder()
79
        .name("timer")
80
        .description("Timer override.")
81
        .defaultValue(1)
82
        .min(0.01)
83
        .sliderRange(0.01, 10)
84
        .build()
85
    );
86
87
    private final Setting<Boolean> onlyInHole = sgGeneral.add(new BoolSetting.Builder()
88
        .name("only-in-holes")
89
        .description("Stops you from burrowing when not in a hole.")
90
        .defaultValue(false)
91
        .build()
92
    );
93
94
    private final Setting<Boolean> center = sgGeneral.add(new BoolSetting.Builder()
95
        .name("center")
96
        .description("Centers you to the middle of the block before burrowing.")
97
        .defaultValue(true)
98
        .build()
99
    );
100
101
    private final Setting<Boolean> rotate = sgGeneral.add(new BoolSetting.Builder()
102
        .name("rotate")
103
        .description("Faces the block you place server-side.")
104
        .defaultValue(true)
105
        .build()
106
    );
107
108
    private final BlockPos.MutableBlockPos blockPos = new BlockPos.MutableBlockPos();
109
    private boolean shouldBurrow;
110
111
    public Burrow() {
112
        super(Categories.Combat, "burrow", "Attempts to clip you into a block.");
113
    }
114
115
    @Override
116
    public void onActivate() {
117
        if (!mc.level.getBlockState(mc.player.blockPosition()).canBeReplaced()) {
118
            error("Already burrowed, disabling.");
119
            toggle();
120
            return;
121
        }
122
123
        if (!PlayerUtils.isInHole(false) && onlyInHole.get()) {
124
            error("Not in a hole, disabling.");
125
            toggle();
126
            return;
127
        }
128
129
        if (!checkHead()) {
130
            error("Not enough headroom to burrow, disabling.");
131
            toggle();
132
            return;
133
        }
134
135
        FindItemResult result = getItem();
136
137
        if (!result.isHotbar() && !result.isOffhand()) {
138
            error("No burrow block found, disabling.");
139
            toggle();
140
            return;
141
        }
142
143
        blockPos.set(mc.player.blockPosition());
144
145
        Modules.get().get(Timer.class).setOverride(this.timer.get());
146
147
        shouldBurrow = false;
148
149
        if (automatic.get()) {
150
            if (instant.get()) shouldBurrow = true;
151
            else mc.player.jumpFromGround();
152
        } else {
153
            info("Waiting for manual jump.");
154
        }
155
    }
156
157
    @Override
158
    public void onDeactivate() {
159
        Modules.get().get(Timer.class).setOverride(Timer.OFF);
160
    }
161
162
    @EventHandler
163
    private void onTick(TickEvent.Pre event) {
164
        if (!instant.get()) shouldBurrow = mc.player.getY() > blockPos.getY() + triggerHeight.get();
165
        if (!shouldBurrow && instant.get()) blockPos.set(mc.player.blockPosition());
166
167
        if (shouldBurrow) {
168
            if (rotate.get())
169
                Rotations.rotate(Rotations.getYaw(mc.player.blockPosition()), Rotations.getPitch(mc.player.blockPosition()), 50, this::burrow);
170
            else burrow();
171
172
            toggle();
173
        }
174
    }
175
176
    @EventHandler
177
    private void onKey(KeyInputEvent event) {
178
        if (instant.get() && !shouldBurrow) {
179
            if (event.action == KeyAction.Press && mc.options.keyJump.matches(event.input)) {
180
                shouldBurrow = true;
181
            }
182
            blockPos.set(mc.player.blockPosition());
183
        }
184
    }
185
186
    private void burrow() {
187
        if (center.get()) PlayerUtils.centerPlayer();
188
189
        if (instant.get()) {
190
            mc.player.connection.send(new ServerboundMovePlayerPacket.Pos(mc.player.getX(), mc.player.getY() + 0.4, mc.player.getZ(), false, mc.player.horizontalCollision));
191
            mc.player.connection.send(new ServerboundMovePlayerPacket.Pos(mc.player.getX(), mc.player.getY() + 0.75, mc.player.getZ(), false, mc.player.horizontalCollision));
192
            mc.player.connection.send(new ServerboundMovePlayerPacket.Pos(mc.player.getX(), mc.player.getY() + 1.01, mc.player.getZ(), false, mc.player.horizontalCollision));
193
            mc.player.connection.send(new ServerboundMovePlayerPacket.Pos(mc.player.getX(), mc.player.getY() + 1.15, mc.player.getZ(), false, mc.player.horizontalCollision));
194
        }
195
196
197
        FindItemResult block = getItem();
198
199
        if (!(mc.player.getInventory().getItem(block.slot()).getItem() instanceof BlockItem)) return;
200
        InvUtils.swap(block.slot(), true);
201
202
        mc.gameMode.useItemOn(mc.player, InteractionHand.MAIN_HAND, new BlockHitResult(Utils.vec3(blockPos), Direction.UP, blockPos, false));
203
        mc.player.connection.send(new ServerboundSwingPacket(InteractionHand.MAIN_HAND));
204
205
        InvUtils.swapBack();
206
207
        if (instant.get()) {
208
            mc.player.connection.send(new ServerboundMovePlayerPacket.Pos(mc.player.getX(), mc.player.getY() + rubberbandHeight.get(), mc.player.getZ(), false, mc.player.horizontalCollision));
209
        } else {
210
            mc.player.absSnapTo(mc.player.getX(), mc.player.getY() + rubberbandHeight.get(), mc.player.getZ());
211
        }
212
    }
213
214
    private FindItemResult getItem() {
215
        return switch (block.get()) {
216
            case EChest -> InvUtils.findInHotbar(Items.ENDER_CHEST);
217
            case Anvil ->
218
                InvUtils.findInHotbar(itemStack -> net.minecraft.world.level.block.Block.byItem(itemStack.getItem()) instanceof AnvilBlock);
219
            case Held ->
220
                new FindItemResult(mc.player.getInventory().getSelectedSlot(), mc.player.getMainHandItem().getCount());
221
            default -> InvUtils.findInHotbar(Items.OBSIDIAN, Items.CRYING_OBSIDIAN);
222
        };
223
    }
224
225
    private boolean checkHead() {
226
        BlockState blockState1 = mc.level.getBlockState(blockPos.set(mc.player.getX() + .3, mc.player.getY() + 2.3, mc.player.getZ() + .3));
227
        BlockState blockState2 = mc.level.getBlockState(blockPos.set(mc.player.getX() + .3, mc.player.getY() + 2.3, mc.player.getZ() - .3));
228
        BlockState blockState3 = mc.level.getBlockState(blockPos.set(mc.player.getX() - .3, mc.player.getY() + 2.3, mc.player.getZ() - .3));
229
        BlockState blockState4 = mc.level.getBlockState(blockPos.set(mc.player.getX() - .3, mc.player.getY() + 2.3, mc.player.getZ() + .3));
230
        boolean air1 = blockState1.canBeReplaced();
231
        boolean air2 = blockState2.canBeReplaced();
232
        boolean air3 = blockState3.canBeReplaced();
233
        boolean air4 = blockState4.canBeReplaced();
234
        return air1 && air2 && air3 && air4;
235
    }
236
237
    public enum Block {
238
        EChest,
239
        Obsidian,
240
        Anvil,
241
        Held
242
    }
243
}
244
MelaHack (ThunderHack fork)COMBATsrc/main/java/thunder/hack/features/modules/combat/Burrow.javaJava · 358 lines · 16.3 KB

Puts a block/web/skull into your thighs.

SettingsModeVClipScaleDownScaleVelocityScale-xplosionScaleFactorScaleDelayAttackPlaceDisableWaitEvadeNoVoidOnGroundIgnoreHeadBlockRotateDiscreteAirFallbackSkipZero
Burrow.javaJava · Minecraft 26.2 · 358 lines · 16.3 KB · complete file, verbatimOriginal ↗
1
package thunder.hack.features.modules.combat;
2
3
import meteordevelopment.orbit.EventHandler;
4
import net.minecraft.core.BlockPos;
5
import net.minecraft.core.Direction;
6
import net.minecraft.network.protocol.game.ClientboundExplodePacket;
7
import net.minecraft.network.protocol.game.ClientboundPlayerPositionPacket;
8
import net.minecraft.network.protocol.game.ServerboundInteractPacket;
9
import net.minecraft.network.protocol.game.ServerboundAttackPacket;
10
import net.minecraft.network.protocol.game.ServerboundMovePlayerPacket;
11
import net.minecraft.network.protocol.game.ServerboundSwingPacket;
12
import net.minecraft.world.InteractionHand;
13
import net.minecraft.world.entity.Entity;
14
import net.minecraft.world.entity.Relative;
15
import net.minecraft.world.entity.boss.enderdragon.EndCrystal;
16
import net.minecraft.world.entity.player.Player;
17
import net.minecraft.world.level.block.Blocks;
18
import net.minecraft.world.level.block.state.BlockState;
19
import net.minecraft.world.phys.AABB;
20
import net.minecraft.world.phys.Vec3;
21
import thunder.hack.events.impl.EventPostSync;
22
import thunder.hack.events.impl.PacketEvent;
23
import thunder.hack.features.modules.Module;
24
import thunder.hack.setting.Setting;
25
import thunder.hack.utility.Timer;
26
import thunder.hack.utility.math.MathUtility;
27
import thunder.hack.utility.player.InteractionUtility;
28
import thunder.hack.utility.player.InventoryUtility;
29
import thunder.hack.utility.player.SearchInvResult;
30
31
import java.lang.reflect.Field;
32
33
import static thunder.hack.features.modules.client.ClientSettings.isRu;
34
35
public final class Burrow extends Module {
36
    private final Setting<Mode> mode = new Setting<>("Mode", Mode.Default);
37
    private final Setting<OffsetMode> offsetMode = new Setting<>("Mode", OffsetMode.Smart, v -> mode.getValue() == Mode.Default);
38
    private final Setting<Float> vClip = new Setting<>("VClip", -9.0F, -256.0F, 256.0F, v -> offsetMode.getValue() == OffsetMode.Constant && mode.getValue() == Mode.Default);
39
    private final Setting<Boolean> scaleDown = new Setting<>("ScaleDown", false, v -> mode.getValue() == Mode.Default);
40
    private final Setting<Boolean> scaleVelocity = new Setting<>("ScaleVelocity", false, v -> mode.getValue() == Mode.Default);
41
    private final Setting<Boolean> scaleExplosion = new Setting<>("Scale-xplosion", false, v -> mode.getValue() == Mode.Default);
42
    private final Setting<Float> scaleFactor = new Setting<>("ScaleFactor", 1.0F, 0.1F, 10.0F, v -> mode.getValue() == Mode.Default);
43
    private final Setting<Integer> scaleDelay = new Setting<>("ScaleDelay", 250, 0, 1000, v -> mode.getValue() == Mode.Default);
44
    private final Setting<Boolean> attack = new Setting<>("Attack", true, v -> mode.getValue() == Mode.Default);
45
    private final Setting<Boolean> placeDisable = new Setting<>("PlaceDisable", false, v -> mode.getValue() == Mode.Default);
46
    private final Setting<Boolean> wait = new Setting<>("Wait", true);
47
    private final Setting<Boolean> evade = new Setting<>("Evade", false, v -> offsetMode.getValue() == OffsetMode.Constant && mode.getValue() == Mode.Default);
48
    private final Setting<Boolean> noVoid = new Setting<>("NoVoid", false, v -> offsetMode.getValue() == OffsetMode.Smart && mode.getValue() == Mode.Default);
49
    private final Setting<Boolean> onGround = new Setting<>("OnGround", true, v -> mode.getValue() == Mode.Default);
50
    private final Setting<Boolean> allowUp = new Setting<>("IgnoreHeadBlock", false, v -> mode.getValue() == Mode.Default);
51
    private final Setting<Boolean> rotate = new Setting<>("Rotate", true);
52
    private final Setting<Boolean> discrete = new Setting<>("Discrete", true, v -> offsetMode.getValue() == OffsetMode.Smart && mode.getValue() == Mode.Default);
53
    private final Setting<Boolean> air = new Setting<>("Air", false, v -> offsetMode.getValue() == OffsetMode.Smart && mode.getValue() == Mode.Default);
54
    private final Setting<Boolean> fallback = new Setting<>("Fallback", true, v -> offsetMode.getValue() == OffsetMode.Smart && mode.getValue() == Mode.Default);
55
    private final Setting<Boolean> skipZero = new Setting<>("SkipZero", true, v -> offsetMode.getValue() == OffsetMode.Smart && mode.getValue() == Mode.Default);
56
57
    private double motionY;
58
    private BlockPos startPos;
59
    private volatile double last_x;
60
    private volatile double last_y;
61
    private volatile double last_z;
62
    private final Timer scaleTimer = new Timer();
63
    private final Timer timer = new Timer();
64
65
    public Burrow() {
66
        super("Burrow", Category.COMBAT);
67
    }
68
69
    @Override
70
    public void onEnable() {
71
        startPos = getPlayerPos();
72
    }
73
74
    @EventHandler
75
    public void onPacketReceive(PacketEvent.Receive event) {
76
        if (mode.getValue() != Mode.Default) return;
77
        if (event.getPacket() instanceof ClientboundExplodePacket explosion) {
78
            if (scaleExplosion.getValue()) {
79
                motionY = explosion.playerKnockback().map(vec -> vec.y).orElse(0.0);
80
                scaleTimer.reset();
81
            }
82
            if (scaleVelocity.getValue()) return;
83
            if (mc.player != null) {
84
                motionY = explosion.playerKnockback().map(vec -> vec.y / 8000.0).orElse(0.0);
85
                scaleTimer.reset();
86
            }
87
        }
88
89
        if (event.getPacket() instanceof ClientboundPlayerPositionPacket packet) {
90
            Vec3 position = packet.change().position();
91
            double x = position.x;
92
            double y = position.y;
93
            double z = position.z;
94
95
            if (packet.relatives().contains(Relative.X)) x += mc.player.getX();
96
            if (packet.relatives().contains(Relative.Y)) y += mc.player.getY();
97
            if (packet.relatives().contains(Relative.Z)) z += mc.player.getZ();
98
99
            last_x = MathUtility.clamp(x, -3.0E7, 3.0E7);
100
            last_y = y;
101
            last_z = MathUtility.clamp(z, -3.0E7, 3.0E7);
102
        }
103
    }
104
105
    @EventHandler
106
    public void onPostSync(EventPostSync e) {
107
        if (wait.getValue()) {
108
            BlockPos currentPos = getPlayerPos();
109
            if (!currentPos.equals(startPos)) {
110
                disable(isRu() ? "Отключен из-за движения!" : "Disabled due to movement!");
111
                return;
112
            }
113
        }
114
115
        BlockPos pos = getPosition(mc.player);
116
        if (!mc.level.getBlockState(pos).canBeReplaced()) {
117
            if (!wait.getValue())
118
                disable(isRu() ? "Невозможно поставить блок! Отключаю.." : "Can't place the block! Disabling..");
119
            return;
120
        }
121
122
        for (Entity entity : mc.level.getEntitiesOfClass(Entity.class, new AABB(pos))) {
123
            if (entity != null && !mc.player.equals(entity)) {
124
                if (entity instanceof EndCrystal && attack.getValue()) {
125
                    sendPacket(new ServerboundAttackPacket(entity.getId()));
126
                    sendPacket(new ServerboundSwingPacket(InteractionHand.MAIN_HAND));
127
                    continue;
128
                }
129
                if (!wait.getValue())
130
                    disable(isRu() ? "Невозможно поставить блок! Отключаю.." : "Can't place the block on! Disabling..");
131
                return;
132
            }
133
        }
134
135
        switch (mode.getValue()) {
136
            case Default -> handleDefault(pos);
137
            case Web -> handleWeb(pos);
138
            case Skull -> handleSkull(pos);
139
        }
140
    }
141
142
    private void handleWeb(BlockPos pos) {
143
        SearchInvResult webResult = InventoryUtility.findBlockInHotBar(Blocks.COBWEB);
144
145
        if (!webResult.found()) {
146
            disable(isRu() ? "Нет паутины!" : "No webs found!");
147
            return;
148
        }
149
150
        if (timer.passedMs(250)) {
151
            if (rotate.getValue()) sendPacket(new ServerboundMovePlayerPacket.Rot(mc.player.getYRot(), 90, onGround.getValue(), mc.player.horizontalCollision));
152
153
            InventoryUtility.saveSlot();
154
            InteractionUtility.placeBlock(pos, InteractionUtility.Rotate.None, InteractionUtility.Interact.Vanilla, InteractionUtility.PlaceMode.Packet, webResult.slot(), false, true);
155
            mc.player.swing(InteractionHand.MAIN_HAND);
156
            timer.reset();
157
            InventoryUtility.returnSlot();
158
            if (!wait.getValue() || placeDisable.getValue())
159
                disable(isRu() ? "Успешно забурровился! Отключаю.." : "Successfully burrowed! Disabling..");
160
        }
161
    }
162
163
    private void handleSkull(BlockPos pos) {
164
        SearchInvResult skullResult = InventoryUtility.getSkull();
165
166
        if (!skullResult.found()) {
167
            disable(isRu() ? "Нет голов!" : "No heads found!");
168
            return;
169
        }
170
171
        if (timer.passedMs(250)) {
172
            if (rotate.getValue()) sendPacket(new ServerboundMovePlayerPacket.Rot(mc.player.getYRot(), 90, onGround.getValue(), mc.player.horizontalCollision));
173
            InventoryUtility.saveSlot();
174
            InteractionUtility.placeBlock(pos, InteractionUtility.Rotate.None, InteractionUtility.Interact.Vanilla, InteractionUtility.PlaceMode.Normal, skullResult.slot(), false, true);
175
            mc.player.swing(InteractionHand.MAIN_HAND);
176
            timer.reset();
177
            InventoryUtility.returnSlot();
178
            if (!wait.getValue() || placeDisable.getValue())
179
                disable(isRu() ? "Успешно забурровился! Отключаю.." : "Successfully burrowed! Disabling..");
180
        }
181
    }
182
183
    public void handleDefault(BlockPos pos) {
184
        if ((mc.level.getBlockState(BlockPos.containing(mc.player.position().relative(Direction.UP, 0.2))).isCollisionShapeFullBlock(mc.level, BlockPos.containing(mc.player.position().relative(Direction.UP, 0.2))) || !mc.player.verticalCollision)) {
185
            return;
186
        }
187
188
        Player rEntity = mc.player;
189
190
        BlockPos posHead = getPosition(rEntity).above().above();
191
        if (!mc.level.getBlockState(posHead).canBeReplaced() && wait.getValue()) {
192
            return;
193
        }
194
195
        if (!allowUp.getValue()) {
196
            BlockPos upUp = pos.above(2);
197
            BlockState upState = mc.level.getBlockState(upUp);
198
            if (upState.isCollisionShapeFullBlock(mc.level, upUp)) {
199
                if (!wait.getValue())
200
                    disable(isRu() ? "Над головой блок, невозможно забурровиться! Отключаю.." : "Above the head block, impossible to burrow! Disabling..");
201
                return;
202
            }
203
        }
204
205
        SearchInvResult obbyResult = InventoryUtility.findBlockInHotBar(Blocks.OBSIDIAN);
206
        SearchInvResult echestResult = InventoryUtility.findBlockInHotBar(Blocks.ENDER_CHEST);
207
208
        int slot = (!obbyResult.found() || mc.level.getBlockState(pos.below()).getBlock() == Blocks.ENDER_CHEST ? echestResult.slot() : obbyResult.slot());
209
        if (slot == -1) {
210
            disable(isRu() ? "Нет блоков!" : "No Block found!");
211
            return;
212
        }
213
214
        double y = applyScale(getY(rEntity, offsetMode.getValue()));
215
        if (Double.isNaN(y)) {
216
            return;
217
        }
218
219
        float[] r = InteractionUtility.getPlaceAngle(pos, InteractionUtility.Interact.Strict, true);
220
221
        if (mc.isLocalServer()) {
222
            disable(isRu() ? "Дебил! Ты в одиночке.." : "Retard! You're in singleplayer..");
223
            return;
224
        }
225
226
        if (timer.passedMs(1000)) {
227
            if (rotate.getValue()) {
228
                if (r != null) {
229
                    if (rEntity.position().equals(new Vec3(last_x, last_y, last_z))) sendPacket(new ServerboundMovePlayerPacket.Rot(r[0], r[1], onGround.getValue(), mc.player.horizontalCollision));
230
                    else sendPacket(new ServerboundMovePlayerPacket.PosRot(rEntity.getX(), rEntity.getY(), rEntity.getZ(), r[0], r[1], onGround.getValue(), mc.player.horizontalCollision));
231
                }
232
            }
233
234
            sendPacket(new ServerboundMovePlayerPacket.Pos(rEntity.getX(), rEntity.getY() + 0.42, rEntity.getZ(), onGround.getValue(), mc.player.horizontalCollision));
235
            sendPacket(new ServerboundMovePlayerPacket.Pos(rEntity.getX(), rEntity.getY() + 0.75, rEntity.getZ(), onGround.getValue(), mc.player.horizontalCollision));
236
            sendPacket(new ServerboundMovePlayerPacket.Pos(rEntity.getX(), rEntity.getY() + 1.01, rEntity.getZ(), onGround.getValue(), mc.player.horizontalCollision));
237
            sendPacket(new ServerboundMovePlayerPacket.Pos(rEntity.getX(), rEntity.getY() + 1.16, rEntity.getZ(), onGround.getValue(), mc.player.horizontalCollision));
238
239
            InventoryUtility.saveSlot();
240
            InteractionUtility.placeBlock(pos, InteractionUtility.Rotate.None, InteractionUtility.Interact.Vanilla, InteractionUtility.PlaceMode.Packet, slot, false, true);
241
            mc.player.swing(InteractionHand.MAIN_HAND);
242
            sendPacket(new ServerboundMovePlayerPacket.Pos(rEntity.getX(), y, rEntity.getZ(), false, mc.player.horizontalCollision));
243
            timer.reset();
244
            InventoryUtility.returnSlot();
245
246
            if (!wait.getValue() || placeDisable.getValue())
247
                disable(isRu() ? "Успешно забурровился! Отключаю.." : "Successfully burrowed! Disabling..");
248
        }
249
    }
250
251
    public static void changeId(ServerboundInteractPacket packet, int id) {
252
        try {
253
            Field field = ServerboundInteractPacket.class.getDeclaredField("field_12870");
254
            field.setAccessible(true);
255
            field.setInt(packet, id);
256
        } catch (Exception ignored) {
257
        }
258
    }
259
260
    public double getY(Entity entity, OffsetMode mode) {
261
        if (mode == OffsetMode.Constant) {
262
            double y = entity.getY() + vClip.getValue();
263
            if (evade.getValue() && Math.abs(y) < 1) {
264
                y = -1;
265
            }
266
            return y;
267
        }
268
269
        double d = getY(entity, 3, 10, true);
270
        if (Double.isNaN(d)) {
271
            d = getY(entity, -3, -10, false);
272
            if (Double.isNaN(d)) {
273
                if (fallback.getValue()) {
274
                    return getY(entity, OffsetMode.Constant);
275
                }
276
            }
277
        }
278
279
        return d;
280
    }
281
282
    public static BlockPos getPosition(Entity entity) {
283
        double y = entity.getY();
284
        if (entity.getY() - Math.floor(entity.getY()) > 0.5) {
285
            y = Math.ceil(entity.getY());
286
        }
287
288
        return BlockPos.containing(entity.getX(), y, entity.getZ());
289
    }
290
291
    public double getY(Entity entity, double min, double max, boolean add) {
292
        if (min > max && add || max > min && !add) {
293
            return Double.NaN;
294
        }
295
296
        double x = entity.getX();
297
        double y = entity.getY();
298
        double z = entity.getZ();
299
300
        boolean air = false;
301
        double lastOff = 0.0;
302
        BlockPos last = null;
303
        for (double off = min; add ? off < max : off > max; off = (add ? ++off : --off)) {
304
            BlockPos pos = BlockPos.containing(x, y - off, z);
305
            if (noVoid.getValue() && pos.getY() < 0) {
306
                continue;
307
            }
308
309
            if (skipZero.getValue() && Math.abs(y) < 1) {
310
                air = false;
311
                last = pos;
312
                lastOff = y - off;
313
                continue;
314
            }
315
316
            BlockState state = mc.level.getBlockState(pos);
317
            if (!this.air.getValue() && !state.isCollisionShapeFullBlock(mc.level, pos) || state.getBlock() == Blocks.AIR) {
318
                if (air) {
319
                    if (add) return discrete.getValue() ? pos.getY() : y - off;
320
                    else return discrete.getValue() ? last.getY() : lastOff;
321
                }
322
                air = true;
323
            } else air = false;
324
            last = pos;
325
            lastOff = y - off;
326
        }
327
328
        return Double.NaN;
329
    }
330
331
    protected double applyScale(double value) {
332
        if (value < mc.player.getY() && !scaleDown.getValue()
333
                || !scaleExplosion.getValue() && !scaleVelocity.getValue()
334
                || scaleTimer.passedMs(scaleDelay.getValue())
335
                || motionY == 0.0) {
336
            return value;
337
        }
338
339
        if (value < mc.player.getY()) value -= (motionY * scaleFactor.getValue());
340
        else value += (motionY * scaleFactor.getValue());
341
342
        return discrete.getValue() ? Math.floor(value) : value;
343
    }
344
345
    public static BlockPos getPlayerPos() {
346
        return Math.abs(mc.player.getDeltaMovement().y()) > 0.1 ? BlockPos.containing(mc.player.position()) : getPosition(mc.player);
347
    }
348
349
    public enum OffsetMode {
350
        Constant,
351
        Smart
352
    }
353
354
    private enum Mode {
355
        Default, Skull, Web
356
    }
357
}
358
OfflineClientCOMBATsrc/main/java/com/jellypudding/offlineclient/modules/combat/Burrow.javaJava · 226 lines · 8.4 KB

Places a blast proof block inside your own hitbox.

SettingsBlockBlocksLiftAutomaticTrigger heightRubberband heightTimerOnly in holesCentreRotate
Burrow.javaJava · Minecraft 26.2 · 226 lines · 8.4 KB · complete file, verbatimOriginal ↗
1
package com.jellypudding.offlineclient.modules.combat;
2
3
import com.jellypudding.offlineclient.event.Subscribe;
4
import com.jellypudding.offlineclient.event.events.KeyPressEvent;
5
import com.jellypudding.offlineclient.event.events.TickEvent;
6
import com.jellypudding.offlineclient.module.Category;
7
import com.jellypudding.offlineclient.module.Module;
8
import com.jellypudding.offlineclient.modules.misc.Timer;
9
import com.jellypudding.offlineclient.setting.BoolSetting;
10
import com.jellypudding.offlineclient.setting.EnumSetting;
11
import com.jellypudding.offlineclient.setting.NumberSetting;
12
import com.jellypudding.offlineclient.setting.RegistryListSetting;
13
import com.jellypudding.offlineclient.util.BlockUtil;
14
import com.jellypudding.offlineclient.util.ChatUtil;
15
import com.jellypudding.offlineclient.util.InputUtil;
16
import com.jellypudding.offlineclient.util.InventoryUtil;
17
import com.jellypudding.offlineclient.util.InventoryUtil.SlotSwap;
18
import net.minecraft.core.BlockPos;
19
import net.minecraft.core.registries.BuiltInRegistries;
20
import net.minecraft.network.protocol.game.ServerboundMovePlayerPacket;
21
import net.minecraft.world.item.BlockItem;
22
import net.minecraft.world.level.block.Block;
23
import net.minecraft.world.level.block.Blocks;
24
import org.lwjgl.glfw.GLFW;
25
26
import java.util.List;
27
28
public final class Burrow extends Module {
29
30
    // Rungs of the packet lift. The last one clears the block completely.
31
    private static final double[] LIFT = {0.42, 0.75, 1.01, 1.16};
32
33
    private static final int JUMP_TIMEOUT = 20;
34
35
    private static final String TIMER_KEY = "burrow";
36
37
    public enum Lift { JUMP, PACKET }
38
39
    public enum Source { LIST, HELD }
40
41
    private final EnumSetting<Source> source = new EnumSetting<>("Block",
42
        "Where the block comes from.", Source.LIST)
43
        .describe(Source.LIST, "The first block from the list below that is in your hotbar.")
44
        .describe(Source.HELD, "Whatever block is in your main hand.");
45
    private final RegistryListSetting<Block> blocks = new RegistryListSetting<>("Blocks",
46
        "Blocks to use in order of preference.",
47
        BuiltInRegistries.BLOCK,
48
        List.of(Blocks.OBSIDIAN, Blocks.CRYING_OBSIDIAN, Blocks.ENDER_CHEST));
49
    private final EnumSetting<Lift> lift = new EnumSetting<>("Lift",
50
        "How to get above the block as it goes in.", Lift.PACKET)
51
        .describe(Lift.JUMP, "Jumps for real.")
52
        .describe(Lift.PACKET, "Sends position packets to hop up without moving on screen.");
53
    private final BoolSetting automatic = new BoolSetting("Automatic",
54
        "Burrow the moment the module turns on. Off waits for you to press jump.", true);
55
    private final NumberSetting triggerHeight = new NumberSetting("Trigger height",
56
        "How high a jump has to carry you before the block goes in.", 1.02, 0.01, 1.4, 0.01, " blocks")
57
        .under(lift, Lift.JUMP);
58
    private final NumberSetting rubberband = new NumberSetting("Rubberband height",
59
        "Size of the refused move that puts you back inside the block.", 12, -30, 30, 1, " blocks");
60
    private final NumberSetting timer = new NumberSetting("Timer",
61
        "Game speed whilst the module runs. One leaves it alone.", 1, 1, 10, 0.5, "x");
62
    private final BoolSetting onlyInHoles = new BoolSetting("Only in holes",
63
        "Refuse to burrow unless you stand in a blast proof hole.", false);
64
    private final BoolSetting center = new BoolSetting("Centre",
65
        "Snap to the middle of your block first.", true);
66
    private final BoolSetting rotate = new BoolSetting("Rotate",
67
        "Send a look packet towards the block as it goes down.", true);
68
69
    private final SlotSwap slots = new SlotSwap();
70
    private BlockPos anchor;
71
    private int waited;
72
73
    // True once the burrow has been set off. Manual mode waits for the jump key.
74
    private boolean armed;
75
76
    public Burrow() {
77
        super("Burrow", "Places a blast proof block inside your own hitbox.", Category.COMBAT);
78
        blocks.under(source, Source.LIST);
79
        addSettings(source, blocks, lift, automatic, triggerHeight, rubberband, timer,
80
            onlyInHoles, center, rotate);
81
        searchTags("clip", "obsidian", "crystal", "hole");
82
    }
83
84
    @Override
85
    public boolean savesEnabledState() {
86
        return false;
87
    }
88
89
    @Override
90
    protected void onEnable() {
91
        waited = 0;
92
        anchor = null;
93
        armed = false;
94
        slots.forget();
95
        if (!inGame() || mc.player.isSpectator()) {
96
            setEnabled(false);
97
            return;
98
        }
99
        BlockPos feet = mc.player.blockPosition();
100
        if (!BlockUtil.isReplaceable(feet)) {
101
            ChatUtil.error("Already inside a block.");
102
            setEnabled(false);
103
            return;
104
        }
105
        if (!headroom(feet)) {
106
            ChatUtil.error("Not enough room above to burrow.");
107
            setEnabled(false);
108
            return;
109
        }
110
        if (onlyInHoles.isOn() && !BlockUtil.playerInHole()) {
111
            ChatUtil.error("Not in a hole.");
112
            setEnabled(false);
113
            return;
114
        }
115
        if (findSlot() == -1) {
116
            ChatUtil.error(source.is(Source.HELD)
117
                ? "No block in your main hand." : "No burrow block in your hotbar.");
118
            setEnabled(false);
119
            return;
120
        }
121
        anchor = feet;
122
        Timer.override(TIMER_KEY, timer.getFloat());
123
        if (!automatic.isOn()) {
124
            ChatUtil.message("Waiting for a jump.");
125
            return;
126
        }
127
        arm();
128
    }
129
130
    @Override
131
    protected void onDisable() {
132
        Timer.override(TIMER_KEY, 1f);
133
    }
134
135
    // Sets the burrow off. A real jump starts here and the packet lift needs nothing yet.
136
    private void arm() {
137
        armed = true;
138
        waited = 0;
139
        if (lift.is(Lift.JUMP) && mc.player.onGround()) {
140
            mc.player.jumpFromGround();
141
        }
142
    }
143
144
    // Manual mode goes off the jump key. Vanilla jumps on the same press.
145
    @Subscribe
146
    private void onKeyPress(KeyPressEvent event) {
147
        if (!inGame() || armed || event.getAction() != GLFW.GLFW_PRESS || mc.gui.screen() != null) {
148
            return;
149
        }
150
        if (InputUtil.isKey(mc.options.keyJump, event.getKey())) {
151
            anchor = mc.player.blockPosition();
152
            arm();
153
        }
154
    }
155
156
    @Subscribe
157
    private void onTick(TickEvent event) {
158
        if (!inGame() || mc.player.isSpectator() || anchor == null) {
159
            setEnabled(false);
160
            return;
161
        }
162
        if (!armed) {
163
            // The player may walk to another block before the jump.
164
            if (mc.player.onGround()) {
165
                anchor = mc.player.blockPosition();
166
            }
167
            return;
168
        }
169
        if (lift.is(Lift.JUMP) && mc.player.getY() < anchor.getY() + triggerHeight.getValue()) {
170
            if (++waited > JUMP_TIMEOUT) {
171
                ChatUtil.error("Could not get high enough to burrow.");
172
                setEnabled(false);
173
            }
174
            return;
175
        }
176
        burrow();
177
        setEnabled(false);
178
    }
179
180
    private void burrow() {
181
        if (center.isOn()) {
182
            BlockUtil.centerPlayer();
183
        }
184
        if (lift.is(Lift.PACKET)) {
185
            for (double step : LIFT) {
186
                sendLift(step);
187
            }
188
        }
189
190
        int slot = findSlot();
191
        if (slot == -1) {
192
            ChatUtil.error("No burrow block to hand.");
193
            return;
194
        }
195
        slots.select(slot);
196
        // The local placement is refused but the packet still goes out. The server
197
        // has the player up on the lift by then.
198
        BlockUtil.placeDirect(anchor, rotate.isOn(), true);
199
        slots.restore();
200
201
        if (lift.is(Lift.PACKET)) {
202
            sendLift(rubberband.getValue());
203
        } else {
204
            mc.player.absSnapTo(mc.player.getX(), mc.player.getY() + rubberband.getValue(), mc.player.getZ());
205
        }
206
    }
207
208
    private void sendLift(double offset) {
209
        mc.player.connection.send(new ServerboundMovePlayerPacket.Pos(
210
            mc.player.getX(), mc.player.getY() + offset, mc.player.getZ(),
211
            false, mc.player.horizontalCollision));
212
    }
213
214
    private static boolean headroom(BlockPos feet) {
215
        return BlockUtil.isReplaceable(feet.above()) && BlockUtil.isReplaceable(feet.above(2));
216
    }
217
218
    private int findSlot() {
219
        if (source.is(Source.HELD)) {
220
            return mc.player.getMainHandItem().getItem() instanceof BlockItem
221
                ? InventoryUtil.selectedSlot() : -1;
222
        }
223
        return BlockUtil.findRankedBlockSlot(blocks.getValue(), block -> true);
224
    }
225
}
226