collisions module

collisions: Minecraft 26.3 cheat module, full source for every implementation (2 clients: Meteor Client, OfflineClient).

2 implementationsWorldWORLD

Clients with this module

Full module source: 2 implementations

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

Meteor ClientWorldsrc/main/java/meteordevelopment/meteorclient/systems/modules/world/Collisions.javaJava · 119 lines · 4.7 KB

Adds collision boxes to certain blocks/areas.

Settingsblocksmagmaunloaded-chunksignore-border
Collisions.javaJava · Minecraft 26.2 · 119 lines · 4.7 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.world;
7
8
import meteordevelopment.meteorclient.events.entity.player.PlayerMoveEvent;
9
import meteordevelopment.meteorclient.events.packets.PacketEvent;
10
import meteordevelopment.meteorclient.events.world.CollisionShapeEvent;
11
import meteordevelopment.meteorclient.mixininterface.IVec3;
12
import meteordevelopment.meteorclient.settings.BlockListSetting;
13
import meteordevelopment.meteorclient.settings.BoolSetting;
14
import meteordevelopment.meteorclient.settings.Setting;
15
import meteordevelopment.meteorclient.settings.SettingGroup;
16
import meteordevelopment.meteorclient.systems.modules.Categories;
17
import meteordevelopment.meteorclient.systems.modules.Module;
18
import meteordevelopment.orbit.EventHandler;
19
import net.minecraft.network.protocol.game.ServerboundMovePlayerPacket;
20
import net.minecraft.network.protocol.game.ServerboundMoveVehiclePacket;
21
import net.minecraft.world.level.block.*;
22
import net.minecraft.world.phys.shapes.Shapes;
23
24
import java.util.List;
25
26
public class Collisions extends Module {
27
    private final SettingGroup sgGeneral = settings.getDefaultGroup();
28
29
    public final Setting<List<Block>> blocks = sgGeneral.add(new BlockListSetting.Builder()
30
        .name("blocks")
31
        .description("What blocks should be added collision box.")
32
        .filter(this::blockFilter)
33
        .build()
34
    );
35
36
    private final Setting<Boolean> magma = sgGeneral.add(new BoolSetting.Builder()
37
        .name("magma")
38
        .description("Prevents you from walking over magma blocks.")
39
        .defaultValue(false)
40
        .build()
41
    );
42
43
    private final Setting<Boolean> unloadedChunks = sgGeneral.add(new BoolSetting.Builder()
44
        .name("unloaded-chunks")
45
        .description("Stops you from going into unloaded chunks.")
46
        .defaultValue(false)
47
        .build()
48
    );
49
50
    private final Setting<Boolean> ignoreBorder = sgGeneral.add(new BoolSetting.Builder()
51
        .name("ignore-border")
52
        .description("Removes world border collision.")
53
        .defaultValue(false)
54
        .build()
55
    );
56
57
    public Collisions() {
58
        super(Categories.World, "collisions", "Adds collision boxes to certain blocks/areas.");
59
    }
60
61
    @EventHandler
62
    private void onCollisionShape(CollisionShapeEvent event) {
63
        if (mc.level == null || mc.player == null) return;
64
        if (!event.state.getFluidState().isEmpty()) return;
65
        if (blocks.get().contains(event.state.getBlock())) {
66
            event.shape = Shapes.block();
67
        } else if (magma.get() && !mc.player.isShiftKeyDown()
68
            && event.state.isAir()
69
            && mc.level.getBlockState(event.pos.below()).getBlock() == Blocks.MAGMA_BLOCK) {
70
            event.shape = Shapes.block();
71
        }
72
    }
73
74
    @EventHandler
75
    private void onPlayerMove(PlayerMoveEvent event) {
76
        int x = (int) (mc.player.getX() + event.movement.x) >> 4;
77
        int z = (int) (mc.player.getZ() + event.movement.z) >> 4;
78
        if (unloadedChunks.get() && !mc.level.getChunkSource().hasChunk(x, z)) {
79
            ((IVec3) event.movement).meteor$set(0, event.movement.y, 0);
80
        }
81
    }
82
83
    @EventHandler
84
    private void onPacketSend(PacketEvent.Send event) {
85
        if (!unloadedChunks.get()) return;
86
        if (event.packet instanceof ServerboundMoveVehiclePacket packet) {
87
            if (!mc.level.getChunkSource().hasChunk((int) packet.position().x() >> 4, (int) packet.position().z() >> 4)) {
88
                mc.player.getVehicle().absSnapTo(mc.player.getVehicle().xo, mc.player.getVehicle().yo, mc.player.getVehicle().zo);
89
                event.cancel();
90
            }
91
        } else if (event.packet instanceof ServerboundMovePlayerPacket packet) {
92
            if (!mc.level.getChunkSource().hasChunk((int) packet.getX(mc.player.getX()) >> 4, (int) packet.getZ(mc.player.getZ()) >> 4)) {
93
                event.cancel();
94
            }
95
        }
96
    }
97
98
    private boolean blockFilter(Block block) {
99
        return (block instanceof BaseFireBlock
100
            || block instanceof BasePressurePlateBlock
101
            || block instanceof TripWireBlock
102
            || block instanceof TripWireHookBlock
103
            || block instanceof WebBlock
104
            || block instanceof CampfireBlock
105
            || block instanceof SweetBerryBushBlock
106
            || block instanceof CactusBlock
107
            || block instanceof BaseRailBlock
108
            || block instanceof TrapDoorBlock
109
            || block instanceof PowderSnowBlock
110
            || block instanceof AbstractCauldronBlock
111
            || block instanceof HoneyBlock
112
        );
113
    }
114
115
    public boolean ignoreBorder() {
116
        return isActive() && ignoreBorder.get();
117
    }
118
}
119
OfflineClientWORLDsrc/main/java/com/jellypudding/offlineclient/modules/world/Collisions.javaJava · 121 lines · 4.6 KB

