jesus module

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

3 implementationsMovementMOVEMENT

Full module source: 3 implementations

Every implementation below is the complete module file, verbatim. Expand a client to read its code.

Meteor ClientMovementsrc/main/java/meteordevelopment/meteorclient/systems/modules/movement/Jesus.javaJava · 361 lines · 14.1 KB

Walk on liquids and powder snow like Jesus.

Settingspowder-snowncp-bypassslow-downmodedip-if-burningdip-on-sneakdip-on-falldip-fall-heightdip-if-resistant
Jesus.javaJava · Minecraft 26.2 · 361 lines · 14.1 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.movement;
7
8
import com.mojang.datafixers.util.Pair;
9
import meteordevelopment.meteorclient.events.entity.player.CanWalkOnFluidEvent;
10
import meteordevelopment.meteorclient.events.entity.player.PlayerMoveEvent;
11
import meteordevelopment.meteorclient.events.packets.PacketEvent;
12
import meteordevelopment.meteorclient.events.world.CollisionShapeEvent;
13
import meteordevelopment.meteorclient.events.world.TickEvent;
14
import meteordevelopment.meteorclient.mixin.EntityMixin;
15
import meteordevelopment.meteorclient.mixin.ServerboundMovePlayerPacketAccessor;
16
import meteordevelopment.meteorclient.mixininterface.IVec3;
17
import meteordevelopment.meteorclient.pathing.PathManagers;
18
import meteordevelopment.meteorclient.settings.*;
19
import meteordevelopment.meteorclient.systems.modules.Categories;
20
import meteordevelopment.meteorclient.systems.modules.Module;
21
import meteordevelopment.meteorclient.systems.modules.Modules;
22
import meteordevelopment.meteorclient.systems.modules.movement.speed.modes.Strafe;
23
import meteordevelopment.meteorclient.utils.entity.EntityUtils;
24
import meteordevelopment.meteorclient.utils.player.PlayerUtils;
25
import meteordevelopment.orbit.EventHandler;
26
import net.minecraft.network.protocol.game.ServerboundMovePlayerPacket;
27
import net.minecraft.world.effect.MobEffects;
28
import net.minecraft.world.entity.Entity;
29
import net.minecraft.world.entity.ai.attributes.Attributes;
30
import net.minecraft.world.entity.monster.Strider;
31
import net.minecraft.world.entity.vehicle.boat.AbstractBoat;
32
import net.minecraft.world.level.GameType;
33
import net.minecraft.world.level.block.Blocks;
34
import net.minecraft.world.level.block.state.BlockState;
35
import net.minecraft.world.level.block.state.properties.BlockStateProperties;
36
import net.minecraft.world.level.material.Fluids;
37
import net.minecraft.world.phys.AABB;
38
import net.minecraft.world.phys.shapes.Shapes;
39
import org.joml.Vector2d;
40
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
41
42
public class Jesus extends Module {
43
    private final SettingGroup sgGeneral = settings.createGroup("General");
44
    private final SettingGroup sgWater = settings.createGroup("Water");
45
    private final SettingGroup sgLava = settings.createGroup("Lava");
46
47
    // General
48
49
    private final Setting<Boolean> powderSnow = sgGeneral.add(new BoolSetting.Builder()
50
        .name("powder-snow")
51
        .description("Walk on powder snow.")
52
        .defaultValue(true)
53
        .build()
54
    );
55
56
    /**
57
     * @see <a href="https://github.com/lambda-client/lambda/blob/9490eec0e81faf33a318ac1cabbdeb4f4c4f6850/src/main/kotlin/com/lambda/module/modules/movement/Jesus.kt">"NCP New" mode</a>
58
     * Author: bladekt
59
     */
60
    private final Setting<Boolean> ncpBypass = sgGeneral.add(new BoolSetting.Builder()
61
        .name("ncp-bypass")
62
        .description("Whether to apply a bypass for NCP.")
63
        .defaultValue(false)
64
        .build()
65
    );
66
67
    private final Setting<Boolean> slowDown = sgGeneral.add(new BoolSetting.Builder()
68
        .name("slow-down")
69
        .description("Further movement option to try bypassing NCP")
70
        .defaultValue(false)
71
        .visible(ncpBypass::get)
72
        .build()
73
    );
74
75
    // Water
76
77
    private final Setting<Mode> waterMode = sgWater.add(new EnumSetting.Builder<Mode>()
78
        .name("mode")
79
        .description("How to treat the water.")
80
        .defaultValue(Mode.Solid)
81
        .build()
82
    );
83
84
    private final Setting<Boolean> dipIfBurning = sgWater.add(new BoolSetting.Builder()
85
        .name("dip-if-burning")
86
        .description("Lets you go into the water when you are burning.")
87
        .defaultValue(true)
88
        .visible(() -> waterMode.get() == Mode.Solid)
89
        .build()
90
    );
91
92
    private final Setting<Boolean> dipOnSneakWater = sgWater.add(new BoolSetting.Builder()
93
        .name("dip-on-sneak")
94
        .description("Lets you go into the water when your sneak key is held.")
95
        .defaultValue(true)
96
        .visible(() -> waterMode.get() == Mode.Solid)
97
        .build()
98
    );
99
100
    private final Setting<Boolean> dipOnFallWater = sgWater.add(new BoolSetting.Builder()
101
        .name("dip-on-fall")
102
        .description("Lets you go into the water when you fall over a certain height.")
103
        .defaultValue(true)
104
        .visible(() -> waterMode.get() == Mode.Solid)
105
        .build()
106
    );
107
108
    private final Setting<Integer> dipFallHeightWater = sgWater.add(new IntSetting.Builder()
109
        .name("dip-fall-height")
110
        .description("The fall height at which you will go into the water.")
111
        .defaultValue(4)
112
        .range(1, 255)
113
        .sliderRange(3, 20)
114
        .visible(() -> waterMode.get() == Mode.Solid && dipOnFallWater.get())
115
        .build()
116
    );
117
118
    // Lava
119
120
    private final Setting<Mode> lavaMode = sgLava.add(new EnumSetting.Builder<Mode>()
121
        .name("mode")
122
        .description("How to treat the lava.")
123
        .defaultValue(Mode.Solid)
124
        .build()
125
    );
126
127
    private final Setting<Boolean> dipIfFireResistant = sgLava.add(new BoolSetting.Builder()
128
        .name("dip-if-resistant")
129
        .description("Lets you go into the lava if you have Fire Resistance effect.")
130
        .defaultValue(true)
131
        .visible(() -> lavaMode.get() == Mode.Solid)
132
        .build()
133
    );
134
135
    private final Setting<Boolean> dipOnSneakLava = sgLava.add(new BoolSetting.Builder()
136
        .name("dip-on-sneak")
137
        .description("Lets you go into the lava when your sneak key is held.")
138
        .defaultValue(true)
139
        .visible(() -> lavaMode.get() == Mode.Solid)
140
        .build()
141
    );
142
143
    private final Setting<Boolean> dipOnFallLava = sgLava.add(new BoolSetting.Builder()
144
        .name("dip-on-fall")
145
        .description("Lets you go into the lava when you fall over a certain height.")
146
        .defaultValue(true)
147
        .visible(() -> lavaMode.get() == Mode.Solid)
148
        .build()
149
    );
150
151
    private final Setting<Integer> dipFallHeightLava = sgLava.add(new IntSetting.Builder()
152
        .name("dip-fall-height")
153
        .description("The fall height at which you will go into the lava.")
154
        .defaultValue(4)
155
        .range(1, 255)
156
        .sliderRange(3, 20)
157
        .visible(() -> lavaMode.get() == Mode.Solid && dipOnFallLava.get())
158
        .build()
159
    );
160
161
    // Other
162
163
    private int ascending = 10;
164
    private int swimmingTicks = 0;
165
166
    private boolean prePathManagerWalkOnWater;
167
    private boolean prePathManagerWalkOnLava;
168
169
    /**
170
     * {@link EntityMixin#onBubbleColumn(CallbackInfo)}
171
     */
172
    public boolean isInBubbleColumn = false;
173
174
    public Jesus() {
175
        super(Categories.Movement, "jesus", "Walk on liquids and powder snow like Jesus.");
176
    }
177
178
    @Override
179
    public void onActivate() {
180
        prePathManagerWalkOnWater = PathManagers.get().getSettings().getWalkOnWater().get();
181
        prePathManagerWalkOnLava = PathManagers.get().getSettings().getWalkOnLava().get();
182
183
        PathManagers.get().getSettings().getWalkOnWater().set(waterMode.get() == Mode.Solid);
184
        PathManagers.get().getSettings().getWalkOnLava().set(lavaMode.get() == Mode.Solid);
185
    }
186
187
    @Override
188
    public void onDeactivate() {
189
        PathManagers.get().getSettings().getWalkOnWater().set(prePathManagerWalkOnWater);
190
        PathManagers.get().getSettings().getWalkOnLava().set(prePathManagerWalkOnLava);
191
    }
192
193
    @EventHandler
194
    private void onTick(TickEvent.Post event) {
195
        boolean bubbleColumn = isInBubbleColumn;
196
        isInBubbleColumn = false;
197
198
        if (mc.player.isVisuallySwimming()) return;
199
        if (mc.player.isInWater() && !waterShouldBeSolid()) return;
200
        if (mc.player.isInLava() && !lavaShouldBeSolid()) return;
201
202
        Entity movingEntity = mc.player.isPassenger() ? mc.player.getVehicle() : mc.player;
203
204
        // Move up in bubble columns
205
        if (bubbleColumn) {
206
            if (mc.options.keyJump.isDown() && movingEntity.getDeltaMovement().y() < 0.11)
207
                ((IVec3) movingEntity.getDeltaMovement()).meteor$setY(0.11);
208
            return;
209
        }
210
211
        // Move up
212
        if (movingEntity.isInWater() || movingEntity.isInLava()) {
213
            ((IVec3) movingEntity.getDeltaMovement()).meteor$setY(0.11);
214
            ascending = 0;
215
            return;
216
        }
217
218
        BlockState blockBelowState = mc.level.getBlockState(movingEntity.blockPosition().below());
219
        boolean waterLogged = blockBelowState.getValueOrElse(BlockStateProperties.WATERLOGGED, false);
220
221
        if (ascending == 0) ((IVec3) movingEntity.getDeltaMovement()).meteor$setY(0.11);
222
        else if (ascending == 1 && (blockBelowState.getBlock() == Blocks.WATER || blockBelowState.getBlock() == Blocks.LAVA || waterLogged))
223
            ((IVec3) movingEntity.getDeltaMovement()).meteor$setY(0);
224
225
        ascending++;
226
    }
227
228
    @EventHandler
229
    private void onCanWalkOnFluid(CanWalkOnFluidEvent event) {
230
        if (mc.player != null && mc.player.isSwimming()) return;
231
232
        if ((event.fluidState.getType() == Fluids.WATER || event.fluidState.getType() == Fluids.FLOWING_WATER) && waterShouldBeSolid()) {
233
            event.walkOnFluid = true;
234
        } else if ((event.fluidState.getType() == Fluids.LAVA || event.fluidState.getType() == Fluids.FLOWING_LAVA) && lavaShouldBeSolid()) {
235
            event.walkOnFluid = true;
236
        }
237
    }
238
239
    @EventHandler
240
    private void onFluidCollisionShape(CollisionShapeEvent event) {
241
        if (event.state.getFluidState().isEmpty()) return;
242
243
        if ((event.state.getBlock() == Blocks.WATER || event.state.getFluidState().getType() == Fluids.WATER) && !mc.player.isInWater() && waterShouldBeSolid() && event.pos.getY() <= mc.player.getY() - 1) {
244
            event.shape = Shapes.block();
245
        } else if (event.state.getBlock() == Blocks.LAVA && !mc.player.isInLava() && lavaShouldBeSolid() && (isLavaDangerous() || event.pos.getY() <= mc.player.getY() - 1)) {
246
            event.shape = Shapes.block();
247
        }
248
    }
249
250
    @EventHandler
251
    private void onSendPacket(PacketEvent.Send event) {
252
        if (!(event.packet instanceof ServerboundMovePlayerPacket packet)) return;
253
        if (mc.player.isInWater() && !waterShouldBeSolid()) return;
254
        if (mc.player.isInLava() && !lavaShouldBeSolid()) return;
255
        if (!ncpBypass.get()) return;
256
257
        // Check inWater, fallDistance and if over liquid
258
        Pair<Boolean, Boolean> overLiquid = isOverLiquid();
259
        boolean shouldWork = (overLiquid.getFirst() && waterShouldBeSolid()) || (overLiquid.getSecond() && lavaShouldBeSolid());
260
261
        if (mc.player.isInWater() || mc.player.isInLava() || mc.player.fallDistance > 3f || !shouldWork) return;
262
263
        ((ServerboundMovePlayerPacketAccessor) packet).meteor$setOnGround(false);
264
        if (!mc.player.onGround() || !packet.hasPosition()) return;
265
266
        ((ServerboundMovePlayerPacketAccessor) packet).meteor$setY(packet.getY(0) - (0.02 + (0.0001 * swimmingTicks)));
267
    }
268
269
    @EventHandler
270
    private void onMoveEvent(PlayerMoveEvent event) {
271
        if (!ncpBypass.get()) return;
272
273
        Pair<Boolean, Boolean> overLiquid = isOverLiquid();
274
        boolean water = overLiquid.getFirst() && waterShouldBeSolid();
275
        boolean lava = overLiquid.getSecond() && lavaShouldBeSolid();
276
277
        if (!water && !lava) {
278
            swimmingTicks = 0;
279
            return;
280
        }
281
282
        if (++swimmingTicks < 15) {
283
            if (mc.player.onGround()) {
284
                Vector2d vel = Strafe.transformStrafe(PlayerUtils.isMoving() ? 0.2873 : 0);
285
                ((IVec3) event.movement).meteor$setXZ(vel.x, vel.y);
286
            }
287
288
            return;
289
        }
290
291
        swimmingTicks = 0;
292
        if (slowDown.get()) ((IVec3) event.movement).meteor$setXZ(0, 0);
293
        ((IVec3) mc.player.getDeltaMovement()).meteor$setY(0.08);
294
    }
295
296
    private boolean waterShouldBeSolid() {
297
        if (EntityUtils.getGameMode(mc.player) == GameType.SPECTATOR || mc.player.getAbilities().flying) return false;
298
299
        if (mc.player.getVehicle() != null) {
300
            if (mc.player.getVehicle() instanceof AbstractBoat) return false;
301
        }
302
303
        if (Modules.get().get(Flight.class).isActive()) return false;
304
305
        if (dipIfBurning.get() && mc.player.isOnFire()) return false;
306
        if (dipOnSneakWater.get() && mc.options.keyShift.isDown()) return false;
307
        if (dipOnFallWater.get() && mc.player.fallDistance > dipFallHeightWater.get()) return false;
308
309
        return waterMode.get() == Mode.Solid;
310
    }
311
312
    private boolean lavaShouldBeSolid() {
313
        if (EntityUtils.getGameMode(mc.player) == GameType.SPECTATOR || mc.player.getAbilities().flying) return false;
314
315
        if (mc.player.getVehicle() != null) {
316
            if (mc.player.getVehicle() instanceof Strider) return false;
317
        }
318
319
        if (isLavaDangerous() && lavaMode.get() == Mode.Solid) return true;
320
321
        if (dipOnSneakLava.get() && mc.options.keyShift.isDown()) return false;
322
        if (dipOnFallLava.get() && mc.player.fallDistance > dipFallHeightLava.get()) return false;
323
324
        return lavaMode.get() == Mode.Solid;
325
    }
326
327
    private boolean isLavaDangerous() {
328
        if (!dipIfFireResistant.get()) return true;
329
        return !mc.player.hasEffect(MobEffects.FIRE_RESISTANCE) || (mc.player.getEffect(MobEffects.FIRE_RESISTANCE).getDuration() <= (15 * 20 * mc.player.getAttributeValue(Attributes.BURNING_TIME)));
330
    }
331
332
    private Pair<Boolean, Boolean> isOverLiquid() {
333
        AABB box = mc.player.isPassenger() ? mc.player.getBoundingBox().minmax(mc.player.getVehicle().getBoundingBox()) : mc.player.getBoundingBox();
334
        BlockState[] states = mc.level.getBlockStatesIfLoaded(box.move(0.0, -0.01, 0.0)).toArray(BlockState[]::new);
335
336
        boolean water = false, lava = false;
337
        boolean foundSolid = false;
338
339
        for (BlockState state : states) {
340
            if (state.getBlock() == Blocks.WATER || state.getFluidState().getType() == Fluids.WATER) water = true;
341
            else if (state.getBlock() == Blocks.LAVA) lava = true;
342
343
            else if (!state.isAir()) {
344
                foundSolid = true;
345
                break;
346
            }
347
        }
348
349
        return Pair.of(water && !foundSolid, lava && !foundSolid);
350
    }
351
352
    public enum Mode {
353
        Solid,
354
        Ignore
355
    }
356
357
    public boolean canWalkOnPowderSnow() {
358
        return isActive() && powderSnow.get();
359
    }
360
}
361
MelaHack (ThunderHack fork)MOVEMENTsrc/main/java/thunder/hack/features/modules/movement/Jesus.javaJava · 40 lines · 1.3 KB

