HandView module

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

1 implementationRENDER

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.

OfflineClientRENDERsrc/main/java/com/jellypudding/offlineclient/modules/render/HandView.javaJava · 184 lines · 8.2 KB

Reshapes and repositions your first person hands.

SettingsServer rotationsOld animationsSkip swap animationNo eating animationSword slashSwing handSwing speedMain hand progressOff hand progressAdjust
HandView.javaJava · Minecraft 26.2 · 184 lines · 8.2 KB · complete file, verbatimOriginal ↗
1
package com.jellypudding.offlineclient.modules.render;
2
3
import com.jellypudding.offlineclient.module.Category;
4
import com.jellypudding.offlineclient.module.Module;
5
import com.jellypudding.offlineclient.setting.BoolSetting;
6
import com.jellypudding.offlineclient.setting.EnumSetting;
7
import com.jellypudding.offlineclient.setting.NumberSetting;
8
import com.jellypudding.offlineclient.setting.Setting;
9
import com.jellypudding.offlineclient.util.RotationManager;
10
import com.mojang.blaze3d.vertex.PoseStack;
11
import com.mojang.math.Axis;
12
import net.minecraft.tags.ItemTags;
13
import net.minecraft.world.InteractionHand;
14
import net.minecraft.world.item.ItemStack;
15
import java.util.Locale;
16
17
// Changes how the first person hands look and move.
18
// Every hook lives in ItemInHandRendererMixin and LivingEntityMixin.
19
public final class HandView extends Module {
20
21
    public enum SwingHand { NORMAL, MAIN_HAND, OFF_HAND }
22
23
    private final BoolSetting serverRotations = new BoolSetting("Server rotations",
24
        "The hands follow the angle the server sees rather than your camera.", false);
25
    private final BoolSetting oldAnimations = new BoolSetting("Old animations",
26
        "Hits and swaps snap the way they did in older versions.", false);
27
    private final BoolSetting skipSwap = new BoolSetting("Skip swap animation",
28
        "A new item appears in hand at once instead of rising into view.", false);
29
    private final BoolSetting noEating = new BoolSetting("No eating animation",
30
        "Food stays still whilst you eat instead of bobbing off screen.", false);
31
    private final BoolSetting swordSlash = new BoolSetting("Sword slash",
32
        "A sword swing uses the resting pose and the blade never fills the screen.", false);
33
    private final EnumSetting<SwingHand> swingHand = new EnumSetting<>("Swing hand",
34
        "Which hand is swung on a hit.", SwingHand.NORMAL)
35
        .describe(SwingHand.NORMAL, "Whichever hand the game would swing.")
36
        .describe(SwingHand.MAIN_HAND, "Always the main hand.")
37
        .describe(SwingHand.OFF_HAND, "Always the off hand.");
38
    private final NumberSetting swingSpeed = new NumberSetting("Swing speed",
39
        "Ticks one swing takes.", 6, 1, 20, 1, " ticks").min(1);
40
    private final NumberSetting mainSwing = new NumberSetting("Main hand progress",
41
        "Adds to how far through a swing the main hand is drawn.", 0, -1, 1, 0.05);
42
    private final NumberSetting offSwing = new NumberSetting("Off hand progress",
43
        "Adds to how far through a swing the off hand is drawn.", 0, -1, 1, 0.05);
44
45
    private final Adjust mainHand = new Adjust("Main hand", "the item in your main hand");
46
    private final Adjust offHand = new Adjust("Off hand", "the item in your off hand");
47
    private final Adjust arm = new Adjust("Arm", "your bare arm");
48
49
    public HandView() {
50
        super("HandView", "Reshapes and repositions your first person hands.", Category.RENDER);
51
        addSettings(serverRotations, oldAnimations, skipSwap, noEating, swordSlash,
52
            swingHand, swingSpeed, mainSwing, offSwing);
53
        addSettings(mainHand.settings());
54
        addSettings(offHand.settings());
55
        addSettings(arm.settings());
56
        searchTags("hand position", "viewmodel", "swing");
57
    }
58
59
    // Runs just before the held item is drawn.
60
    public void adjustItem(InteractionHand hand, PoseStack pose) {
61
        if (!isEnabled()) {
62
            return;
63
        }
64
        (hand == InteractionHand.MAIN_HAND ? mainHand : offHand).apply(pose);
65
        followServer(pose);
66
    }
67
68
    // Runs just before an empty arm is drawn.
69
    public void adjustArm(PoseStack pose) {
70
        if (!isEnabled()) {
71
            return;
72
        }
73
        arm.apply(pose);
74
        followServer(pose);
75
    }
76
77
    // Turns the hand by the gap between the camera and the angle the server holds.
78
    private void followServer(PoseStack pose) {
79
        if (!serverRotations.isOn() || mc.player == null) {
80
            return;
81
        }
82
        pose.mulPose(Axis.XP.rotationDegrees(mc.player.getXRot() - RotationManager.serverPitch()));
83
        pose.mulPose(Axis.YP.rotationDegrees(mc.player.getYRot() - RotationManager.serverYaw()));
84
    }
85
86
    // How far through its swing the hand is drawn. Zero is the resting pose.
87
    public float adjustSwing(float progress, ItemStack mainItem, ItemStack offItem) {
88
        if (!isEnabled() || mc.player == null) {
89
            return progress;
90
        }
91
        InteractionHand hand = mc.player.swingingArm == null
92
            ? InteractionHand.MAIN_HAND : mc.player.swingingArm;
93
        if (hand == InteractionHand.MAIN_HAND) {
94
            if (swordSlash.isOn() && mainItem.is(ItemTags.SWORDS)) {
95
                return 0;
96
            }
97
            // The slider reaches minus one and the pose has no meaning below zero.
98
            return mainItem.isEmpty() ? progress : Math.max(0f, progress + mainSwing.getFloat());
99
        }
100
        return offItem.isEmpty() ? progress : Math.max(0f, progress + offSwing.getFloat());
101
    }
102
103
    public boolean skipsSwap() {
104
        return isEnabled() && skipSwap.isOn();
105
    }
106
107
    public boolean usesOldAnimations() {
108
        return isEnabled() && oldAnimations.isOn();
109
    }
110
111
    public boolean hidesEating() {
112
        return isEnabled() && noEating.isOn();
113
    }
114
115
    // The hand a hit swings. Only your own hits are changed.
116
    public InteractionHand swingHand(InteractionHand asked) {
117
        if (!isEnabled() || swingHand.is(SwingHand.NORMAL)) {
118
            return asked;
119
        }
120
        return swingHand.is(SwingHand.OFF_HAND) ? InteractionHand.OFF_HAND : InteractionHand.MAIN_HAND;
121
    }
122
123
    // Ticks one swing lasts in first person.
124
    public int swingDuration(int vanilla) {
125
        if (!isEnabled() || !mc.options.getCameraType().isFirstPerson()) {
126
            return vanilla;
127
        }
128
        return swingSpeed.getInt();
129
    }
130
131
    // Scale and offset and turn for one drawn thing.
132
    private static final class Adjust {
133
134
        private final BoolSetting enabled;
135
        private final NumberSetting scaleX;
136
        private final NumberSetting scaleY;
137
        private final NumberSetting scaleZ;
138
        private final NumberSetting x;
139
        private final NumberSetting y;
140
        private final NumberSetting z;
141
        private final NumberSetting pitch;
142
        private final NumberSetting yaw;
143
        private final NumberSetting roll;
144
145
        Adjust(String label, String what) {
146
            enabled = new BoolSetting("Adjust " + label.toLowerCase(Locale.ROOT),
147
                "Reshapes " + what + ".", false);
148
            scaleX = new NumberSetting(label + " scale x",
149
                "How wide it is drawn.", 1, 0.1, 3, 0.05, "x").min(0.01).max(5).under(enabled);
150
            scaleY = new NumberSetting(label + " scale y",
151
                "How tall it is drawn.", 1, 0.1, 3, 0.05, "x").min(0.01).max(5).under(enabled);
152
            scaleZ = new NumberSetting(label + " scale z",
153
                "How deep it is drawn.", 1, 0.1, 3, 0.05, "x").min(0.01).max(5).under(enabled);
154
            x = new NumberSetting(label + " x",
155
                "Sideways offset.", 0, -2, 2, 0.05).under(enabled);
156
            y = new NumberSetting(label + " y",
157
                "Up and down offset.", 0, -2, 2, 0.05).under(enabled);
158
            z = new NumberSetting(label + " z",
159
                "Toward and away offset.", 0, -2, 2, 0.05).under(enabled);
160
            pitch = new NumberSetting(label + " pitch",
161
                "Tilt up or down.", 0, -180, 180, 5, "°").under(enabled);
162
            yaw = new NumberSetting(label + " yaw",
163
                "Turn left or right.", 0, -180, 180, 5, "°").under(enabled);
164
            roll = new NumberSetting(label + " roll",
165
                "Roll about the forward axis.", 0, -180, 180, 5, "°").under(enabled);
166
        }
167
168
        Setting<?>[] settings() {
169
            return new Setting<?>[] { enabled, scaleX, scaleY, scaleZ, x, y, z, pitch, yaw, roll };
170
        }
171
172
        void apply(PoseStack pose) {
173
            if (!enabled.isOn()) {
174
                return;
175
            }
176
            pose.mulPose(Axis.XP.rotationDegrees(pitch.getFloat()));
177
            pose.mulPose(Axis.YP.rotationDegrees(yaw.getFloat()));
178
            pose.mulPose(Axis.ZP.rotationDegrees(roll.getFloat()));
179
            pose.scale(scaleX.getFloat(), scaleY.getFloat(), scaleZ.getFloat());
180
            pose.translate(x.getFloat(), y.getFloat(), z.getFloat());
181
        }
182
    }
183
}
184