Turns fire and webs and other soft blocks into walls.

SettingsBlocksMagmaUnloaded chunksIgnore border
Collisions.javaJava · Minecraft 26.2 · 121 lines · 4.6 KB · complete file, verbatimOriginal ↗
1
package com.jellypudding.offlineclient.modules.world;
2
3
import com.jellypudding.offlineclient.event.Subscribe;
4
import com.jellypudding.offlineclient.event.events.PacketSendEvent;
5
import com.jellypudding.offlineclient.event.events.PreMotionEvent;
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.RegistryListSetting;
10
import net.minecraft.core.BlockPos;
11
import net.minecraft.core.registries.BuiltInRegistries;
12
import net.minecraft.network.protocol.game.ServerboundMovePlayerPacket;
13
import net.minecraft.network.protocol.game.ServerboundMoveVehiclePacket;
14
import net.minecraft.world.entity.Entity;
15
import net.minecraft.world.level.block.Block;
16
import net.minecraft.world.level.block.Blocks;
17
import net.minecraft.world.level.block.state.BlockState;
18
import net.minecraft.world.phys.Vec3;
19
import net.minecraft.world.phys.shapes.Shapes;
20
import net.minecraft.world.phys.shapes.VoxelShape;
21
22
import java.util.List;
23
24
// Gives a full cube to blocks that normally let you walk straight through them.
25
public final class Collisions extends Module {
26
27
    private final RegistryListSetting<Block> blocks = new RegistryListSetting<>("Blocks",
28
        "Blocks that become solid to you. Click to pick them.", BuiltInRegistries.BLOCK, List.of());
29
    private final BoolSetting magma = new BoolSetting("Magma",
30
        "Makes the air over a magma block solid so you cannot step on it.", false);
31
    private final BoolSetting unloadedChunks = new BoolSetting("Unloaded chunks",
32
        "Stops you walking or riding into a chunk that has not loaded.", false);
33
    private final BoolSetting ignoreBorder = new BoolSetting("Ignore border",
34
        "Walks through the world border instead of stopping at it.", false);
35
36
    // The last spot inside a loaded chunk. Nought whilst nothing is known.
37
    private double safeX;
38
    private double safeZ;
39
    private boolean haveSafe;
40
41
    public Collisions() {
42
        super("Collisions", "Turns fire and webs and other soft blocks into walls.", Category.WORLD);
43
        addSettings(blocks, magma, unloadedChunks, ignoreBorder);
44
        searchTags("collision", "hitbox", "world border", "magma");
45
    }
46
47
    @Override
48
    protected void onEnable() {
49
        haveSafe = false;
50
    }
51
52
    // Null leaves the block with the shape the game gave it.
53
    public VoxelShape forcedShape(BlockState state, BlockPos pos) {
54
        if (!state.getFluidState().isEmpty() || !inGame()) {
55
            return null;
56
        }
57
        if (blocks.contains(state.getBlock())) {
58
            return Shapes.block();
59
        }
60
        // Sneaking lets you drop onto the magma on purpose.
61
        if (magma.isOn() && state.isAir() && !mc.player.isShiftKeyDown()
62
            && mc.level.getBlockState(pos.below()).is(Blocks.MAGMA_BLOCK)) {
63
            return Shapes.block();
64
        }
65
        return null;
66
    }
67
68
    public boolean ignoresBorder() {
69
        return ignoreBorder.isOn();
70
    }
71
72
    // Walking out of the loaded world puts you back where you last stood.
73
    @Subscribe
74
    private void onPreMotion(PreMotionEvent event) {
75
        if (!unloadedChunks.isOn() || !inGame()) {
76
            haveSafe = false;
77
            return;
78
        }
79
        if (loaded(mc.player.getX(), mc.player.getZ())) {
80
            safeX = mc.player.getX();
81
            safeZ = mc.player.getZ();
82
            haveSafe = true;
83
            return;
84
        }
85
        if (!haveSafe) {
86
            return;
87
        }
88
        mc.player.setPos(safeX, mc.player.getY(), safeZ);
89
        Vec3 motion = mc.player.getDeltaMovement();
90
        mc.player.setDeltaMovement(0, motion.y, 0);
91
    }
92
93
    @Subscribe
94
    private void onPacketSend(PacketSendEvent event) {
95
        if (!unloadedChunks.isOn() || !inGame()) {
96
            return;
97
        }
98
        if (event.getPacket() instanceof ServerboundMovePlayerPacket move) {
99
            if (!loaded(move.getX(mc.player.getX()), move.getZ(mc.player.getZ()))) {
100
                event.cancel();
101
            }
102
            return;
103
        }
104
        if (event.getPacket() instanceof ServerboundMoveVehiclePacket move) {
105
            Vec3 where = move.position();
106
            if (loaded(where.x, where.z)) {
107
                return;
108
            }
109
            Entity vehicle = mc.player.getVehicle();
110
            if (vehicle != null) {
111
                vehicle.absSnapTo(vehicle.xo, vehicle.yo, vehicle.zo);
112
            }
113
            event.cancel();
114
        }
115
    }
116
117
    private boolean loaded(double x, double z) {
118
        return mc.level.getChunkSource().hasChunk((int) Math.floor(x) >> 4, (int) Math.floor(z) >> 4);
119
    }
120
}
121