SpeedMine module

SpeedMine: Minecraft 26.3 cheat module, full source for every implementation (1 client: MelaHack (ThunderHack fork)).

1 implementationPLAYER

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.

MelaHack (ThunderHack fork)PLAYERsrc/main/java/thunder/hack/features/modules/player/SpeedMine.javaJava · 540 lines · 23.5 KB

Increases your mining speed (not hashrate).

SettingsModeDoubleMineStartModeSwitchModeSwapDelayFactorSpeedRangeRotatePlaceCrystalResetOnSwitchBreakAttemptsPause On EatClientRemovePacketsStopAbortStartStop2RenderSmoothRender ModeStart Line ColorEnd Line ColorLine WidthStart Fill ColorEnd Fill Color
SpeedMine.javaJava · Minecraft 26.2 · 540 lines · 23.5 KB · complete file, verbatimOriginal ↗
1
package thunder.hack.features.modules.player;
2
3
import meteordevelopment.orbit.EventHandler;
4
import meteordevelopment.orbit.EventPriority;
5
import net.minecraft.core.BlockPos;
6
import net.minecraft.core.Direction;
7
import net.minecraft.core.registries.Registries;
8
import net.minecraft.network.protocol.game.ServerboundContainerClosePacket;
9
import net.minecraft.network.protocol.game.ServerboundPlayerActionPacket;
10
import net.minecraft.network.protocol.game.ServerboundSetCarriedItemPacket;
11
import net.minecraft.world.InteractionHand;
12
import net.minecraft.world.effect.MobEffects;
13
import net.minecraft.world.entity.Entity;
14
import net.minecraft.world.entity.ai.attributes.Attributes;
15
import net.minecraft.world.entity.item.ItemEntity;
16
import net.minecraft.world.inventory.ContainerInput;
17
import net.minecraft.world.item.ItemStack;
18
import net.minecraft.world.item.enchantment.EnchantmentHelper;
19
import net.minecraft.world.item.enchantment.Enchantments;
20
import net.minecraft.world.level.block.AirBlock;
21
import net.minecraft.world.level.block.Block;
22
import net.minecraft.world.level.block.Blocks;
23
import net.minecraft.world.level.block.state.BlockState;
24
import net.minecraft.world.phys.AABB;
25
import org.jetbrains.annotations.NotNull;
26
import org.jetbrains.annotations.Nullable;
27
import thunder.hack.core.Managers;
28
import thunder.hack.core.manager.client.ModuleManager;
29
import thunder.hack.core.manager.player.PlayerManager;
30
import thunder.hack.events.impl.EventAttackBlock;
31
import thunder.hack.events.impl.EventSync;
32
import thunder.hack.events.impl.PacketEvent;
33
import thunder.hack.features.modules.Module;
34
import thunder.hack.features.modules.combat.AutoCrystal;
35
import thunder.hack.injection.accesors.IInteractionManager;
36
import thunder.hack.setting.Setting;
37
import thunder.hack.setting.impl.BooleanSettingGroup;
38
import thunder.hack.setting.impl.ColorSetting;
39
import thunder.hack.setting.impl.SettingGroup;
40
import thunder.hack.utility.Timer;
41
import thunder.hack.utility.math.MathUtility;
42
import thunder.hack.utility.player.InteractionUtility;
43
import thunder.hack.utility.player.InventoryUtility;
44
import thunder.hack.utility.player.PlayerUtility;
45
import thunder.hack.utility.render.Render2DEngine;
46
import thunder.hack.utility.render.Render3DEngine;
47
import thunder.hack.utility.world.ExplosionUtility;
48
import com.mojang.blaze3d.vertex.PoseStack;
49
import java.awt.*;
50
import java.util.ArrayList;
51
import java.util.Objects;
52
53
public final class SpeedMine extends Module {
54
    public SpeedMine() {
55
        super("SpeedMine", Category.PLAYER);
56
    }
57
58
    public final Setting<Mode> mode = new Setting<>("Mode", Mode.Packet);
59
    public final Setting<Boolean> doubleMine = new Setting<>("DoubleMine", false);
60
    private final Setting<StartMode> startMode = new Setting<>("StartMode", StartMode.StartAbort, v -> mode.is(Mode.Packet) && !doubleMine.getValue());
61
    private final Setting<SwitchMode> switchMode = new Setting<>("SwitchMode", SwitchMode.Alternative, v -> mode.not(Mode.Damage));
62
    private final Setting<Integer> swapDelay = new Setting<>("SwapDelay", 50, 0, 1000, v -> mode.getValue() != Mode.Damage);
63
    private final Setting<Float> factor = new Setting<>("Factor", 1f, 0.5f, 2f, v -> mode.getValue() != Mode.Damage);
64
    private final Setting<Float> speed = new Setting<>("Speed", 0.5f, 0f, 1f, v -> mode.getValue() == Mode.Damage);
65
    public final Setting<Float> range = new Setting<>("Range", 4.2f, 3.0f, 10.0f, v -> mode.getValue() != Mode.Damage);
66
    private final Setting<Boolean> rotate = new Setting<>("Rotate", false, v -> mode.getValue() != Mode.Damage);
67
    private final Setting<Boolean> placeCrystal = new Setting<>("PlaceCrystal", true);
68
    private final Setting<Boolean> resetOnSwitch = new Setting<>("ResetOnSwitch", true, v -> mode.getValue() != Mode.Damage);
69
    private final Setting<Integer> breakAttempts = new Setting<>("BreakAttempts", 10, 1, 50, v -> mode.getValue() == Mode.Packet);
70
    private final Setting<Boolean> pauseEat = new Setting<>("Pause On Eat", false);
71
    private final Setting<Boolean> clientRemove = new Setting<>("ClientRemove", true);
72
73
    private final Setting<SettingGroup> packets = new Setting<>("Packets", new SettingGroup(false, 0), v -> mode.is(Mode.Packet) && !doubleMine.getValue());
74
    private final Setting<Boolean> stop = new Setting<>("Stop", true, v -> mode.is(Mode.Packet) && !doubleMine.getValue()).addToGroup(packets);
75
    private final Setting<Boolean> abort = new Setting<>("Abort", true, v -> mode.is(Mode.Packet) && !doubleMine.getValue()).addToGroup(packets);
76
    private final Setting<Boolean> start = new Setting<>("Start", true, v -> mode.is(Mode.Packet) && !doubleMine.getValue()).addToGroup(packets);
77
    private final Setting<Boolean> stop2 = new Setting<>("Stop2", true, v -> mode.is(Mode.Packet) && !doubleMine.getValue()).addToGroup(packets);
78
79
    private final Setting<BooleanSettingGroup> render = new Setting<>("Render", new BooleanSettingGroup(false), v -> mode.getValue() != Mode.Damage);
80
    private final Setting<Boolean> smooth = new Setting<>("Smooth", true, v -> mode.getValue() != Mode.Damage).addToGroup(render);
81
    private final Setting<RenderMode> renderMode = new Setting<>("Render Mode", RenderMode.Shrink, v -> mode.getValue() != Mode.Damage).addToGroup(render);
82
    private final Setting<ColorSetting> startLineColor = new Setting<>("Start Line Color", new ColorSetting(new Color(255, 0, 0, 200)), v -> mode.getValue() != Mode.Damage).addToGroup(render);
83
    private final Setting<ColorSetting> endLineColor = new Setting<>("End Line Color", new ColorSetting(new Color(47, 255, 0, 200)), v -> mode.getValue() != Mode.Damage).addToGroup(render);
84
    private final Setting<Integer> lineWidth = new Setting<>("Line Width", 2, 1, 10, v -> mode.getValue() != Mode.Damage).addToGroup(render);
85
    private final Setting<ColorSetting> startFillColor = new Setting<>("Start Fill Color", new ColorSetting(new Color(255, 0, 0, 120)), v -> mode.getValue() != Mode.Damage).addToGroup(render);
86
    private final Setting<ColorSetting> endFillColor = new Setting<>("End Fill Color", new ColorSetting(new Color(47, 255, 0, 120)), v -> mode.getValue() != Mode.Damage).addToGroup(render);
87
88
89
    public ArrayList<MineAction> actions = new ArrayList<>();
90
91
    @Override
92
    public void onDisable() {
93
        actions.forEach(MineAction::reset);
94
        actions.clear();
95
    }
96
97
    @Override
98
    public void onEnable() {
99
        actions.forEach(MineAction::reset);
100
        actions.clear();
101
    }
102
103
    @Override
104
    public void onUpdate() {
105
        if (fullNullCheck() || mc.player.getAbilities().instabuild)
106
            return;
107
108
        if (PlayerUtility.isEating() && pauseEat.getValue()) return;
109
110
        if (mode.getValue() == Mode.Damage)
111
            if (((IInteractionManager) mc.gameMode).getCurBlockDamageMP() < speed.getValue())
112
                ((IInteractionManager) mc.gameMode).setCurBlockDamageMP(speed.getValue());
113
114
        actions.removeIf(MineAction::update);
115
    }
116
117
    @Override
118
    public void onRender3D(PoseStack stack) {
119
        if (mode.is(Mode.Damage) || mc.level == null)
120
            return;
121
122
        actions.forEach(a -> {
123
            if (!mc.level.isEmptyBlock(a.getPos())) {
124
                float noom = (float) MathUtility.clamp(Render2DEngine.interpolate(a.getPrevProgress(), a.getProgress(), Render3DEngine.getTickDelta()), 0f, 1f);
125
                AABB renderBox =
126
127
                        switch (renderMode.getValue()) {
128
                            case Block -> new AABB(a.getPos());
129
                            case Grow ->
130
                                    new AABB(a.getPos().getX(), a.getPos().getY(), a.getPos().getZ(), a.getPos().getX() + 1, a.getPos().getY() + noom, a.getPos().getZ() + 1);
131
                            case Shrink ->
132
                                    new AABB(a.getPos().getX(), a.getPos().getY(), a.getPos().getZ(), a.getPos().getX(), a.getPos().getY(), a.getPos().getZ())
133
                                            .contract(noom, noom, noom)
134
                                            .move(0.5 + noom * 0.5, 0.5 + noom * 0.5, 0.5 + noom * 0.5);
135
                        };
136
137
                Render3DEngine.FILLED_QUEUE.add(new Render3DEngine.FillAction(
138
                        renderBox,
139
                        Render2DEngine.getColor(startFillColor.getValue().getColorObject(), endFillColor.getValue().getColorObject(), a.getProgress(), smooth.getValue())
140
                ));
141
142
                Render3DEngine.OUTLINE_QUEUE.add(new Render3DEngine.OutlineAction(
143
                        renderBox,
144
                        Render2DEngine.getColor(startLineColor.getValue().getColorObject(), endLineColor.getValue().getColorObject(), a.getProgress(), smooth.getValue()),
145
                        lineWidth.getValue()
146
                ));
147
            }
148
        });
149
    }
150
151
    @EventHandler
152
    @SuppressWarnings("unused")
153
    public void onAttackBlock(@NotNull EventAttackBlock event) {
154
        if (fullNullCheck() || !canBreak(event.getBlockPos()) || mc.player.getAbilities().instabuild || mode.is(Mode.Damage))
155
            return;
156
157
        if (!alreadyActing(event.getBlockPos())) {
158
            if (!doubleMine.getValue() || actions.size() >= 2) {
159
                if (!actions.isEmpty())
160
                    actions.removeFirst().cancel();
161
            }
162
163
            actions.add(new MineAction(event.getBlockPos(), event.getEnumFacing()));
164
        }
165
166
        event.cancel();
167
    }
168
169
    public boolean alreadyActing(BlockPos blockPos) {
170
        return actions.stream().anyMatch(a -> a.pos.equals(blockPos));
171
    }
172
173
    @SuppressWarnings("unused")
174
    @EventHandler(priority = EventPriority.LOW)
175
    private void onSync(EventSync event) {
176
        actions.forEach(MineAction::onSync);
177
    }
178
179
    @EventHandler
180
    @SuppressWarnings("unused")
181
    private void onPacketSend(PacketEvent.@NotNull SendPost e) {
182
        if (e.getPacket() instanceof ServerboundSetCarriedItemPacket && resetOnSwitch.getValue() && !switchMode.is(SwitchMode.Silent) && !mode.is(Mode.GrimInstant))
183
            actions.forEach(MineAction::reset);
184
    }
185
186
    private void closeScreen() {
187
        if (mc.player == null) return;
188
189
        sendPacket(new ServerboundContainerClosePacket(mc.player.containerMenu.containerId));
190
    }
191
192
    public float getBlockStrength(@NotNull BlockState state, BlockPos position) {
193
        if (state == Blocks.AIR.defaultBlockState())
194
            return 0.02f;
195
196
        float hardness = state.getDestroySpeed(mc.level, position);
197
198
        if (hardness < 0)
199
            return 0;
200
201
        return getDigSpeed(state, position) / hardness / (canBreak(position) ? 30f : 100f);
202
    }
203
204
    private float getDestroySpeed(BlockPos position, BlockState state) {
205
        float destroySpeed = 1;
206
        int slot = getTool(position);
207
208
        if (mc.player == null)
209
            return 0;
210
        if (slot != -1 && mc.player.getInventory().getItem(slot) != null && !mc.player.getInventory().getItem(slot).isEmpty()) {
211
            destroySpeed *= mc.player.getInventory().getItem(slot).getDestroySpeed(state);
212
        }
213
214
        return destroySpeed;
215
    }
216
217
    public float getDigSpeed(BlockState state, BlockPos position) {
218
        if (mc.player == null) return 0;
219
        float digSpeed = getDestroySpeed(position, state);
220
221
        if (digSpeed > 1) {
222
            int slot = getTool(position);
223
            if (slot != -1) {
224
                ItemStack itemstack = mc.player.getInventory().getItem(slot);
225
                int efficiencyModifier = EnchantmentHelper.getItemEnchantmentLevel(mc.level.registryAccess().lookupOrThrow(Registries.ENCHANTMENT).getOrThrow(Enchantments.EFFICIENCY), itemstack);
226
                if (efficiencyModifier > 0 && !itemstack.isEmpty()) {
227
                    digSpeed += (float) (StrictMath.pow(efficiencyModifier, 2) + 1);
228
                }
229
            }
230
        }
231
232
        if (mc.player.hasEffect(MobEffects.HASTE))
233
            digSpeed *= 1 + (Objects.requireNonNull(mc.player.getEffect(MobEffects.HASTE)).getAmplifier() + 1) * 0.2F;
234
235
236
        if (mc.player.hasEffect(MobEffects.MINING_FATIGUE))
237
            digSpeed *= (float) Math.pow(0.3f, Objects.requireNonNull(mc.player.getEffect(MobEffects.MINING_FATIGUE)).getAmplifier() + 1);
238
239
240
        if (mc.player.isUnderWater())
241
            digSpeed *= (float) mc.player.getAttribute(Attributes.SUBMERGED_MINING_SPEED).getValue();
242
243
        if (!mc.player.onGround() && ModuleManager.freeCam.isDisabled())
244
            digSpeed /= 5;
245
246
        return digSpeed < 0 ? 0 : digSpeed * factor.getValue();
247
    }
248
249
    public int getTool(final BlockPos pos) {
250
        int index = -1;
251
        float currentFastest = 1.f;
252
253
        if (mc.level == null
254
                || mc.player == null
255
                || mc.level.getBlockState(pos).getBlock() instanceof AirBlock)
256
            return -1;
257
258
        for (int i = 9; i < 45; ++i) {
259
            final ItemStack stack = mc.player.getInventory().getItem(i >= 36 ? i - 36 : i);
260
261
            if (stack != ItemStack.EMPTY) {
262
                if (!(stack.getMaxDamage() - stack.getDamageValue() > 10))
263
                    continue;
264
265
                final float digSpeed = EnchantmentHelper.getItemEnchantmentLevel(mc.level.registryAccess().lookupOrThrow(Registries.ENCHANTMENT).getOrThrow(Enchantments.EFFICIENCY), stack);
266
                final float destroySpeed = stack.getDestroySpeed(mc.level.getBlockState(pos));
267
268
                if (digSpeed + destroySpeed > currentFastest) {
269
                    currentFastest = digSpeed + destroySpeed;
270
                    index = i;
271
                }
272
            }
273
        }
274
275
        return index >= 36 ? index - 36 : index;
276
    }
277
278
    private boolean canBreak(BlockPos pos) {
279
        if (mc.level == null || PlayerUtility.squaredDistanceFromEyes(net.minecraft.world.phys.Vec3.atBottomCenterOf(pos)) > range.getPow2Value())
280
            return false;
281
282
        final BlockState blockState = mc.level.getBlockState(pos);
283
        final Block block = blockState.getBlock();
284
        return block.defaultDestroyTime() != -1;
285
    }
286
287
    public void placeCrystal() {
288
        if (AutoCrystal.target == null)
289
            return;
290
291
        AutoCrystal.PlaceData data = getCevData();
292
293
        if (data == null)
294
            data = getBestData();
295
296
        if (data != null) {
297
            ModuleManager.autoCrystal.placeCrystal(data.bhr(), true, false);
298
            debug("placing..");
299
            ModuleManager.autoTrap.pause();
300
            ModuleManager.breaker.pause();
301
        }
302
    }
303
304
    public AutoCrystal.@Nullable PlaceData getCevData() {
305
306
        for (MineAction action : actions) {
307
            if (mc.level.isEmptyBlock(action.getPos().below())) {
308
                if (ExplosionUtility.getSelfExplosionDamage(net.minecraft.world.phys.Vec3.atBottomCenterOf(action.getPos()).add(0, 0.5, 0), 0, false) > ModuleManager.autoCrystal.maxSelfDamage.getValue())
309
                    return null;
310
311
                return ModuleManager.autoCrystal.getPlaceData(action.getPos(), null, mc.player.position());
312
            }
313
        }
314
        return null;
315
    }
316
317
    public AutoCrystal.@Nullable PlaceData getBestData() {
318
        for (MineAction action : actions) {
319
            BlockState prevState = mc.level.getBlockState(action.getPos());
320
            mc.level.setBlockAndUpdate(action.getPos(), Blocks.AIR.defaultBlockState());
321
322
            for (Direction dir : Direction.values()) {
323
                if (dir == Direction.UP || dir == Direction.DOWN) continue;
324
                if (ExplosionUtility.getSelfExplosionDamage(net.minecraft.world.phys.Vec3.atBottomCenterOf(action.getPos().below().relative(dir)).add(0, 0.5, 0), 0, false) > ModuleManager.autoCrystal.maxSelfDamage.getValue())
325
                    continue;
326
327
                AutoCrystal.PlaceData autoMineData = ModuleManager.autoCrystal.getPlaceData(action.getPos().below().relative(dir), null, mc.player.position());
328
                if (autoMineData != null) {
329
                    mc.level.setBlockAndUpdate(action.getPos(), prevState);
330
                    return autoMineData;
331
                }
332
            }
333
334
            float selfDmg = ExplosionUtility.getSelfExplosionDamage(net.minecraft.world.phys.Vec3.atBottomCenterOf(action.getPos()).add(0, 0.5, 0), 0, false);
335
            mc.level.setBlockAndUpdate(action.getPos(), prevState);
336
337
            AutoCrystal.PlaceData autoMineData = ModuleManager.autoCrystal.getPlaceData(action.getPos(), null, mc.player.position());
338
            if (selfDmg > ModuleManager.autoCrystal.maxSelfDamage.getValue())
339
                continue;
340
341
            return autoMineData;
342
        }
343
344
        return null;
345
    }
346
347
    public boolean isBlockDrop(Entity ent) {
348
        if (ent instanceof ItemEntity && isOn() && ent.tickCount < 3)
349
            for (MineAction a : actions)
350
                if (net.minecraft.world.phys.Vec3.atBottomCenterOf(a.getPos()).distanceToSqr(ent.position()) <= 1f)
351
                    return true;
352
353
        return false;
354
    }
355
356
    public class MineAction {
357
        @NotNull
358
        private final BlockPos pos;
359
        private float progress, prevProgress;
360
361
        private int mineBreaks;
362
363
        private final Timer attackTimer = new Timer();
364
365
        public MineAction(@NotNull BlockPos pos, Direction direction) {
366
            this.pos = pos;
367
            progress = 0;
368
            mineBreaks = 0;
369
            start(direction);
370
        }
371
372
        public void start(Direction direction) {
373
            Direction startDirection = direction == null ? mc.player.getDirection() : direction;
374
375
            if (startDirection != null)
376
                if (doubleMine.getValue()) {
377
                    sendPacket(new ServerboundPlayerActionPacket(ServerboundPlayerActionPacket.Action.STOP_DESTROY_BLOCK, pos, startDirection));
378
                    sendPacket(new ServerboundPlayerActionPacket(ServerboundPlayerActionPacket.Action.START_DESTROY_BLOCK, pos, startDirection));
379
                    sendPacket(new ServerboundPlayerActionPacket(ServerboundPlayerActionPacket.Action.STOP_DESTROY_BLOCK, pos, startDirection));
380
                } else {
381
                    sendPacket(new ServerboundPlayerActionPacket(ServerboundPlayerActionPacket.Action.START_DESTROY_BLOCK, pos, startDirection));
382
                    sendPacket(new ServerboundPlayerActionPacket(startMode.getValue() == StartMode.StartAbort ? ServerboundPlayerActionPacket.Action.ABORT_DESTROY_BLOCK : ServerboundPlayerActionPacket.Action.STOP_DESTROY_BLOCK, pos, startDirection));
383
                }
384
        }
385
386
        public boolean update() {
387
            Direction dir = InteractionUtility.getStrictDirections(pos).stream().findFirst().orElse(mc.player.getDirection());
388
389
            if (mineBreaks >= breakAttempts.getValue() && mode.not(Mode.GrimInstant))
390
                return true;
391
392
            if (PlayerUtility.squaredDistanceFromEyes(net.minecraft.world.phys.Vec3.atBottomCenterOf(pos)) > range.getPow2Value()) {
393
                cancel();
394
                return true;
395
            }
396
397
            if (mc.level.isEmptyBlock(pos)) {
398
                progress = 0;
399
                prevProgress = -1;
400
                return false;
401
            }
402
403
            if (progress == 0 && prevProgress == -1 && mode.is(Mode.Packet) && attackTimer.every(800)) {
404
                start(dir);
405
                mc.player.swing(InteractionHand.MAIN_HAND);
406
            }
407
408
            int pickSlot = getTool(pos);
409
            int prevSlot = mc.player.getInventory().getSelectedSlot();
410
411
            if (pickSlot == -1)
412
                return false;
413
414
            boolean instant = mineBreaks > 0 && mode.is(Mode.GrimInstant);
415
416
            if (progress >= 1 || instant) {
417
                if (placeCrystal.getValue())
418
                    placeCrystal();
419
420
                switchTo(pickSlot, -1);
421
422
                if (mode.getValue() == Mode.GrimInstant || doubleMine.getValue()) {
423
                    sendPacket(new ServerboundPlayerActionPacket(ServerboundPlayerActionPacket.Action.STOP_DESTROY_BLOCK, pos, dir));
424
                } else {
425
                    if (stop.getValue())
426
                        sendPacket(new ServerboundPlayerActionPacket(ServerboundPlayerActionPacket.Action.STOP_DESTROY_BLOCK, pos, dir));
427
                    if (abort.getValue())
428
                        sendPacket(new ServerboundPlayerActionPacket(ServerboundPlayerActionPacket.Action.ABORT_DESTROY_BLOCK, pos, dir));
429
                    if (start.getValue())
430
                        sendPacket(new ServerboundPlayerActionPacket(ServerboundPlayerActionPacket.Action.START_DESTROY_BLOCK, pos, dir));
431
                    if (stop2.getValue())
432
                        sendPacket(new ServerboundPlayerActionPacket(ServerboundPlayerActionPacket.Action.STOP_DESTROY_BLOCK, pos, dir));
433
                }
434
435
                if (clientRemove.getValue())
436
                    mc.gameMode.destroyBlock(pos);
437
438
                int delay = doubleMine.getValue() ? 100 : swapDelay.getValue();
439
440
                if (delay != 0)
441
                    Managers.ASYNC.run(() -> switchTo(prevSlot, pickSlot), delay);
442
                else
443
                    switchTo(prevSlot, pickSlot);
444
445
                mineBreaks++;
446
447
                progress = prevProgress = 0;
448
449
                if (doubleMine.getValue() && mode.is(Mode.GrimInstant) && actions.size() >= 2)
450
                    return true;
451
            } else {
452
                prevProgress = progress;
453
                progress += getBlockStrength(mc.level.getBlockState(pos), pos);
454
            }
455
456
            fixMovement();
457
458
            return false;
459
        }
460
461
        private void switchTo(int slot, int from) {
462
            if (switchMode.getValue() == SwitchMode.Alternative || slot >= 9) {
463
                if (from == -1)
464
                    clickSlot(slot < 9 ? slot + 36 : slot, mc.player.getInventory().getSelectedSlot(), ContainerInput.SWAP);
465
                else
466
                    clickSlot(from < 9 ? from + 36 : from, mc.player.getInventory().getSelectedSlot(), ContainerInput.SWAP);
467
                closeScreen();
468
            } else if (switchMode.is(SwitchMode.Silent)) InventoryUtility.switchToSilent(slot);
469
            else InventoryUtility.switchTo(slot);
470
        }
471
472
        public void fixMovement() {
473
            if (rotate.getValue() && progress > 0.95)
474
                ModuleManager.rotations.fixRotation = PlayerManager.calcAngle(mc.player.getEyePosition(), net.minecraft.world.phys.Vec3.atBottomCenterOf(pos))[0];
475
        }
476
477
        public BlockPos getPos() {
478
            return pos;
479
        }
480
481
        public float getPrevProgress() {
482
            return prevProgress;
483
        }
484
485
        public float getProgress() {
486
            return progress;
487
        }
488
489
        public void onSync() {
490
            if (rotate.getValue() && progress > 0.95) {
491
                float[] angle = PlayerManager.calcAngle(mc.player.getEyePosition(), net.minecraft.world.phys.Vec3.atBottomCenterOf(pos).add(0, -0.25f, 0));
492
                mc.player.setYRot(angle[0]);
493
                mc.player.setXRot(angle[1]);
494
            }
495
        }
496
497
        public void reset() {
498
            if (progress == 0)
499
                return;
500
501
            prevProgress = progress = 0;
502
            Direction dir = InteractionUtility.getStrictDirections(pos).stream().findFirst().orElse(mc.player.getDirection());
503
            sendPacket(new ServerboundPlayerActionPacket(ServerboundPlayerActionPacket.Action.ABORT_DESTROY_BLOCK, pos, dir));
504
            start(dir);
505
        }
506
507
        public void cancel() {
508
            if (progress != 0)
509
                sendPacket(new ServerboundPlayerActionPacket(ServerboundPlayerActionPacket.Action.ABORT_DESTROY_BLOCK, pos, Direction.DOWN));
510
        }
511
512
        public boolean instantBreaking() {
513
            return mineBreaks > 0 && mode.is(Mode.GrimInstant);
514
        }
515
    }
516
517
    public enum Mode {
518
        Packet,
519
        GrimInstant,
520
        Damage
521
    }
522
523
    public enum RenderMode {
524
        Block,
525
        Shrink,
526
        Grow
527
    }
528
529
    public enum SwitchMode {
530
        Silent,
531
        Normal,
532
        Alternative
533
    }
534
535
    public enum StartMode {
536
        StartAbort,
537
        StartStop
538
    }
539
}
540