Rotations module

Rotations: Minecraft 26.3 cheat module, full source for every implementation (2 clients: MelaHack (ThunderHack fork), LiquidBounce (Kotlin)).

2 implementationsCLIENTRENDER

Full module source: 2 implementations

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

MelaHack (ThunderHack fork)CLIENTsrc/main/java/thunder/hack/features/modules/client/Rotations.javaJava · 104 lines · 3.8 KB

Module responsible for setting up rotations.

SettingsMoveFixClientLook
Rotations.javaJava · Minecraft 26.2 · 104 lines · 3.8 KB · complete file, verbatimOriginal ↗
1
package thunder.hack.features.modules.client;
2
3
import net.minecraft.util.Mth;
4
import net.minecraft.world.phys.Vec3;
5
import thunder.hack.core.Managers;
6
import thunder.hack.core.manager.client.ModuleManager;
7
import thunder.hack.events.impl.EventFixVelocity;
8
import thunder.hack.events.impl.EventKeyboardInput;
9
import thunder.hack.events.impl.EventPlayerJump;
10
import thunder.hack.events.impl.EventPlayerTravel;
11
import thunder.hack.features.modules.Module;
12
import thunder.hack.features.modules.combat.Aura;
13
import thunder.hack.setting.Setting;
14
import thunder.hack.utility.player.MovementUtility;
15
16
public class Rotations extends Module {
17
    public Rotations() {
18
        super("Rotations", Category.CLIENT);
19
    }
20
21
    private final Setting<MoveFix> moveFix = new Setting<>("MoveFix", MoveFix.Off);
22
    public final Setting<Boolean> clientLook = new Setting<>("ClientLook", false);
23
24
    private enum MoveFix {
25
        Off, Focused, Free
26
    }
27
28
    public float fixRotation;
29
    private float prevYaw, prevPitch;
30
31
    public void onJump(EventPlayerJump e) {
32
        if (Float.isNaN(fixRotation) || moveFix.getValue() == MoveFix.Off || mc.player.isHandsBusy())
33
            return;
34
35
        if (e.isPre()) {
36
            prevYaw = mc.player.getYRot();
37
            mc.player.setYRot(fixRotation);
38
        } else mc.player.setYRot(prevYaw);
39
    }
40
41
    public void onPlayerMove(EventFixVelocity event) {
42
        if (moveFix.getValue() == MoveFix.Free) {
43
            if (Float.isNaN(fixRotation) || mc.player.isHandsBusy())
44
                return;
45
            event.setVelocity(fix(fixRotation, event.getMovementInput(), event.getSpeed()));
46
        }
47
    }
48
49
    public void modifyVelocity(EventPlayerTravel e) {
50
        if (ModuleManager.aura.isEnabled() && ModuleManager.aura.target != null && ModuleManager.aura.rotationMode.not(Aura.Mode.None)
51
                && ModuleManager.aura.elytraTarget.getValue() && Managers.PLAYER.ticksElytraFlying > 5) {
52
            if (e.isPre()) {
53
                prevYaw = mc.player.getYRot();
54
                prevPitch = mc.player.getXRot();
55
56
                mc.player.setYRot(fixRotation);
57
                mc.player.setXRot(ModuleManager.aura.rotationPitch);
58
            } else {
59
                mc.player.setYRot(prevYaw);
60
                mc.player.setXRot(prevPitch);
61
            }
62
            return;
63
        }
64
65
        if (moveFix.getValue() == MoveFix.Focused && !Float.isNaN(fixRotation) && !mc.player.isHandsBusy()) {
66
            if (e.isPre()) {
67
                prevYaw = mc.player.getYRot();
68
                mc.player.setYRot(fixRotation);
69
            } else {
70
                mc.player.setYRot(prevYaw);
71
            }
72
        }
73
    }
74
75
    public void onKeyInput(EventKeyboardInput e) {
76
        if (moveFix.getValue() == MoveFix.Free) {
77
            if (Float.isNaN(fixRotation) || mc.player.isHandsBusy())
78
                return;
79
80
            float mF = mc.player.input.getMoveVector().y;
81
            float mS = mc.player.input.getMoveVector().x;
82
            float delta = (mc.player.getYRot() - fixRotation) * Mth.DEG_TO_RAD;
83
            float cos = Mth.cos(delta);
84
            float sin = Mth.sin(delta);
85
            MovementUtility.setMovementInput((float) Math.round(mS * cos - mF * sin), (float) Math.round(mF * cos + mS * sin));
86
        }
87
    }
88
89
    private Vec3 fix(float yaw, Vec3 movementInput, float speed) {
90
        double d = movementInput.lengthSqr();
91
        if (d < 1.0E-7)
92
            return Vec3.ZERO;
93
        Vec3 vec3d = (d > 1.0 ? movementInput.normalize() : movementInput).scale(speed);
94
        float f = Mth.sin(yaw * Mth.DEG_TO_RAD);
95
        float g = Mth.cos(yaw * Mth.DEG_TO_RAD);
96
        return new Vec3(vec3d.x * (double) g - vec3d.z * (double) f, vec3d.y, vec3d.z * (double) g + vec3d.x * (double) f);
97
    }
98
99
    @Override
100
    public boolean isToggleable() {
101
        return false;
102
    }
103
}
104
LiquidBounce (Kotlin)RENDERsrc/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/render/ModuleRotations.ktKotlin · 135 lines · 4.7 KB