Allows you to walk on water.

SettingsMode
Jesus.javaJava · Minecraft 26.2 · 40 lines · 1.3 KB · complete file, verbatimOriginal ↗
1
package thunder.hack.features.modules.movement;
2
3
import meteordevelopment.orbit.EventHandler;
4
import net.minecraft.world.level.block.*;
5
import thunder.hack.core.manager.client.ModuleManager;
6
import thunder.hack.events.impl.EventCollision;
7
import thunder.hack.features.modules.Module;
8
import thunder.hack.features.modules.client.Religion;
9
import thunder.hack.setting.Setting;
10
11
import static thunder.hack.features.modules.client.ClientSettings.isRu;
12
13
public class Jesus extends Module {
14
    public Jesus() {
15
        super("Jesus", Category.MOVEMENT);
16
    }
17
18
    public final Setting<Mode> mode = new Setting<>("Mode", Mode.SOLID);
19
20
    @EventHandler
21
    @SuppressWarnings("unused")
22
    public void onCollide(EventCollision e) {
23
        if (e.getState().getBlock() instanceof LiquidBlock) {
24
            e.setState(mode.is(Mode.SOLID) ? Blocks.ENDER_CHEST.defaultBlockState() : Blocks.OBSIDIAN.defaultBlockState());
25
        }
26
    }
27
28
    @Override
29
    public void onEnable() {
30
        if (ModuleManager.religion.isOn() && !ModuleManager.religion.ReligionSetting.is(Religion.YourReligion.Christianity)) {
31
            ModuleManager.religion.sendMessage(isRu() ? "Ты не веришь в Иисуса!" : "You do not believe in Jesus!");
32
            disable();
33
        }
34
    }
35
36
    public enum Mode {
37
        SOLID, SOLID2
38
    }
39
}
40
OfflineClientMOVEMENTsrc/main/java/com/jellypudding/offlineclient/modules/movement/Jesus.javaJava · 401 lines · 16.3 KB

