AutoWasp module

AutoWasp: Minecraft 26.3 cheat module, full source for every implementation (1 client: OfflineClient).

1 implementationMOVEMENT

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.

OfflineClientMOVEMENTsrc/main/java/com/jellypudding/offlineclient/modules/movement/AutoWasp.javaJava · 203 lines · 7.8 KB

Flies you straight at a player on your elytra.

SettingsHorizontal speedVertical speedAvoid landingPredict movementOnly friendsOn target lossOffset xOffset yOffset z
AutoWasp.javaJava · Minecraft 26.2 · 203 lines · 7.8 KB · complete file, verbatimOriginal ↗
1
package com.jellypudding.offlineclient.modules.movement;
2
3
import com.jellypudding.offlineclient.event.Subscribe;
4
import com.jellypudding.offlineclient.event.events.TickEvent;
5
import com.jellypudding.offlineclient.module.Category;
6
import com.jellypudding.offlineclient.module.Module;
7
import com.jellypudding.offlineclient.setting.BoolSetting;
8
import com.jellypudding.offlineclient.setting.EnumSetting;
9
import com.jellypudding.offlineclient.setting.NumberSetting;
10
import com.jellypudding.offlineclient.util.BlockUtil;
11
import com.jellypudding.offlineclient.util.ChatUtil;
12
import com.jellypudding.offlineclient.util.EntityUtil;
13
import net.minecraft.core.BlockPos;
14
import net.minecraft.core.Direction;
15
import net.minecraft.network.chat.Component;
16
import net.minecraft.world.entity.EquipmentSlot;
17
import net.minecraft.world.entity.LivingEntity;
18
import net.minecraft.world.entity.player.Player;
19
import net.minecraft.world.phys.Vec3;
20
21
// Flies straight at a chosen player on an elytra. It assumes a clear line.
22
public final class AutoWasp extends Module {
23
24
    public enum OnLoss { SWITCH_OFF, NEW_TARGET, DISCONNECT }
25
26
    // Ticks after the jump before the wings open.
27
    private static final int OPEN_DELAY = 4;
28
29
    // How close to the block top the target must stand to count as landed.
30
    private static final double LANDED = 0.25;
31
32
    // Height above a landed target to hover at.
33
    private static final double HOVER = 1.25;
34
35
    private static final double TINY = 1.0E-5;
36
37
    private final NumberSetting horizontalSpeed = new NumberSetting("Horizontal speed",
38
        "Blocks a tick along the ground.", 2, 0.1, 10, 0.1, " blocks").min(0);
39
    private final NumberSetting verticalSpeed = new NumberSetting("Vertical speed",
40
        "Blocks a tick up or down.", 3, 0.1, 10, 0.1, " blocks").min(0);
41
    private final BoolSetting avoidLanding = new BoolSetting("Avoid landing",
42
        "Hovers just above a target that stands on the ground so you keep gliding.", true);
43
    private final BoolSetting predictMovement = new BoolSetting("Predict movement",
44
        "Aims where the target is heading rather than where they are.", true);
45
    private final BoolSetting onlyFriends = new BoolSetting("Only friends",
46
        "Only follows players on your friend list.", false);
47
    private final EnumSetting<OnLoss> onLoss = new EnumSetting<>("On target loss",
48
        "What happens when the target vanishes.", OnLoss.SWITCH_OFF)
49
        .describe(OnLoss.SWITCH_OFF, "Switches the module off.")
50
        .describe(OnLoss.NEW_TARGET, "Picks the nearest player as the new target.")
51
        .describe(OnLoss.DISCONNECT, "Leaves the server.");
52
    private final NumberSetting offsetX = new NumberSetting("Offset x",
53
        "Blocks east of the target to aim at.", 0, -10, 10, 0.5, " blocks");
54
    private final NumberSetting offsetY = new NumberSetting("Offset y",
55
        "Blocks above the target to aim at.", 0, -10, 10, 0.5, " blocks");
56
    private final NumberSetting offsetZ = new NumberSetting("Offset z",
57
        "Blocks south of the target to aim at.", 0, -10, 10, 0.5, " blocks");
58
59
    private Player target;
60
    private int jumpTimer;
61
    private boolean jumped;
62
63
    public AutoWasp() {
64
        super("AutoWasp", "Flies you straight at a player on your elytra.", Category.MOVEMENT);
65
        addSettings(horizontalSpeed, verticalSpeed, avoidLanding, predictMovement, onlyFriends,
66
            onLoss, offsetX, offsetY, offsetZ);
67
        searchTags("wasp", "elytra chase", "follow");
68
    }
69
70
    @Override
71
    public String getSuffix() {
72
        return target == null ? null : EntityUtil.nameOf(target);
73
    }
74
75
    @Override
76
    protected void onEnable() {
77
        jumpTimer = 0;
78
        jumped = false;
79
        if (!pickTarget()) {
80
            ChatUtil.error("AutoWasp found no player to follow.");
81
            setEnabled(false);
82
        }
83
    }
84
85
    @Override
86
    protected void onDisable() {
87
        target = null;
88
    }
89
90
    // Read by LivingEntityMixin. The glide velocity that heads for the target
91
    // or null whilst the module has nothing to steer.
92
    public Vec3 glideVelocity() {
93
        if (target == null || !inGame() || !mc.player.isFallFlying() || !wearingWings()) {
94
            return null;
95
        }
96
        Vec3 aim = aimPoint();
97
        double dx = aim.x - mc.player.getX();
98
        double dz = aim.z - mc.player.getZ();
99
        double flat = Math.sqrt(dx * dx + dz * dz);
100
        double along = Math.min(flat, horizontalSpeed.getValue());
101
        double vx = flat > TINY ? dx / flat * along : 0;
102
        double vz = flat > TINY ? dz / flat * along : 0;
103
        double dy = aim.y - mc.player.getY();
104
        double vy = 0;
105
        if (Math.abs(dy) > TINY) {
106
            vy = Math.signum(dy) * Math.min(Math.abs(dy), verticalSpeed.getValue());
107
        }
108
        return new Vec3(vx, vy, vz);
109
    }
110
111
    @Subscribe
112
    private void onTick(TickEvent event) {
113
        if (!inGame()) {
114
            return;
115
        }
116
        if (target == null || target.isRemoved()) {
117
            targetLost();
118
            if (!isEnabled()) {
119
                return;
120
            }
121
        }
122
        if (!wearingWings()) {
123
            return;
124
        }
125
        if (mc.player.isFallFlying()) {
126
            jumped = false;
127
            jumpTimer = 0;
128
            return;
129
        }
130
        if (mc.player.onGround()) {
131
            mc.player.jumpFromGround();
132
            jumped = true;
133
            jumpTimer = 0;
134
            return;
135
        }
136
        if (!jumped) {
137
            return;
138
        }
139
        // The server refuses a glide start before the jump has cleared the ground.
140
        if (++jumpTimer >= OPEN_DELAY) {
141
            jumpTimer = 0;
142
            mc.player.setJumping(false);
143
            mc.player.setSprinting(true);
144
            ElytraFly.sendStartGlide();
145
        }
146
    }
147
148
    private void targetLost() {
149
        ChatUtil.message("AutoWasp lost its target.");
150
        switch (onLoss.getValue()) {
151
            case SWITCH_OFF -> setEnabled(false);
152
            case NEW_TARGET -> {
153
                if (!pickTarget()) {
154
                    ChatUtil.error("AutoWasp found no new player to follow.");
155
                    setEnabled(false);
156
                }
157
            }
158
            case DISCONNECT -> mc.player.connection.getConnection()
159
                .disconnect(Component.literal("§b[§3Offline§b] §fAutoWasp lost its target."));
160
        }
161
    }
162
163
    private boolean pickTarget() {
164
        target = (Player) EntityUtil.nearest(Double.MAX_VALUE, entity -> entity instanceof Player player
165
            && !player.isDeadOrDying() && player.getHealth() > 0
166
            && (!onlyFriends.isOn() || EntityUtil.isFriend(player)));
167
        if (target != null) {
168
            ChatUtil.message("AutoWasp is following " + EntityUtil.nameOf(target) + ".");
169
        }
170
        return target != null;
171
    }
172
173
    private boolean wearingWings() {
174
        return LivingEntity.canGlideUsing(mc.player.getItemBySlot(EquipmentSlot.CHEST),
175
            EquipmentSlot.CHEST);
176
    }
177
178
    private Vec3 aimPoint() {
179
        Vec3 aim = target.position().add(offsetX.getValue(), offsetY.getValue(), offsetZ.getValue());
180
        if (predictMovement.isOn()) {
181
            aim = aim.add(target.getDeltaMovement());
182
        }
183
        if (avoidLanding.isOn()) {
184
            aim = hoverAbove(aim);
185
        }
186
        return aim;
187
    }
188
189
    // A target standing on a block gets a hover point a little above it.
190
    private Vec3 hoverAbove(Vec3 aim) {
191
        double half = target.getBbWidth() / 2;
192
        for (Direction side : Direction.Plane.HORIZONTAL) {
193
            Vec3 corner = aim.relative(side, half).relative(side.getClockWise(), half);
194
            BlockPos below = BlockPos.containing(corner).below();
195
            boolean solid = !BlockUtil.state(below).getCollisionShape(mc.level, below).isEmpty();
196
            if (solid && Math.abs(aim.y - (below.getY() + 1)) <= LANDED) {
197
                return new Vec3(aim.x, below.getY() + HOVER, aim.z);
198
            }
199
        }
200
        return aim;
201
    }
202
}
203