Allows you to see server-sided rotations.

SettingsBodyPartSmoothVectorLineVectorDot
ModuleRotations.ktKotlin · Minecraft 26.2 · 135 lines · 4.7 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of LiquidBounce (https://github.com/CCBlueX/LiquidBounce)
3
 *
4
 * Copyright (c) 2015 - 2026 CCBlueX
5
 *
6
 * LiquidBounce is free software: you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation, either version 3 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * LiquidBounce is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with LiquidBounce. If not, see <https://www.gnu.org/licenses/>.
18
 */
19
package net.ccbluex.liquidbounce.features.module.modules.render
20
21
import net.ccbluex.liquidbounce.config.types.list.Tagged
22
import net.ccbluex.liquidbounce.event.events.GameTickEvent
23
import net.ccbluex.liquidbounce.event.events.WorldRenderEvent
24
import net.ccbluex.liquidbounce.event.handler
25
import net.ccbluex.liquidbounce.features.module.ClientModule
26
import net.ccbluex.liquidbounce.features.module.ModuleCategories
27
import net.ccbluex.liquidbounce.features.module.modules.render.ModuleRotations.smooth
28
import net.ccbluex.liquidbounce.render.drawBox
29
import net.ccbluex.liquidbounce.render.drawLine
30
import net.ccbluex.liquidbounce.render.engine.type.Color4b
31
import net.ccbluex.liquidbounce.render.engine.type.Vec3f
32
import net.ccbluex.liquidbounce.render.renderEnvironment
33
import net.ccbluex.liquidbounce.utils.aiming.RotationManager
34
import net.ccbluex.liquidbounce.utils.aiming.data.Rotation
35
import net.ccbluex.liquidbounce.utils.entity.lastRotation
36
import net.ccbluex.liquidbounce.utils.kotlin.EventPriorityConvention
37
import net.ccbluex.liquidbounce.utils.math.toVec3f
38
import net.minecraft.world.phys.AABB
39
40
/**
41
 * Rotations module
42
 *
43
 * Allows you to see server-sided rotations.
44
 */
45
46
object ModuleRotations : ClientModule("Rotations", ModuleCategories.RENDER) {
47
48
    /**
49
     * Body part to modify the rotation of.
50
     */
51
    private val bodyPart by multiEnumChoice("BodyPart", BodyPart.entries)
52
53
    @Suppress("unused")
54
    enum class BodyPart(
55
        override val tag: String,
56
    ) : Tagged {
57
        HEAD("Head"),
58
        BODY("Body");
59
    }
60
61
    fun isPartAllowed(part: BodyPart) = part in bodyPart
62
63
    /**
64
     * Smoothes the rotation visually only.
65
     */
66
    private val smooth by float("Smooth", 0.0f, 0.0f..0.3f)
67
68
    private val vectorLine by color("VectorLine", Color4b.WHITE.with(a = 0)) // alpha 0 means OFF
69
    private val vectorDot by color("VectorDot", Color4b(0x00, 0x80, 0xFF, 0x00))
70
71
    /**
72
     * The current model rotation, we could be using
73
     * [RotationManager.currentRotation] and [RotationManager.previousRotation]
74
     * directly but this is required for [smooth] to work.
75
     */
76
    var modelRotation: Rotation? = null
77
        get() = if (this.running) field else null
78
    var prevModelRotation: Rotation? = null
79
80
    @Suppress("unused")
81
    private val modelUpdater = handler<GameTickEvent>(priority = EventPriorityConvention.READ_FINAL_STATE) {
82
        val prev = prevModelRotation ?: player.lastRotation
83
        val current = RotationManager.currentRotation
84
85
        if (current == null) {
86
            prevModelRotation = modelRotation
87
            modelRotation = null
88
            return@handler
89
        }
90
91
        val next = if (smooth > 0f) {
92
            prev.interpolateTo(current, 1f - smooth)
93
        } else {
94
            current
95
        }
96
97
        prevModelRotation = modelRotation
98
        modelRotation = next
99
    }
100
101
    @Suppress("unused")
102
    private val renderHandler = handler<WorldRenderEvent> { event ->
103
        val drawVectorLine = vectorLine.a > 0
104
        val drawVectorDot = vectorDot.a > 0
105
106
        if (drawVectorLine || drawVectorDot) {
107
            val currentRotation = RotationManager.currentRotation ?: return@handler
108
            val previousRotation = RotationManager.previousRotation ?: currentRotation
109
110
            val interpolatedRotationVec = previousRotation.directionVector
111
                .lerp(currentRotation.directionVector, event.partialTicks.toDouble())
112
                .toVec3f()
113
114
            val eyeVector = Vec3f.eyeVector(event.camera)
115
116
            event.renderEnvironment {
117
                val vector = eyeVector.fma(100f, interpolatedRotationVec)
118
                if (drawVectorLine) {
119
                    drawLine(eyeVector, vector, vectorLine.argb)
120
                }
121
122
                if (drawVectorDot) {
123
                    drawBox(AABB.ofSize(vector.toVec3d(), 2.5, 2.5, 2.5), vectorDot)
124
                }
125
            }
126
        }
127
    }
128
129
    override fun onDisabled() {
130
        this.modelRotation = null
131
        this.prevModelRotation = null
132
        super.onDisabled()
133
    }
134
}
135