LegitHelper module

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

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.

MelaHack (ThunderHack fork)COMBATsrc/main/java/thunder/hack/features/modules/combat/LegitHelper.javaJava · 343 lines · 17.0 KB

Represents macros for crystals and anchors.

SettingsMinecartsMaxDistanceRefillRefillSlotAnchorsAnchorDelayAnchorBindCrystalsCrystalDelayCrystalBindChangePitchCrystalOptimizerSwitchBackShieldBreakerBreakerDelaySwapBackWindBoostJumpWindBoostBindCrossBowCrossBowBindCBSwapBack
LegitHelper.javaJava · Minecraft 26.2 · 343 lines · 17.0 KB · complete file, verbatimOriginal ↗
1
package thunder.hack.features.modules.combat;
2
3
import meteordevelopment.orbit.EventHandler;
4
import net.minecraft.network.protocol.game.*;
5
import net.minecraft.util.Mth;
6
import net.minecraft.core.*;
7
import net.minecraft.core.component.DataComponents;
8
import net.minecraft.world.InteractionHand;
9
import net.minecraft.world.entity.Entity;
10
import net.minecraft.world.entity.boss.enderdragon.EndCrystal;
11
import net.minecraft.world.entity.player.Player;
12
import net.minecraft.world.entity.projectile.arrow.Arrow;
13
import net.minecraft.world.inventory.ContainerInput;
14
import net.minecraft.world.item.Items;
15
import net.minecraft.world.level.ClipContext;
16
import net.minecraft.world.level.block.Blocks;
17
import net.minecraft.world.phys.*;
18
import org.jetbrains.annotations.NotNull;
19
import org.lwjgl.glfw.GLFW;
20
import thunder.hack.core.Managers;
21
import thunder.hack.core.manager.client.AsyncManager;
22
import thunder.hack.core.manager.client.ModuleManager;
23
import thunder.hack.events.impl.EventEntitySpawn;
24
import thunder.hack.events.impl.EventSync;
25
import thunder.hack.events.impl.PacketEvent;
26
import thunder.hack.injection.accesors.IMinecraftClient;
27
import thunder.hack.features.modules.Module;
28
import thunder.hack.setting.Setting;
29
import thunder.hack.setting.impl.Bind;
30
import thunder.hack.setting.impl.BooleanSettingGroup;
31
import thunder.hack.utility.Timer;
32
import thunder.hack.utility.player.InteractionUtility;
33
import thunder.hack.utility.player.InventoryUtility;
34
import thunder.hack.utility.player.PlayerUtility;
35
import thunder.hack.utility.player.SearchInvResult;
36
import thunder.hack.utility.render.Render2DEngine;
37
import thunder.hack.utility.render.Render3DEngine;
38
39
import static thunder.hack.features.modules.combat.Criticals.getEntity;
40
import static thunder.hack.features.modules.combat.Criticals.getInteractType;
41
42
public class LegitHelper extends Module {
43
    public LegitHelper() {
44
        super("LegitHelper", Category.COMBAT);
45
    }
46
47
    private final Setting<BooleanSettingGroup> minecarts = new Setting<>("Minecarts", new BooleanSettingGroup(true));
48
    private final Setting<Float> maxDistance = new Setting<>("MaxDistance", 4f, 2f, 6f).addToGroup(minecarts);
49
    private final Setting<Boolean> refill = new Setting<>("Refill", true).addToGroup(minecarts);
50
    private final Setting<Integer> refillSlot = new Setting<>("RefillSlot", 9, 1, 9, v -> refill.getValue()).addToGroup(minecarts);
51
52
    private final Setting<BooleanSettingGroup> anchors = new Setting<>("Anchors", new BooleanSettingGroup(true));
53
    private final Setting<Integer> anchorDelay = new Setting<>("AnchorDelay", 50, 5, 250).addToGroup(anchors);
54
    private final Setting<Bind> anchorBind = new Setting<>("AnchorBind", new Bind(GLFW.GLFW_KEY_Y, false, false)).addToGroup(anchors);
55
56
    private final Setting<BooleanSettingGroup> crystals = new Setting<>("Crystals", new BooleanSettingGroup(true));
57
    private final Setting<Integer> crystalDelay = new Setting<>("CrystalDelay", 50, 5, 250).addToGroup(crystals);
58
    private final Setting<Bind> crystalBind = new Setting<>("CrystalBind", new Bind(GLFW.GLFW_KEY_U, false, false)).addToGroup(crystals);
59
    private final Setting<Boolean> changePitch = new Setting<>("ChangePitch", false).addToGroup(crystals);
60
    private final Setting<Boolean> crystalOptimizer = new Setting<>("CrystalOptimizer", false).addToGroup(crystals);
61
    private final Setting<Boolean> switchBack = new Setting<>("SwitchBack", false).addToGroup(crystals);
62
63
    private final Setting<BooleanSettingGroup> shieldBreaker = new Setting<>("ShieldBreaker", new BooleanSettingGroup(false));
64
    private final Setting<Integer> breakerDelay = new Setting<>("BreakerDelay", 50, 5, 250).addToGroup(shieldBreaker);
65
    private final Setting<Boolean> swapBack = new Setting<>("SwapBack", true).addToGroup(shieldBreaker);
66
67
    private final Setting<BooleanSettingGroup> windBoostJump = new Setting<>("WindBoostJump", new BooleanSettingGroup(true));
68
    private final Setting<Bind> windBoostBind = new Setting<>("WindBoostBind", new Bind(GLFW.GLFW_KEY_I, false, false)).addToGroup(windBoostJump);
69
70
    private final Setting<BooleanSettingGroup> crossBow = new Setting<>("CrossBow", new BooleanSettingGroup(true));
71
    private final Setting<Bind> crossBowBind = new Setting<>("CrossBowBind", new Bind(GLFW.GLFW_KEY_O, false, false)).addToGroup(crossBow);
72
    private final Setting<Boolean> cbswapBack = new Setting<>("CBSwapBack", true).addToGroup(crossBow);
73
74
    private Timer timer = new Timer();
75
    private Timer cbtimer = new Timer();
76
77
    private Vec3 lastCrystalVec = Vec3.ZERO;
78
    private Vec3 rotationVec = Vec3.ZERO;
79
80
    @Override
81
    public void onUpdate() {
82
        if (anchors.getValue().isEnabled() && isKeyPressed(anchorBind) && timer.every(anchorDelay.getValue() * 5L + 100)) {
83
            int glowSlot = InventoryUtility.findItemInHotBar(Items.GLOWSTONE).slot();
84
            int anchorSlot = InventoryUtility.findItemInHotBar(Items.RESPAWN_ANCHOR).slot();
85
            if (glowSlot == -1 || anchorSlot == -1) return;
86
87
            int prevSlot = mc.player.getInventory().getSelectedSlot();
88
89
            Managers.ASYNC.run(() -> {
90
                mc.player.getInventory().setSelectedSlot(anchorSlot);
91
                mc.getConnection().send(new ServerboundSetCarriedItemPacket(anchorSlot));
92
            });
93
94
            Managers.ASYNC.run(() -> mc.executeIfPossible(() -> ((IMinecraftClient) mc).idoItemUse()), anchorDelay.getValue());
95
96
            Managers.ASYNC.run(() -> {
97
                mc.player.getInventory().setSelectedSlot(glowSlot);
98
                mc.getConnection().send(new ServerboundSetCarriedItemPacket(glowSlot));
99
            }, anchorDelay.getValue() * 2);
100
101
            Managers.ASYNC.run(() -> mc.executeIfPossible(() -> ((IMinecraftClient) mc).idoItemUse()), anchorDelay.getValue() * 3L);
102
103
            Managers.ASYNC.run(() -> {
104
                mc.player.getInventory().setSelectedSlot(prevSlot);
105
                mc.getConnection().send(new ServerboundSetCarriedItemPacket(prevSlot));
106
            }, anchorDelay.getValue() * 4);
107
108
            Managers.ASYNC.run(() -> mc.executeIfPossible(() -> ((IMinecraftClient) mc).idoItemUse()), anchorDelay.getValue() * 5L);
109
110
            return;
111
        }
112
113
        boolean crystalAtCrosshair = mc.hitResult instanceof EntityHitResult ehr && ehr.getEntity() instanceof EndCrystal;
114
        boolean obbyAtCrosshair = mc.hitResult instanceof BlockHitResult bhr && mc.level.getBlockState(bhr.getBlockPos()).getBlock() == Blocks.OBSIDIAN;
115
116
        if (crystals.getValue().isEnabled() && isKeyPressed(crystalBind) && timer.every(crystalDelay.getValue() * (crystalAtCrosshair ? 1L : obbyAtCrosshair ? 2L : 4L))) {
117
            int crystalSlot = InventoryUtility.findItemInHotBar(Items.END_CRYSTAL).slot();
118
            int obbySlot = InventoryUtility.findBlockInHotBar(Blocks.OBSIDIAN).slot();
119
            if (obbySlot == -1 || crystalSlot == -1 || crystalSlot >= 9 || obbySlot >= 9) return;
120
121
            if (crystalAtCrosshair) {
122
                mc.gameMode.attack(mc.player, ((EntityHitResult) mc.hitResult).getEntity());
123
                mc.player.swing(InteractionHand.MAIN_HAND);
124
                return;
125
            }
126
127
            int prevSlot = mc.player.getInventory().getSelectedSlot();
128
129
            if (!obbyAtCrosshair) {
130
                mc.player.getInventory().setSelectedSlot(obbySlot);
131
                mc.getConnection().send(new ServerboundSetCarriedItemPacket(obbySlot));
132
                ((IMinecraftClient) mc).idoItemUse();
133
            }
134
135
            Managers.ASYNC.run(() -> {
136
                if (!obbyAtCrosshair)
137
                    AsyncManager.sleep(crystalDelay.getValue());
138
139
                mc.player.getInventory().setSelectedSlot(crystalSlot);
140
                mc.getConnection().send(new ServerboundSetCarriedItemPacket(crystalSlot));
141
                AsyncManager.sleep(crystalDelay.getValue());
142
                ((IMinecraftClient) mc).idoItemUse();
143
                lastCrystalVec = mc.hitResult.getLocation();
144
                if (switchBack.getValue()) {
145
                    AsyncManager.sleep(crystalDelay.getValue());
146
                    mc.player.getInventory().setSelectedSlot(prevSlot);
147
                    mc.getConnection().send(new ServerboundSetCarriedItemPacket(prevSlot));
148
                }
149
            });
150
        }
151
152
153
        if (shieldBreaker.getValue().isEnabled()
154
                && mc.hitResult instanceof EntityHitResult ehr
155
                && ehr.getEntity() instanceof Player pl
156
                && !Managers.FRIEND.isFriend(pl)
157
                && (pl.getOffhandItem().getItem() == Items.SHIELD || pl.getMainHandItem().getItem() == Items.SHIELD)
158
                && pl.getUseItem().getItem() == Items.SHIELD && timer.every(500)) {
159
160
            int axeSlot = InventoryUtility.getAxeHotBar().slot();
161
            if (axeSlot == -1)
162
                return;
163
164
            int prevSlot = mc.player.getInventory().getSelectedSlot();
165
166
            Managers.ASYNC.run(() -> {
167
                AsyncManager.sleep(breakerDelay.getValue());
168
                mc.player.getInventory().setSelectedSlot(axeSlot);
169
                mc.getConnection().send(new ServerboundSetCarriedItemPacket(axeSlot));
170
                AsyncManager.sleep(breakerDelay.getValue());
171
                if (mc.hitResult instanceof EntityHitResult ehr2)
172
                    mc.gameMode.attack(mc.player, ehr2.getEntity());
173
                mc.player.swing(InteractionHand.MAIN_HAND);
174
175
                if (swapBack.getValue()) {
176
                    AsyncManager.sleep(breakerDelay.getValue());
177
                    mc.player.getInventory().setSelectedSlot(prevSlot);
178
                    mc.getConnection().send(new ServerboundSetCarriedItemPacket(prevSlot));
179
                }
180
            });
181
        }
182
183
        if (minecarts.getValue().isEnabled() && refill.getValue())
184
            if (mc.player.getInventory().getItem(refillSlot.getValue() - 1).getItem() != Items.TNT_MINECART) {
185
                SearchInvResult result = InventoryUtility.findItemInInventory(Items.TNT_MINECART);
186
                if (result.found())
187
                    clickSlot(result.slot(), refillSlot.getValue() - 1, ContainerInput.SWAP);
188
            }
189
190
        if (crossBow.getValue().isEnabled() && isKeyPressed(crossBowBind) && cbtimer.every(300)) {
191
            SearchInvResult result = InventoryUtility.findInHotBar(i -> i.getItem() == Items.CROSSBOW && i.get(DataComponents.CHARGED_PROJECTILES) != null && !i.get(DataComponents.CHARGED_PROJECTILES).isEmpty());
192
            if (result.found()) {
193
                InventoryUtility.saveAndSwitchTo(result.slot());
194
                InteractionUtility.sendSequencedPacket(id -> new ServerboundUseItemPacket(InteractionHand.MAIN_HAND, id, mc.player.getYRot(), mc.player.getXRot()));
195
                if (cbswapBack.getValue())
196
                    InventoryUtility.returnSlot();
197
            }
198
        }
199
    }
200
201
202
    @EventHandler
203
    public void onEntitySpawn(EventEntitySpawn e) {
204
        if (e.getEntity() instanceof EndCrystal cr && e.getEntity().distanceToSqr(lastCrystalVec) < 4f) {
205
            lastCrystalVec = Vec3.ZERO;
206
            if (changePitch.getValue()) {
207
                float pitch = InteractionUtility.calculateAngle(cr.position().add(0, 0.15, 0))[1];
208
                double gcdFix = (Math.pow(mc.options.sensitivity().get() * 0.6 + 0.2, 3.0)) * 1.2;
209
                mc.player.setXRot((float) (pitch - (pitch - mc.player.getXRot()) % gcdFix));
210
            }
211
            mc.gameMode.attack(mc.player, e.getEntity());
212
            mc.player.swing(InteractionHand.MAIN_HAND);
213
        }
214
    }
215
216
    @EventHandler
217
    public void onPacketSend(PacketEvent.@NotNull Send event) {
218
        if (crystalOptimizer.getValue() && event.getPacket() instanceof ServerboundInteractPacket
219
                && getInteractType(event.getPacket()) == Criticals.InteractType.ATTACK && getEntity(event.getPacket()) instanceof EndCrystal c
220
                && !ModuleManager.autoCrystal.isEnabled()) {
221
            c.discard();
222
            c.setRemoved(Entity.RemovalReason.KILLED);
223
            c.onClientRemoval();
224
        }
225
    }
226
227
    @EventHandler
228
    public void onPacketSendPost(PacketEvent.@NotNull SendPost event) {
229
        if (event.getPacket() instanceof ServerboundPlayerActionPacket action && action.getAction() == ServerboundPlayerActionPacket.Action.RELEASE_USE_ITEM) {
230
            if (minecarts.getValue().isEnabled() && mc.player.getMainHandItem().getItem() == Items.BOW) {
231
                BlockPos bp = calcTrajectory(mc.player.getYRot());
232
                if (bp != null && PlayerUtility.squaredDistanceFromEyes(net.minecraft.world.phys.Vec3.atBottomCenterOf(bp)) <= maxDistance.getPow2Value() && PlayerUtility.squaredDistanceFromEyes(net.minecraft.world.phys.Vec3.atBottomCenterOf(bp)) > 3) {
233
234
                    SearchInvResult baseResult = InventoryUtility.findItemInHotBar(Items.RAIL, Items.ACTIVATOR_RAIL, Items.DETECTOR_RAIL, Items.POWERED_RAIL);
235
                    SearchInvResult cartResult = InventoryUtility.findItemInHotBar(Items.TNT_MINECART);
236
237
                    if (baseResult.found() && cartResult.found()) {
238
                        InventoryUtility.saveSlot();
239
                        baseResult.switchTo();
240
                        sendSequencedPacket(s -> new ServerboundUseItemOnPacket(InteractionHand.MAIN_HAND,
241
                                new BlockHitResult(new Vec3(bp.getX() + 0.5, bp.above().getY(), bp.getZ() + 0.)
242
                                        , Direction.UP,
243
                                        bp,
244
                                        false), s));
245
246
                        rotationVec = net.minecraft.world.phys.Vec3.atBottomCenterOf(bp.above());
247
                        cartResult.switchTo();
248
                        sendSequencedPacket(s -> new ServerboundUseItemOnPacket(InteractionHand.MAIN_HAND,
249
                                new BlockHitResult(new Vec3(bp.getX() + 0.5, bp.above().getY() + .125, bp.getZ() + 0.5)
250
                                        , Direction.UP,
251
                                        bp.above(),
252
                                        false), s));
253
                        InventoryUtility.returnSlot();
254
                    }
255
                }
256
            }
257
        }
258
    }
259
260
    @EventHandler
261
    public void onSync(EventSync e) {
262
        if (rotationVec != null) {
263
            float[] angle = InteractionUtility.calculateAngle(rotationVec);
264
            mc.player.setYRot(angle[0]);
265
            mc.player.setXRot(angle[1]);
266
            rotationVec = null;
267
        }
268
269
        if (isKeyPressed(windBoostBind) && mc.player.onGround()) {
270
            SearchInvResult result = InventoryUtility.findItemInHotBar(Items.WIND_CHARGE);
271
            if (result.found()) {
272
                mc.player.setXRot(90);
273
                mc.player.jumpFromGround();
274
                InventoryUtility.saveAndSwitchTo(result.slot());
275
                mc.gameMode.useItem(mc.player, InteractionHand.MAIN_HAND);
276
                InventoryUtility.returnSlot();
277
            }
278
        }
279
    }
280
281
    private BlockPos calcTrajectory(float yaw) {
282
        double x = Render2DEngine.interpolate(mc.player.xo, mc.player.getX(), Render3DEngine.getTickDelta());
283
        double y = Render2DEngine.interpolate(mc.player.yo, mc.player.getY(), Render3DEngine.getTickDelta());
284
        double z = Render2DEngine.interpolate(mc.player.zo, mc.player.getZ(), Render3DEngine.getTickDelta());
285
286
        y = y + mc.player.getEyeHeight(mc.player.getPose()) - 0.1000000014901161;
287
288
        double motionX = -Mth.sin(yaw / 180.0f * 3.1415927f) * Mth.cos(mc.player.getXRot() / 180.0f * 3.1415927f);
289
        double motionY = -Mth.sin((mc.player.getXRot()) / 180.0f * 3.141593f);
290
        double motionZ = Mth.cos(yaw / 180.0f * 3.1415927f) * Mth.cos(mc.player.getXRot() / 180.0f * 3.1415927f);
291
        float power = mc.player.getTicksUsingItem() / 20.0f;
292
293
        power = (power * power + power * 2.0f) / 3.0f;
294
        if (power > 1.0f) {
295
            power = 1.0f;
296
        }
297
298
        final float distance = Mth.sqrt((float) (motionX * motionX + motionY * motionY + motionZ * motionZ));
299
        motionX /= distance;
300
        motionY /= distance;
301
        motionZ /= distance;
302
303
        final float pow = power * 3;
304
        motionX *= pow;
305
        motionY *= pow;
306
        motionZ *= pow;
307
308
        if (!mc.player.onGround())
309
            motionY += mc.player.getDeltaMovement().y();
310
311
312
        Vec3 lastPos;
313
        for (int i = 0; i < 300; i++) {
314
            lastPos = new Vec3(x, y, z);
315
            x += motionX;
316
            y += motionY;
317
            z += motionZ;
318
319
            motionX *= 0.99;
320
            motionY *= 0.99;
321
            motionZ *= 0.99;
322
323
324
            motionY -= 0.05000000074505806;
325
            Vec3 pos = new Vec3(x, y, z);
326
327
            for (Entity ent : mc.level.entitiesForRendering()) {
328
                if (ent instanceof Arrow || ent.equals(mc.player)) continue;
329
                if (ent.getBoundingBox().intersects(new AABB(x - 0.3, y - 0.3, z - 0.3, x + 0.3, y + 0.3, z + 0.3)))
330
                    return null;
331
            }
332
333
            BlockHitResult bhr = mc.level.clip(new ClipContext(lastPos, pos, ClipContext.Block.OUTLINE, ClipContext.Fluid.NONE, mc.player));
334
            if (bhr != null && bhr.getType() == HitResult.Type.BLOCK) {
335
                return bhr.getBlockPos();
336
            }
337
338
            if (y <= -65) break;
339
        }
340
        return null;
341
    }
342
}
343