anti-hunger module

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

1 implementationPlayer

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 ClientPlayersrc/main/java/meteordevelopment/meteorclient/systems/modules/player/AntiHunger.javaJava · 75 lines · 2.8 KB

Reduces (does NOT remove) hunger consumption.

Settingssprinton-ground
AntiHunger.javaJava · Minecraft 26.2 · 75 lines · 2.8 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.player;
7
8
import meteordevelopment.meteorclient.events.entity.player.SendMovementPacketsEvent;
9
import meteordevelopment.meteorclient.events.packets.PacketEvent;
10
import meteordevelopment.meteorclient.mixin.ServerboundMovePlayerPacketAccessor;
11
import meteordevelopment.meteorclient.settings.BoolSetting;
12
import meteordevelopment.meteorclient.settings.Setting;
13
import meteordevelopment.meteorclient.settings.SettingGroup;
14
import meteordevelopment.meteorclient.systems.modules.Categories;
15
import meteordevelopment.meteorclient.systems.modules.Module;
16
import meteordevelopment.orbit.EventHandler;
17
import net.minecraft.network.protocol.game.ServerboundMovePlayerPacket;
18
import net.minecraft.network.protocol.game.ServerboundPlayerCommandPacket;
19
20
public class AntiHunger extends Module {
21
    private final SettingGroup sgGeneral = settings.getDefaultGroup();
22
23
    private final Setting<Boolean> sprint = sgGeneral.add(new BoolSetting.Builder()
24
        .name("sprint")
25
        .description("Spoofs sprinting packets.")
26
        .defaultValue(true)
27
        .build()
28
    );
29
30
    private final Setting<Boolean> onGround = sgGeneral.add(new BoolSetting.Builder()
31
        .name("on-ground")
32
        .description("Spoofs the onGround flag.")
33
        .defaultValue(true)
34
        .build()
35
    );
36
37
    private boolean lastOnGround, ignorePacket;
38
39
    public AntiHunger() {
40
        super(Categories.Player, "anti-hunger", "Reduces (does NOT remove) hunger consumption.");
41
    }
42
43
    @Override
44
    public void onActivate() {
45
        lastOnGround = mc.player.onGround();
46
    }
47
48
    @EventHandler
49
    private void onSendPacket(PacketEvent.Send event) {
50
        if (ignorePacket && event.packet instanceof ServerboundMovePlayerPacket) {
51
            ignorePacket = false;
52
            return;
53
        }
54
55
        if (mc.player.isPassenger() || mc.player.isInWater() || mc.player.isUnderWater()) return;
56
57
        if (event.packet instanceof ServerboundPlayerCommandPacket packet && sprint.get()) {
58
            if (packet.getAction() == ServerboundPlayerCommandPacket.Action.START_SPRINTING) event.cancel();
59
        }
60
61
        if (event.packet instanceof ServerboundMovePlayerPacket packet && onGround.get() && mc.player.onGround() && mc.player.fallDistance <= 0.0 && !mc.gameMode.isDestroying()) {
62
            ((ServerboundMovePlayerPacketAccessor) packet).meteor$setOnGround(false);
63
        }
64
    }
65
66
    @EventHandler
67
    private void onTick(SendMovementPacketsEvent.Pre event) {
68
        if (mc.player.onGround() && !lastOnGround && onGround.get()) {
69
            ignorePacket = true; // prevents you from not taking fall damage
70
        }
71
72
        lastOnGround = mc.player.onGround();
73
    }
74
}
75