auto-totem module

auto-totem: Minecraft 26.3 cheat module, full source for every implementation (1 client: Meteor Client).

1 implementationCombat

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.

Meteor ClientCombatsrc/main/java/meteordevelopment/meteorclient/systems/modules/combat/AutoTotem.javaJava · 131 lines · 4.5 KB

Automatically equips a totem in your offhand.

Settingsmodedelayhealthelytrafallexplosion
AutoTotem.javaJava · Minecraft 26.2 · 131 lines · 4.5 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.combat;
7
8
import meteordevelopment.meteorclient.events.packets.PacketEvent;
9
import meteordevelopment.meteorclient.events.world.TickEvent;
10
import meteordevelopment.meteorclient.settings.*;
11
import meteordevelopment.meteorclient.systems.modules.Categories;
12
import meteordevelopment.meteorclient.systems.modules.Module;
13
import meteordevelopment.meteorclient.utils.player.FindItemResult;
14
import meteordevelopment.meteorclient.utils.player.InvUtils;
15
import meteordevelopment.meteorclient.utils.player.PlayerUtils;
16
import meteordevelopment.orbit.EventHandler;
17
import meteordevelopment.orbit.EventPriority;
18
import net.minecraft.network.protocol.game.ClientboundEntityEventPacket;
19
import net.minecraft.world.entity.Entity;
20
import net.minecraft.world.entity.EntityEvent;
21
import net.minecraft.world.entity.EquipmentSlot;
22
import net.minecraft.world.item.Items;
23
24
public class AutoTotem extends Module {
25
    private final SettingGroup sgGeneral = settings.getDefaultGroup();
26
27
    private final Setting<Mode> mode = sgGeneral.add(new EnumSetting.Builder<Mode>()
28
        .name("mode")
29
        .description("Determines when to hold a totem, strict will always hold.")
30
        .defaultValue(Mode.Smart)
31
        .build()
32
    );
33
34
    private final Setting<Integer> delay = sgGeneral.add(new IntSetting.Builder()
35
        .name("delay")
36
        .description("The ticks between slot movements.")
37
        .defaultValue(0)
38
        .min(0)
39
        .build()
40
    );
41
42
    private final Setting<Integer> health = sgGeneral.add(new IntSetting.Builder()
43
        .name("health")
44
        .description("The health to hold a totem at.")
45
        .defaultValue(10)
46
        .range(0, 36)
47
        .sliderMax(36)
48
        .visible(() -> mode.get() == Mode.Smart)
49
        .build()
50
    );
51
52
    private final Setting<Boolean> elytra = sgGeneral.add(new BoolSetting.Builder()
53
        .name("elytra")
54
        .description("Will always hold a totem when flying with elytra.")
55
        .defaultValue(true)
56
        .visible(() -> mode.get() == Mode.Smart)
57
        .build()
58
    );
59
60
    private final Setting<Boolean> fall = sgGeneral.add(new BoolSetting.Builder()
61
        .name("fall")
62
        .description("Will hold a totem when fall damage could kill you.")
63
        .defaultValue(true)
64
        .visible(() -> mode.get() == Mode.Smart)
65
        .build()
66
    );
67
68
    private final Setting<Boolean> explosion = sgGeneral.add(new BoolSetting.Builder()
69
        .name("explosion")
70
        .description("Will hold a totem when explosion damage could kill you.")
71
        .defaultValue(true)
72
        .visible(() -> mode.get() == Mode.Smart)
73
        .build()
74
    );
75
76
    public boolean locked;
77
    private int totems, ticks;
78
79
    public AutoTotem() {
80
        super(Categories.Combat, "auto-totem", "Automatically equips a totem in your offhand.");
81
    }
82
83
    @EventHandler(priority = EventPriority.HIGHEST)
84
    private void onTick(TickEvent.Pre event) {
85
        FindItemResult result = InvUtils.find(Items.TOTEM_OF_UNDYING);
86
        totems = result.count();
87
88
        if (totems <= 0) locked = false;
89
        else if (ticks >= delay.get()) {
90
            boolean low = mc.player.getHealth() + mc.player.getAbsorptionAmount() - PlayerUtils.possibleHealthReductions(explosion.get(), fall.get()) <= health.get();
91
            boolean ely = elytra.get() && mc.player.getItemBySlot(EquipmentSlot.CHEST).getItem() == Items.ELYTRA && mc.player.isFallFlying();
92
93
            locked = mode.get() == Mode.Strict || (mode.get() == Mode.Smart && (low || ely));
94
95
            if (locked && mc.player.getOffhandItem().getItem() != Items.TOTEM_OF_UNDYING) {
96
                InvUtils.move().from(result.slot()).toOffhand();
97
            }
98
99
            ticks = 0;
100
            return;
101
        }
102
103
        ticks++;
104
    }
105
106
    @EventHandler(priority = EventPriority.HIGH)
107
    private void onReceivePacket(PacketEvent.Receive event) {
108
        if (!(event.packet instanceof ClientboundEntityEventPacket p)) return;
109
        if (p.getEventId() != EntityEvent.PROTECTED_FROM_DEATH) return;
110
111
        Entity entity = p.getEntity(mc.level);
112
        if (entity == null || !(entity.equals(mc.player))) return;
113
114
        ticks = 0;
115
    }
116
117
    public boolean isLocked() {
118
        return isActive() && locked;
119
    }
120
121
    @Override
122
    public String getInfoString() {
123
        return String.valueOf(totems);
124
    }
125
126
    public enum Mode {
127
        Smart,
128
        Strict
129
    }
130
}
131