PearlChaser module

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

1 implementationMISC

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)MISCsrc/main/java/thunder/hack/features/modules/misc/PearlChaser.javaJava · 254 lines · 10.8 KB

Automatic pursuit pearl.

SettingsStopMotionLegitStopPauseAuraOnlyOnGroundNoMoveOnlyTarget
PearlChaser.javaJava · Minecraft 26.2 · 254 lines · 10.8 KB · complete file, verbatimOriginal ↗
1
package thunder.hack.features.modules.misc;
2
3
import meteordevelopment.orbit.EventHandler;
4
import meteordevelopment.orbit.EventPriority;
5
import net.minecraft.core.BlockPos;
6
import net.minecraft.network.protocol.game.ServerboundSetCarriedItemPacket;
7
import net.minecraft.network.protocol.game.ServerboundSwingPacket;
8
import net.minecraft.network.protocol.game.ServerboundUseItemPacket;
9
import net.minecraft.util.Mth;
10
import net.minecraft.world.InteractionHand;
11
import net.minecraft.world.entity.Entity;
12
import net.minecraft.world.entity.player.Player;
13
import net.minecraft.world.entity.projectile.arrow.Arrow;
14
import net.minecraft.world.entity.projectile.throwableitemprojectile.ThrownEnderpearl;
15
import net.minecraft.world.item.Items;
16
import net.minecraft.world.level.ClipContext;
17
import net.minecraft.world.phys.AABB;
18
import net.minecraft.world.phys.BlockHitResult;
19
import net.minecraft.world.phys.HitResult;
20
import net.minecraft.world.phys.Vec3;
21
import org.jetbrains.annotations.NotNull;
22
import thunder.hack.core.manager.client.ModuleManager;
23
import thunder.hack.events.impl.EventEntitySpawn;
24
import thunder.hack.events.impl.EventPostSync;
25
import thunder.hack.events.impl.EventSync;
26
import thunder.hack.features.modules.Module;
27
import thunder.hack.features.modules.combat.Aura;
28
import thunder.hack.features.modules.combat.AutoCrystal;
29
import thunder.hack.setting.Setting;
30
import thunder.hack.setting.impl.BooleanSettingGroup;
31
import thunder.hack.utility.Timer;
32
import thunder.hack.utility.math.MathUtility;
33
import thunder.hack.utility.player.MovementUtility;
34
35
import java.util.Comparator;
36
import java.util.HashMap;
37
38
import static thunder.hack.features.modules.client.ClientSettings.isRu;
39
40
public class PearlChaser extends Module {
41
    public PearlChaser() { //todo better targeting?..
42
        super("PearlChaser", Category.MISC);
43
    }
44
45
    private final Setting<BooleanSettingGroup> stopMotion = new Setting<>("StopMotion", new BooleanSettingGroup(false));
46
    private final Setting<Boolean> legitStop = new Setting<>("LegitStop", false).addToGroup(stopMotion);
47
    private final Setting<Boolean> pauseAura = new Setting<>("PauseAura", false);
48
    private final Setting<Boolean> onlyOnGround = new Setting<>("OnlyOnGround", false);
49
    private final Setting<Boolean> noMove = new Setting<>("NoMove", false);
50
    private final Setting<Boolean> onlyTarget = new Setting<>("OnlyTarget", false);
51
52
    private Runnable postSyncAction;
53
    private final Timer delayTimer = new Timer();
54
    private BlockPos targetBlock;
55
    private int lastPearlId;
56
    private int lastOurPearlId;
57
    private HashMap<Player, Long> targets = new HashMap<>();
58
59
    @EventHandler
60
    public void onEntitySpawn(EventEntitySpawn e) {
61
        if (e.getEntity() instanceof ThrownEnderpearl)
62
            mc.level.players().stream()
63
                    .min(Comparator.comparingDouble((p) -> p.distanceToSqr(e.getEntity().position())))
64
                    .ifPresent((player) -> {
65
                        if (player.equals(mc.player))
66
                            lastOurPearlId = e.getEntity().getId();
67
                    });
68
69
    }
70
71
    @EventHandler(priority = EventPriority.LOW)
72
    public void onSync(EventSync event) {
73
        if (onlyTarget.getValue()) {
74
            if (Aura.target != null && ModuleManager.aura.isEnabled() && Aura.target instanceof Player pl && !targets.containsKey(pl))
75
                targets.put(pl, System.currentTimeMillis());
76
77
            if (AutoCrystal.target != null && ModuleManager.autoCrystal.isEnabled() && AutoCrystal.target instanceof Player pl && !targets.containsKey(pl))
78
                targets.put(pl, System.currentTimeMillis());
79
80
            new HashMap<>(targets).forEach((k, v) -> {
81
                if (System.currentTimeMillis() - v > 10000)
82
                    targets.remove(k);
83
            });
84
        }
85
86
        // Анти селфкилл
87
        if (mc.player.getHealth() < 5)
88
            return;
89
90
        // Антиспам
91
        if (!delayTimer.passedMs(1000))
92
            return;
93
94
        for (Entity ent : mc.level.entitiesForRendering()) {
95
            if (!(ent instanceof ThrownEnderpearl)) continue;
96
            if (ent.getId() == lastPearlId || ent.getId() == lastOurPearlId) continue;
97
            mc.level.players().stream()
98
                    .filter(e -> targets.containsKey(e) || !onlyTarget.getValue())
99
                    .min(Comparator.comparingDouble((p) -> p.distanceToSqr(ent.position())))
100
                    .ifPresent((player) -> {
101
                        if (!player.equals(mc.player)) {
102
                            targetBlock = calcTrajectory(ent);
103
                            lastPearlId = ent.getId();
104
                        }
105
                    });
106
        }
107
108
        // Анти NPE
109
        if (targetBlock == null)
110
            return;
111
112
        // Нет смысла кидать если кидают в нас
113
        if (mc.player.distanceToSqr(net.minecraft.world.phys.Vec3.atBottomCenterOf(targetBlock)) < 49)
114
            return;
115
116
        float rotationPitch = (float) (-Math.toDegrees(calcTrajectory(targetBlock)));
117
        float rotationYaw = (float) Math.toDegrees(Math.atan2(targetBlock.getZ() + 0.5f - mc.player.getZ(), targetBlock.getX() + 0.5f - mc.player.getX())) - 90.0f;
118
        BlockPos tracedBP = checkTrajectory(rotationYaw, rotationPitch);
119
120
        if (tracedBP == null || targetBlock.distToCenterSqr(net.minecraft.world.phys.Vec3.atBottomCenterOf(tracedBP)) > 36)
121
            return;
122
123
        if(pauseAura.getValue() && ModuleManager.aura.isEnabled())
124
            ModuleManager.aura.pause();
125
126
        if(onlyOnGround.getValue() && !mc.player.onGround())
127
            return;
128
129
        if(noMove.getValue() && MovementUtility.isMoving())
130
            return;
131
132
        if(stopMotion.getValue().isEnabled()) {
133
            if(!legitStop.getValue())
134
                mc.player.setDeltaMovement(0,0,0);
135
            mc.options.keyUp.setDown(false);
136
            mc.options.keyDown.setDown(false);
137
            mc.options.keyLeft.setDown(false);
138
            mc.options.keyRight.setDown(false);
139
            thunder.hack.utility.player.MovementUtility.clearMovementInput();
140
            return;
141
        }
142
143
        sendMessage(isRu() ?
144
                ("Догоняем перл! Позиция X:" + tracedBP.getX() + " Y:" + tracedBP.getY() + " Z:" + tracedBP.getZ() + " Углы Y:" + rotationYaw + " P:" + rotationPitch) :
145
                ("Chasing pearl on X:" + tracedBP.getX() + " Y:" + tracedBP.getY() + " Z:" + tracedBP.getZ() + " Angle Y:" + rotationYaw + " P:" + rotationPitch));
146
147
        mc.player.setYRot(rotationYaw);
148
        mc.player.setXRot(MathUtility.clamp(rotationPitch, -89, 89));
149
150
        float yaw = mc.player.getYRot();
151
        float pitch = mc.player.getXRot();
152
153
        postSyncAction = () -> {
154
            int epSlot = findEPSlot();
155
            int originalSlot = mc.player.getInventory().getSelectedSlot();
156
            if (epSlot != -1) {
157
                mc.player.getInventory().setSelectedSlot(epSlot);
158
                sendPacket(new ServerboundSetCarriedItemPacket(epSlot));
159
                sendSequencedPacket(id -> new ServerboundUseItemPacket(InteractionHand.MAIN_HAND, id, yaw, pitch));
160
                sendPacket(new ServerboundSwingPacket(InteractionHand.MAIN_HAND));
161
                mc.player.getInventory().setSelectedSlot(originalSlot);
162
                sendPacket(new ServerboundSetCarriedItemPacket(originalSlot));
163
            }
164
        };
165
166
        targetBlock = null;
167
        delayTimer.reset();
168
    }
169
170
    @EventHandler
171
    public void onPostSync(EventPostSync event) {
172
        if (postSyncAction != null) {
173
            postSyncAction.run();
174
            postSyncAction = null;
175
        }
176
    }
177
178
    private int findEPSlot() {
179
        int epSlot = -1;
180
        if (mc.player.getMainHandItem().getItem() == Items.ENDER_PEARL)
181
            epSlot = mc.player.getInventory().getSelectedSlot();
182
        if (epSlot == -1)
183
            for (int l = 0; l < 9; ++l)
184
                if (mc.player.getInventory().getItem(l).getItem() == Items.ENDER_PEARL) {
185
                    epSlot = l;
186
                    break;
187
                }
188
        return epSlot;
189
    }
190
191
    private float calcTrajectory(@NotNull BlockPos bp) {
192
        double a = Math.hypot(bp.getX() + 0.5f - mc.player.getX(), bp.getZ() + 0.5f - mc.player.getZ());
193
        double y = 6.125 * ((bp.getY() + 1f) - (mc.player.getY() + (double) mc.player.getEyeHeight(mc.player.getPose())));
194
        y = 0.05000000074505806 * ((0.05000000074505806 * (a * a)) + y);
195
        y = Math.sqrt(9.37890625 - y);
196
        double d = 3.0625 - y;
197
        y = Math.atan2(d * d + y, 0.05000000074505806 * a);
198
        d = Math.atan2(d, 0.05000000074505806 * a);
199
        return (float) Math.min(y, d);
200
    }
201
202
    private BlockPos calcTrajectory(Entity e) {
203
        return traceTrajectory(e.getX(), e.getY(), e.getZ(), e.getDeltaMovement().x, e.getDeltaMovement().y, e.getDeltaMovement().z);
204
    }
205
206
    private BlockPos checkTrajectory(float yaw, float pitch) {
207
        if (Float.isNaN(pitch))
208
            return null;
209
        float yawRad = yaw / 180.0f * 3.1415927f;
210
        float pitchRad = pitch / 180.0f * 3.1415927f;
211
        double x = mc.player.getX() - Mth.cos(yawRad) * 0.16f;
212
        double y = mc.player.getY() + mc.player.getEyeHeight(mc.player.getPose()) - 0.1000000014901161;
213
        double z = mc.player.getZ() - Mth.sin(yawRad) * 0.16f;
214
        double motionX = -Mth.sin(yawRad) * Mth.cos(pitchRad) * 0.4f;
215
        double motionY = -Mth.sin(pitchRad) * 0.4f;
216
        double motionZ = Mth.cos(yawRad) * Mth.cos(pitchRad) * 0.4f;
217
        final float distance = Mth.sqrt((float) (motionX * motionX + motionY * motionY + motionZ * motionZ));
218
        motionX /= distance;
219
        motionY /= distance;
220
        motionZ /= distance;
221
        motionX *= 1.5f;
222
        motionY *= 1.5f;
223
        motionZ *= 1.5f;
224
        if (!mc.player.onGround()) motionY += mc.player.getDeltaMovement().y();
225
        return traceTrajectory(x, y, z, motionX, motionY, motionZ);
226
    }
227
228
    private BlockPos traceTrajectory(double x, double y, double z, double mx, double my, double mz) {
229
        Vec3 lastPos;
230
        for (int i = 0; i < 300; i++) {
231
            lastPos = new Vec3(x, y, z);
232
            x += mx;
233
            y += my;
234
            z += mz;
235
            mx *= 0.99;
236
            my *= 0.99;
237
            mz *= 0.99;
238
            my -= 0.03f;
239
            Vec3 pos = new Vec3(x, y, z);
240
            BlockHitResult bhr = mc.level.clip(new ClipContext(lastPos, pos, ClipContext.Block.OUTLINE, ClipContext.Fluid.NONE, mc.player));
241
            if (bhr != null && bhr.getType() == HitResult.Type.BLOCK) return bhr.getBlockPos();
242
243
            for (Entity ent : mc.level.entitiesForRendering()) {
244
                if (ent instanceof Arrow || ent == mc.player || ent instanceof ThrownEnderpearl) continue;
245
                if (ent.getBoundingBox().intersects(new AABB(x - 0.3, y - 0.3, z - 0.3, x + 0.3, y + 0.3, z + 0.2)))
246
                    return null;
247
            }
248
249
            if (y <= -65) break;
250
        }
251
        return null;
252
    }
253
}
254