Walk on water and lava.

SettingsModeWaterDip when burningSneak to dipDip fallLavaDip when resistantLava sneak to dipLava dip fallClimb onRise to surfaceWhilst ridingServer bypassSlow downPowder snow
Jesus.javaJava · Minecraft 26.2 · 401 lines · 16.3 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.PacketSendEvent;
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.setting.BoolSetting;
9
import com.jellypudding.offlineclient.setting.EnumSetting;
10
import com.jellypudding.offlineclient.setting.NumberSetting;
11
import com.jellypudding.offlineclient.util.MovementUtil;
12
import com.jellypudding.offlineclient.util.PacketUtil;
13
import net.minecraft.client.multiplayer.ClientLevel;
14
import net.minecraft.client.player.LocalPlayer;
15
import net.minecraft.core.BlockPos;
16
import net.minecraft.network.protocol.game.ServerboundMovePlayerPacket;
17
import net.minecraft.tags.FluidTags;
18
import net.minecraft.world.effect.MobEffectInstance;
19
import net.minecraft.world.effect.MobEffects;
20
import net.minecraft.world.entity.Entity;
21
import net.minecraft.world.entity.ai.attributes.Attributes;
22
import net.minecraft.world.entity.monster.Strider;
23
import net.minecraft.world.entity.vehicle.boat.AbstractBoat;
24
import net.minecraft.world.level.block.Blocks;
25
import net.minecraft.world.level.block.state.BlockState;
26
import net.minecraft.world.level.material.FluidState;
27
import net.minecraft.world.phys.AABB;
28
import net.minecraft.world.phys.Vec3;
29
import net.minecraft.world.phys.shapes.Shapes;
30
import net.minecraft.world.phys.shapes.VoxelShape;
31
32
// Solid mode makes liquid underfoot solid via BlockCollisionsMixin.
33
// Dolphin mode pushes the player up each tick.
34
public final class Jesus extends Module {
35
36
    public enum Mode { SOLID, DOLPHIN }
37
    public enum Bypass { WOBBLE, NCP, NONE }
38
    private enum Liquid { NONE, WATER, LAVA }
39
40
    // Upward speed whilst climbing out of the liquid.
41
    private static final double RISE_SPEED = 0.11;
42
    // Extra lift per tick whilst bobbing in dolphin mode.
43
    private static final double DOLPHIN_LIFT = 0.04;
44
45
    // Ticks out of the water before the surface counts as solid again.
46
    private static final int SETTLED = 10;
47
    // How far the sent height wobbles above and below the real one.
48
    private static final double PACKET_WOBBLE = 0.05;
49
50
    // Fire Resistance with less than this left is not worth swimming on.
51
    private static final int SHORT_RESISTANCE_TICKS = 15 * 20;
52
53
    // The old NoCheatPlus trick. Ticks of a plain walk between hops and the
54
    // hop itself and how the sent height creeps down each tick.
55
    private static final int NCP_HOP_EVERY = 15;
56
    private static final double NCP_WALK_SPEED = 0.2873;
57
    private static final double NCP_HOP = 0.08;
58
    private static final double NCP_SINK = 0.02;
59
    private static final double NCP_SINK_STEP = 0.0001;
60
    private static final float NCP_MAX_FALL = 3;
61
62
    private final EnumSetting<Mode> mode = new EnumSetting<>("Mode",
63
        "How the liquid holds you.", Mode.SOLID)
64
        .describe(Mode.SOLID, "Lets you stand and walk on the surface.")
65
        .describe(Mode.DOLPHIN, "Keeps you swimming along the top instead.");
66
    private final BoolSetting water = new BoolSetting("Water",
67
        "Walk on water.", true)
68
        .under(mode, Mode.SOLID);
69
    private final BoolSetting dipIfBurning = new BoolSetting("Dip when burning",
70
        "Water stops holding you whilst you are on fire so you drop in and put it out.", true)
71
        .under(water);
72
    private final BoolSetting sneakToDip = new BoolSetting("Sneak to dip",
73
        "Hold sneak to sink into the water.", true)
74
        .under(water);
75
    private final NumberSetting dipFall = new NumberSetting("Dip fall",
76
        "Fall further than this into water and you sink instead of landing. 0 always catches you.",
77
        4, 0, 20, 0.5, " blocks")
78
        .under(water);
79
    private final BoolSetting lava = new BoolSetting("Lava",
80
        "Also walk on lava.", false)
81
        .under(mode, Mode.SOLID);
82
    private final BoolSetting dipIfResistant = new BoolSetting("Dip when resistant",
83
        "Lava stops holding you whilst Fire Resistance has over 15 seconds left so you can swim through.", true)
84
        .under(lava);
85
    private final BoolSetting lavaSneakToDip = new BoolSetting("Lava sneak to dip",
86
        "Hold sneak to sink into the lava.", true)
87
        .under(lava);
88
    private final NumberSetting lavaDipFall = new NumberSetting("Lava dip fall",
89
        "Fall further than this into lava and you sink instead of landing. 0 always catches you.",
90
        0, 0, 20, 0.5, " blocks")
91
        .under(lava);
92
    private final BoolSetting climbOn = new BoolSetting("Climb on",
93
        "Liquid level with your feet counts as solid. You step or jump onto it instead of wading in.", true)
94
        .under(mode, Mode.SOLID);
95
    private final BoolSetting riseToSurface = new BoolSetting("Rise to surface",
96
        "Pushes you up out of the liquid when you are in it. Off lets you swim about as normal.", true)
97
        .under(mode, Mode.SOLID);
98
    private final BoolSetting riding = new BoolSetting("Whilst riding",
99
        "Also holds whatever you ride on the surface. Boats on water and striders on lava are left alone.", true)
100
        .under(mode, Mode.SOLID);
101
    private final EnumSetting<Bypass> bypass = new EnumSetting<>("Server bypass",
102
        "How the packets hide the walk from an anti cheat.", Bypass.WOBBLE)
103
        .describe(Bypass.WOBBLE, "Makes standing on liquid look like bobbing to the server.")
104
        .describe(Bypass.NCP, "Never claims ground and creeps the sent height down whilst a hop every 15 ticks keeps you up.")
105
        .describe(Bypass.NONE, "Sends the packets as they are.")
106
        .under(mode, Mode.SOLID);
107
    private final BoolSetting slowDown = new BoolSetting("Slow down",
108
        "Stops you dead on each hop as well.", false)
109
        .under(bypass, Bypass.NCP);
110
    private final BoolSetting powderSnow = new BoolSetting("Powder snow",
111
        "Also walk on powder snow.", true);
112
113
    private int ticksSinceExit = SETTLED;
114
    private int swimmingTicks;
115
116
    public Jesus() {
117
        super("Jesus", "Walk on water and lava.", Category.MOVEMENT);
118
        addSettings(mode, water, dipIfBurning, sneakToDip, dipFall, lava, dipIfResistant,
119
            lavaSneakToDip, lavaDipFall, climbOn, riseToSurface, riding, bypass, slowDown,
120
            powderSnow);
121
        searchTags("water walking", "waterwalk", "lava walking");
122
    }
123
124
    @Override
125
    public String getSuffix() {
126
        return mode.getValueString();
127
    }
128
129
    @Override
130
    protected void onEnable() {
131
        ticksSinceExit = SETTLED;
132
        swimmingTicks = 0;
133
    }
134
135
    private boolean active() {
136
        LocalPlayer player = mc.player;
137
        return player != null && mc.level != null && active(player);
138
    }
139
140
    // The packet thread holds its own reference. A second read can come back null.
141
    private boolean active(LocalPlayer player) {
142
        if (player.isSpectator() || player.getAbilities().flying) {
143
            return false;
144
        }
145
        return !player.isPassenger() || riding.isOn();
146
    }
147
148
    // The thing being carried. The vehicle whilst riding and the player otherwise.
149
    private Entity mover(LocalPlayer player) {
150
        Entity vehicle = player.getVehicle();
151
        return vehicle != null && riding.isOn() ? vehicle : player;
152
    }
153
154
    private boolean sneakingToDip() {
155
        return sneakToDip.isOn() && mc.options.keyShift.isDown();
156
    }
157
158
    private static boolean fallenPast(LocalPlayer player, NumberSetting limit) {
159
        return limit.getValue() > 0 && player.fallDistance > limit.getValue();
160
    }
161
162
    // True whilst water ought to hold the player up.
163
    private boolean waterWanted() {
164
        LocalPlayer player = mc.player;
165
        if (!mode.is(Mode.SOLID) || !water.isOn() || !active()) {
166
            return false;
167
        }
168
        if (player.getVehicle() instanceof AbstractBoat) {
169
            return false;
170
        }
171
        if (dipIfBurning.isOn() && player.isOnFire()) {
172
            return false;
173
        }
174
        return !sneakingToDip() && !fallenPast(player, dipFall);
175
    }
176
177
    // True whilst lava ought to hold the player up.
178
    private boolean lavaWanted() {
179
        LocalPlayer player = mc.player;
180
        if (!mode.is(Mode.SOLID) || !lava.isOn() || !active()) {
181
            return false;
182
        }
183
        if (player.getVehicle() instanceof Strider) {
184
            return false;
185
        }
186
        if (dipIfResistant.isOn() && longFireResistance(player)) {
187
            return false;
188
        }
189
        if (lavaSneakToDip.isOn() && mc.options.keyShift.isDown()) {
190
            return false;
191
        }
192
        return !fallenPast(player, lavaDipFall);
193
    }
194
195
    // Enough Fire Resistance to swim through lava. Burning time scales the threshold.
196
    private static boolean longFireResistance(LocalPlayer player) {
197
        MobEffectInstance effect = player.getEffect(MobEffects.FIRE_RESISTANCE);
198
        if (effect == null) {
199
            return false;
200
        }
201
        if (effect.isInfiniteDuration()) {
202
            return true;
203
        }
204
        return effect.getDuration() > SHORT_RESISTANCE_TICKS
205
            * player.getAttributeValue(Attributes.BURNING_TIME);
206
    }
207
208
    // Read by PowderSnowBlockMixin.
209
    public boolean walksOnPowderSnow() {
210
        return isEnabled() && powderSnow.isOn() && active() && !sneakingToDip()
211
            && !fallenPast(mc.player, dipFall);
212
    }
213
214
    // Called for every block the player or the ridden vehicle collides with.
215
    public VoxelShape adjustShape(Entity entity, BlockState state, BlockPos pos, VoxelShape original) {
216
        if (!isEnabled() || mc.player == null) {
217
            return original;
218
        }
219
        FluidState fluid = state.getFluidState();
220
        if (fluid.isEmpty()) {
221
            return original;
222
        }
223
        Entity mover = mover(mc.player);
224
        if (entity != mover || pos.getY() > highestSolidLevel(mover)) {
225
            return original;
226
        }
227
        if (fluid.is(FluidTags.WATER) && waterWanted() && !mover.isInWater()) {
228
            return Shapes.block();
229
        }
230
        if (fluid.is(FluidTags.LAVA) && lavaWanted() && !mover.isInLava()) {
231
            return Shapes.block();
232
        }
233
        return original;
234
    }
235
236
    // Liquid below the feet is solid. Climb on also solidifies liquid at foot level.
237
    // The wall must stay up through the jump. The player then lands on top.
238
    private double highestSolidLevel(Entity mover) {
239
        double feet = mover.getY();
240
        if (climbOn.isOn() && !mover.isInWater() && !mover.isInLava()) {
241
            return Math.floor(feet);
242
        }
243
        return feet - 1;
244
    }
245
246
    @Subscribe
247
    private void onTick(TickEvent event) {
248
        if (!active()) {
249
            return;
250
        }
251
        if (mode.is(Mode.DOLPHIN)) {
252
            dolphinTick();
253
            return;
254
        }
255
        Entity mover = mover(mc.player);
256
        Vec3 velocity = mover.getDeltaMovement();
257
258
        // The column carries the player on its own. Jump adds a push and nothing fights it.
259
        if (mover.getInBlockState().is(Blocks.BUBBLE_COLUMN)) {
260
            if (mc.options.keyJump.isDown() && velocity.y < RISE_SPEED) {
261
                mover.setDeltaMovement(velocity.x, RISE_SPEED, velocity.z);
262
            }
263
            ticksSinceExit = SETTLED;
264
            return;
265
        }
266
267
        boolean inSolidLiquid = (mover.isInWater() && waterWanted())
268
            || (mover.isInLava() && lavaWanted());
269
270
        if (inSolidLiquid) {
271
            // Swimming stays vanilla until the player climbs out on their own.
272
            if (!riseToSurface.isOn()) {
273
                ticksSinceExit = SETTLED;
274
                return;
275
            }
276
            mover.setDeltaMovement(velocity.x, RISE_SPEED, velocity.z);
277
            ticksSinceExit = 0;
278
            return;
279
        }
280
        // One more push clears the surface and then gravity sets the player down.
281
        if (ticksSinceExit == 0) {
282
            mover.setDeltaMovement(velocity.x, RISE_SPEED, velocity.z);
283
        } else if (ticksSinceExit == 1 && liquidBelow(mover)) {
284
            mover.setDeltaMovement(velocity.x, 0, velocity.z);
285
        }
286
        ticksSinceExit++;
287
288
        if (bypass.is(Bypass.NCP)) {
289
            ncpTick();
290
        }
291
    }
292
293
    private void dolphinTick() {
294
        if (mc.player.isShiftKeyDown() || !mc.player.isInWater()) {
295
            return;
296
        }
297
        Vec3 velocity = mc.player.getDeltaMovement();
298
        mc.player.setDeltaMovement(velocity.x, velocity.y + DOLPHIN_LIFT, velocity.z);
299
    }
300
301
    private boolean liquidBelow(Entity mover) {
302
        return !mc.level.getFluidState(mover.blockPosition().below()).isEmpty();
303
    }
304
305
    // Walks at a fixed pace for a few ticks then hops. The sent height creeps
306
    // down between hops. The server sees a swimmer and not a hoverer.
307
    private void ncpTick() {
308
        if (!overWantedLiquid(mc.player, mc.level)) {
309
            swimmingTicks = 0;
310
            return;
311
        }
312
        Vec3 velocity = mc.player.getDeltaMovement();
313
        if (++swimmingTicks < NCP_HOP_EVERY) {
314
            if (mc.player.onGround()) {
315
                Vec3 heading = MovementUtil.inputDirection().scale(NCP_WALK_SPEED);
316
                mc.player.setDeltaMovement(heading.x, velocity.y, heading.z);
317
            }
318
            return;
319
        }
320
        swimmingTicks = 0;
321
        double vx = slowDown.isOn() ? 0 : velocity.x;
322
        double vz = slowDown.isOn() ? 0 : velocity.z;
323
        mc.player.setDeltaMovement(vx, NCP_HOP, vz);
324
    }
325
326
    // True whilst the feet rest on a liquid the module means to hold.
327
    private boolean overWantedLiquid(LocalPlayer player, ClientLevel level) {
328
        return switch (standingOnLiquid(mover(player), level)) {
329
            case WATER -> waterWanted();
330
            case LAVA -> lavaWanted();
331
            case NONE -> false;
332
        };
333
    }
334
335
    // The liquid under the whole box. Any solid block there means none.
336
    private static Liquid standingOnLiquid(Entity mover, ClientLevel level) {
337
        AABB slice = mover.getBoundingBox().move(0, -0.01, 0);
338
        Liquid found = Liquid.NONE;
339
        for (BlockPos pos : BlockPos.betweenClosed(
340
            (int) Math.floor(slice.minX), (int) Math.floor(slice.minY), (int) Math.floor(slice.minZ),
341
            (int) Math.floor(slice.maxX), (int) Math.floor(slice.minY), (int) Math.floor(slice.maxZ))) {
342
            BlockState state = level.getBlockState(pos);
343
            FluidState fluid = state.getFluidState();
344
            if (fluid.is(FluidTags.WATER)) {
345
                found = Liquid.WATER;
346
            } else if (fluid.is(FluidTags.LAVA)) {
347
                found = Liquid.LAVA;
348
            } else if (!state.isAir()) {
349
                return Liquid.NONE;
350
            }
351
        }
352
        return found;
353
    }
354
355
    // Nothing in vanilla hovers at exactly block height over water.
356
    @Subscribe
357
    private void onPacketSend(PacketSendEvent event) {
358
        if (bypass.is(Bypass.NONE) || !mode.is(Mode.SOLID)) {
359
            return;
360
        }
361
        if (!(event.getPacket() instanceof ServerboundMovePlayerPacket packet)) {
362
            return;
363
        }
364
        // The packet thread can lose the player mid handler.
365
        LocalPlayer player = mc.player;
366
        ClientLevel level = mc.level;
367
        if (player == null || level == null || !active(player) || player.isPassenger()) {
368
            return;
369
        }
370
        if (player.isInWater() || player.isInLava() || !overWantedLiquid(player, level)) {
371
            return;
372
        }
373
        if (bypass.is(Bypass.NCP)) {
374
            event.setPacket(ncpPacket(packet, player));
375
            return;
376
        }
377
        if (!packet.hasPosition() || !player.onGround()) {
378
            return;
379
        }
380
        double x = packet.getX(player.getX());
381
        double y = packet.getY(player.getY());
382
        double z = packet.getZ(player.getZ());
383
        y += player.tickCount % 2 == 0 ? PACKET_WOBBLE : -PACKET_WOBBLE;
384
        event.setPacket(PacketUtil.withPosition(packet, player, x, y, z, true));
385
    }
386
387
    // Never claims ground. Whilst standing the sent height sinks a touch more each tick.
388
    private ServerboundMovePlayerPacket ncpPacket(ServerboundMovePlayerPacket packet,
389
                                                  LocalPlayer player) {
390
        if (player.fallDistance > NCP_MAX_FALL) {
391
            return packet;
392
        }
393
        if (!player.onGround() || !packet.hasPosition()) {
394
            return PacketUtil.withOnGround(packet, player, false);
395
        }
396
        double sink = NCP_SINK + NCP_SINK_STEP * swimmingTicks;
397
        return PacketUtil.withPosition(packet, player, packet.getX(player.getX()),
398
            packet.getY(player.getY()) - sink, packet.getZ(player.getZ()), false);
399
    }
400
}
401