CameraTweaks module

CameraTweaks: 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/CameraTweaks.javaJava · 113 lines · 4.2 KB

Pulls the third person camera further out and through walls.

SettingsCustom distanceDistanceScrollingScroll keySensitivityNo clip
CameraTweaks.javaJava · Minecraft 26.2 · 113 lines · 4.2 KB · complete file, verbatimOriginal ↗
1
package com.jellypudding.offlineclient.modules.render;
2
3
import com.jellypudding.offlineclient.event.Subscribe;
4
import com.jellypudding.offlineclient.event.events.MouseScrollEvent;
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.KeybindSetting;
10
import com.jellypudding.offlineclient.setting.NumberSetting;
11
import net.minecraft.client.CameraType;
12
import org.lwjgl.glfw.GLFW;
13
14
import java.util.Locale;
15
16
// CameraMixin reads the distance and the wall setting from the third person distance hook.
17
public final class CameraTweaks extends Module {
18
19
    // Share of the current distance one wheel notch changes at sensitivity one.
20
    private static final double NOTCH_SHARE = 0.25;
21
    private static final double MIN_DISTANCE = 0.5;
22
23
    private final BoolSetting customDistance = new BoolSetting("Custom distance",
24
        "Uses your own third person distance instead of the vanilla four blocks.", true);
25
    private final NumberSetting distance = new NumberSetting("Distance",
26
        "How far behind you the third person camera sits.", 10, 1, 64, 0.5, " blocks")
27
        .max(150).under(customDistance);
28
    private final BoolSetting scrolling = new BoolSetting("Scrolling",
29
        "The mouse wheel moves the camera in and out whilst in third person.", true)
30
        .under(customDistance);
31
    private final KeybindSetting scrollKey = new KeybindSetting("Scroll key",
32
        "A key that must be held for the wheel to move the camera. Unbound means always.", GLFW.GLFW_KEY_LEFT_ALT)
33
        .under(scrolling);
34
    private final NumberSetting sensitivity = new NumberSetting("Sensitivity",
35
        "How much of the distance one wheel notch adds or takes away.", 1, 0.1, 3, 0.1, "x").min(0.01)
36
        .under(scrolling);
37
    private final BoolSetting noClip = new BoolSetting("No clip",
38
        "Lets the camera pass through walls instead of snapping back to your head.", true);
39
40
    // The distance after scrolling. Goes back to the setting when the view changes.
41
    private double scrolled;
42
    private double lastSetting;
43
    private CameraType lastView;
44
45
    public CameraTweaks() {
46
        super("CameraTweaks", "Pulls the third person camera further out and through walls.", Category.RENDER);
47
        addSettings(customDistance, distance, scrolling, scrollKey, sensitivity, noClip);
48
        searchTags("camera distance", "camera no clip", "third person", "perspective");
49
    }
50
51
    @Override
52
    public String getSuffix() {
53
        if (!customDistance.isOn()) {
54
            return null;
55
        }
56
        return String.format(Locale.ROOT, "%.1f", current());
57
    }
58
59
    @Override
60
    protected void onEnable() {
61
        reset();
62
        lastView = mc.options.getCameraType();
63
    }
64
65
    private void reset() {
66
        scrolled = distance.getValue();
67
        lastSetting = scrolled;
68
    }
69
70
    // A new view or a slider change throws the scrolled distance away.
71
    @Subscribe
72
    private void onTick(TickEvent event) {
73
        CameraType view = mc.options.getCameraType();
74
        if (view != lastView || distance.getValue() != lastSetting) {
75
            lastView = view;
76
            reset();
77
        }
78
    }
79
80
    @Subscribe
81
    private void onScroll(MouseScrollEvent event) {
82
        if (!customDistance.isOn() || !scrolling.isOn() || mc.gui.screen() != null
83
            || mc.options.getCameraType() == CameraType.FIRST_PERSON) {
84
            return;
85
        }
86
        if (scrollKey.isBound() && !scrollKey.isHeld()) {
87
            return;
88
        }
89
        double before = current();
90
        scrolled = Math.max(MIN_DISTANCE, before - event.getAmount() * NOTCH_SHARE * sensitivity.getValue() * before);
91
        event.cancel();
92
    }
93
94
    private double current() {
95
        if (scrolled <= 0) {
96
            reset();
97
        }
98
        return scrolled;
99
    }
100
101
    // Vanilla passes in the distance it wants before the wall check shortens it.
102
    public float adjustDistance(float vanilla) {
103
        if (!isEnabled() || !customDistance.isOn()) {
104
            return vanilla;
105
        }
106
        return (float) current();
107
    }
108
109
    public boolean passesThroughWalls() {
110
        return isEnabled() && noClip.isOn();
111
    }
112
}
113