RemoteView module

RemoteView: 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/RemoteView.javaJava · 131 lines · 4.9 KB

See the world through the eyes of another player or mob.

SettingsViewName
RemoteView.javaJava · Minecraft 26.2 · 131 lines · 4.9 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.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.modules.misc.FakePlayer;
9
import com.jellypudding.offlineclient.setting.EnumSetting;
10
import com.jellypudding.offlineclient.setting.TextSetting;
11
import com.jellypudding.offlineclient.util.ChatUtil;
12
import com.jellypudding.offlineclient.util.EntityFilter;
13
import com.jellypudding.offlineclient.util.EntityUtil;
14
import net.minecraft.network.protocol.game.ServerboundMovePlayerPacket;
15
import net.minecraft.world.entity.Entity;
16
import net.minecraft.world.entity.LivingEntity;
17
import net.minecraft.world.phys.Vec3;
18
19
import java.util.List;
20
21
// Puts your eyes inside another entity. Your body waits where you left it and
22
// the server never hears about the trip.
23
public final class RemoteView extends Module {
24
25
    public enum Pick { NEAREST, NAME }
26
27
    private static final double SEARCH_RANGE = 128;
28
    // Fake health for the stand in body.
29
    private static final float BODY_HEALTH = 20;
30
31
    private final EnumSetting<Pick> pick = new EnumSetting<>("View", "Whose eyes are borrowed.",
32
        Pick.NEAREST)
33
        .describe(Pick.NEAREST, "The nearest entity the filter allows.")
34
        .describe(Pick.NAME, "The entity whose name you type in.");
35
    private final TextSetting name = new TextSetting("Name",
36
        "The name of the entity to view. Click to type it.", "")
37
        .under(pick, Pick.NAME);
38
    private final EntityFilter filter = EntityFilter.living("View", "viewed", true,
39
        EntityFilter.Pick.ALL, List.of());
40
41
    private Entity viewed;
42
    private boolean wasInvisible;
43
    private FakePlayer.Body body;
44
45
    public RemoteView() {
46
        super("RemoteView", "See the world through the eyes of another player or mob.", Category.RENDER);
47
        addSettings(pick, name);
48
        addSettings(filter.settings());
49
        searchTags("remote view", "spectate", "possess");
50
    }
51
52
    @Override
53
    public boolean savesEnabledState() {
54
        return false;
55
    }
56
57
    @Override
58
    public String getSuffix() {
59
        return viewed == null ? null : viewed.getName().getString();
60
    }
61
62
    @Override
63
    protected void onEnable() {
64
        viewed = inGame() ? pickTarget() : null;
65
        if (viewed == null) {
66
            ChatUtil.error("Nothing to view was found.");
67
            setEnabled(false);
68
            return;
69
        }
70
        wasInvisible = viewed.isInvisible();
71
        mc.player.noPhysics = true;
72
        body = new FakePlayer.Body(mc.level, mc.player, BODY_HEALTH, true, true);
73
        mc.level.addEntity(body);
74
        ChatUtil.message("Now viewing §b" + viewed.getName().getString() + "§7.");
75
    }
76
77
    @Override
78
    protected void onDisable() {
79
        if (viewed != null) {
80
            viewed.setInvisible(wasInvisible);
81
            ChatUtil.message("No longer viewing §b" + viewed.getName().getString() + "§7.");
82
            viewed = null;
83
        }
84
        if (mc.player != null) {
85
            mc.player.noPhysics = false;
86
        }
87
        if (body != null) {
88
            if (mc.player != null && body.level() == mc.level) {
89
                mc.player.setPos(body.getX(), body.getY(), body.getZ());
90
                mc.player.setYRot(body.getYRot());
91
                mc.player.setXRot(body.getXRot());
92
                mc.player.setOldPosAndRot();
93
                mc.player.setDeltaMovement(Vec3.ZERO);
94
                mc.level.removeEntity(body.getId(), Entity.RemovalReason.DISCARDED);
95
            }
96
            body = null;
97
        }
98
    }
99
100
    private Entity pickTarget() {
101
        String wanted = name.getValue().trim();
102
        return EntityUtil.nearest(SEARCH_RANGE, entity -> entity instanceof LivingEntity living
103
            && living.isAlive() && filter.matches(entity)
104
            && (pick.is(Pick.NEAREST) || entity.getName().getString().equalsIgnoreCase(wanted)));
105
    }
106
107
    @Subscribe
108
    private void onTick(TickEvent event) {
109
        if (!inGame() || viewed == null || viewed.isRemoved() || viewed.level() != mc.level
110
            || !(viewed instanceof LivingEntity living) || !living.isAlive()) {
111
            setEnabled(false);
112
            return;
113
        }
114
        mc.player.copyPosition(viewed);
115
        mc.player.setPosRaw(viewed.getX(),
116
            viewed.getY() - mc.player.getEyeHeight(mc.player.getPose()) + viewed.getEyeHeight(viewed.getPose()),
117
            viewed.getZ());
118
        mc.player.setOldPosAndRot();
119
        mc.player.setDeltaMovement(Vec3.ZERO);
120
        viewed.setInvisible(true);
121
    }
122
123
    // The server must never learn where the eyes went.
124
    @Subscribe
125
    private void onPacketSend(PacketSendEvent event) {
126
        if (event.getPacket() instanceof ServerboundMovePlayerPacket) {
127
            event.cancel();
128
        }
129
    }
130
}
131