AntiHunger module

AntiHunger: Minecraft 26.3 cheat module, full source for every implementation (4 clients: MelaHack (ThunderHack fork), OfflineClient, KiwiClient, …).

4 implementationsPLAYEREXPLOIT

Full module source: 4 implementations

Every implementation below is the complete module file, verbatim. Expand a client to read its code.

MelaHack (ThunderHack fork)PLAYERsrc/main/java/thunder/hack/features/modules/player/AntiHunger.javaJava · 31 lines · 1.2 KB

Prevents loss of hunger.

SettingsCancelGroundCancelSprint
AntiHunger.javaJava · Minecraft 26.2 · 31 lines · 1.2 KB · complete file, verbatimOriginal ↗
1
package thunder.hack.features.modules.player;
2
3
import meteordevelopment.orbit.EventHandler;
4
import net.minecraft.network.protocol.game.ServerboundMovePlayerPacket;
5
import net.minecraft.network.protocol.game.ServerboundPlayerCommandPacket;
6
import org.jetbrains.annotations.NotNull;
7
import thunder.hack.events.impl.PacketEvent;
8
import thunder.hack.injection.accesors.IPlayerMoveC2SPacket;
9
import thunder.hack.features.modules.Module;
10
import thunder.hack.setting.Setting;
11
12
public class AntiHunger extends Module {
13
    public AntiHunger() {
14
        super("AntiHunger", Category.PLAYER);
15
    }
16
17
    private final Setting<Boolean> ground = new Setting<>("CancelGround", true);
18
    private final Setting<Boolean> sprint = new Setting<>("CancelSprint", true);
19
20
21
    @EventHandler
22
    public void onPacketSend(PacketEvent.@NotNull Send e) {
23
        if (e.getPacket() instanceof ServerboundMovePlayerPacket pac && ground.getValue())
24
            ((IPlayerMoveC2SPacket) pac).setOnGround(false);
25
26
        if (e.getPacket() instanceof ServerboundPlayerCommandPacket pac && sprint.getValue())
27
            if (pac.getAction() == ServerboundPlayerCommandPacket.Action.START_SPRINTING)
28
                e.cancel();
29
    }
30
}
31
OfflineClientPLAYERsrc/main/java/com/jellypudding/offlineclient/modules/player/AntiHunger.javaJava · 62 lines · 2.5 KB

Slows down how fast you get hungry.

SettingsSprintOn ground
AntiHunger.javaJava · Minecraft 26.2 · 62 lines · 2.5 KB · complete file, verbatimOriginal ↗
1
package com.jellypudding.offlineclient.modules.player;
2
3
import com.jellypudding.offlineclient.event.Subscribe;
4
import com.jellypudding.offlineclient.event.events.PacketSendEvent;
5
import com.jellypudding.offlineclient.module.Category;
6
import com.jellypudding.offlineclient.module.Module;
7
import com.jellypudding.offlineclient.setting.BoolSetting;
8
import com.jellypudding.offlineclient.util.PacketUtil;
9
import net.minecraft.client.multiplayer.MultiPlayerGameMode;
10
import net.minecraft.client.player.LocalPlayer;
11
import net.minecraft.network.protocol.game.ServerboundMovePlayerPacket;
12
import net.minecraft.network.protocol.game.ServerboundPlayerCommandPacket;
13
14
// The server charges no walking exhaustion to airborne players and charges
15
// a sprint jump four times what a walking jump costs.
16
public final class AntiHunger extends Module {
17
18
    private final BoolSetting sprint = new BoolSetting("Sprint",
19
        "Never tells the server you are sprinting. A sprint jump then costs the same as a walking jump.",
20
        true);
21
    private final BoolSetting onGround = new BoolSetting("On ground",
22
        "Tells the server you are in the air whilst you walk so walking costs no hunger.", true);
23
24
    public AntiHunger() {
25
        super("AntiHunger", "Slows down how fast you get hungry.", Category.PLAYER);
26
        addSettings(sprint, onGround);
27
        searchTags("hunger", "food", "exhaustion");
28
    }
29
30
    @Subscribe
31
    private void onPacketSend(PacketSendEvent event) {
32
        // The packet thread can drop the player and the game mode mid handler.
33
        LocalPlayer player = mc.player;
34
        MultiPlayerGameMode gameMode = mc.gameMode;
35
        if (player == null || gameMode == null) {
36
            return;
37
        }
38
        if (event.getPacket() instanceof ServerboundPlayerCommandPacket command) {
39
            if (sprint.isOn() && command.getAction() == ServerboundPlayerCommandPacket.Action.START_SPRINTING) {
40
                event.cancel();
41
            }
42
            return;
43
        }
44
        if (!onGround.isOn() || !(event.getPacket() instanceof ServerboundMovePlayerPacket packet)
45
            || !packet.isOnGround()) {
46
            return;
47
        }
48
        if (player.fallDistance > 0.5) {
49
            return;
50
        }
51
        // A glide only ends when the server hears about the landing.
52
        if (player.isFallFlying()) {
53
            return;
54
        }
55
        // The server slows mining a lot for airborne players.
56
        if (gameMode.isDestroying()) {
57
            return;
58
        }
59
        event.setPacket(PacketUtil.withOnGround(packet, player, false));
60
    }
61
}
62
KiwiClientPLAYERsrc/main/java/com/tangykiwi/kiwiclient/module/player/AntiHunger.javaJava · 75 lines · 2.6 KB

Reduces hunger consumption

SettingsSpoof SprintSpoof OnGround
AntiHunger.javaJava · Minecraft 26.2 · 75 lines · 2.6 KB · complete file, verbatimOriginal ↗
1
package com.tangykiwi.kiwiclient.module.player;
2
3
import static com.tangykiwi.kiwiclient.KiwiClient.mc;
4
5
import com.google.common.eventbus.AllowConcurrentEvents;
6
import com.google.common.eventbus.Subscribe;
7
import com.tangykiwi.kiwiclient.event.PacketEvent;
8
import com.tangykiwi.kiwiclient.event.SendMovementPacketEvent;
9
import com.tangykiwi.kiwiclient.mixin.ServerboundMovePlayerPacketAccessor;
10
import com.tangykiwi.kiwiclient.module.Category;
11
import com.tangykiwi.kiwiclient.module.Module;
12
import com.tangykiwi.kiwiclient.module.setting.ToggleSetting;
13
14
import net.minecraft.network.protocol.game.ServerboundMovePlayerPacket;
15
import net.minecraft.network.protocol.game.ServerboundPlayerCommandPacket;
16
17
public class AntiHunger extends Module {
18
    private boolean lastOnGround;
19
    private boolean ignorePacket;
20
21
    public AntiHunger() {
22
        super("AntiHunger", "Reduces hunger consumption", KEY_UNBOUND, Category.PLAYER,
23
            new ToggleSetting("Spoof Sprint", "Spoofs sprinting packets", true),
24
            new ToggleSetting("Spoof OnGround", "Spoofs OnGround flag", true));
25
    }
26
27
    @Override
28
    public void onEnable() {
29
        if (mc.player == null) {
30
            lastOnGround = true;
31
        } else {
32
            lastOnGround = mc.player.onGround();
33
        }
34
35
        super.onEnable();
36
    }
37
38
    @Subscribe
39
    @AllowConcurrentEvents
40
    public void onSendPacket(PacketEvent.Send event) {
41
        if (mc.player == null) return;
42
        
43
        if (ignorePacket && event.packet instanceof ServerboundMovePlayerPacket) {
44
            ignorePacket = false;
45
            return;
46
        }
47
48
        if (mc.player.isPassenger() || mc.player.isInWater() || mc.player.isUnderWater()) return;
49
50
        if (event.packet instanceof ServerboundPlayerCommandPacket packet && getSetting(0).asToggle().getValue()) {
51
            if (packet.getAction() == ServerboundPlayerCommandPacket.Action.START_SPRINTING) {
52
                event.cancel();
53
            }
54
        }
55
56
        if (event.packet instanceof ServerboundMovePlayerPacket packet && getSetting(1).asToggle().getValue() && mc.player.onGround() && mc.player.fallDistance <= 0.0 && !mc.gameMode.isDestroying()) {
57
            ((ServerboundMovePlayerPacketAccessor) packet).setOnGround(false);
58
        }
59
    }
60
61
    @Subscribe
62
    @AllowConcurrentEvents
63
    public void onSendMovementPacketsHead(SendMovementPacketEvent.Pre event) {
64
        if (mc.player == null) {
65
            return;
66
        }
67
68
        if (mc.player.onGround() && !lastOnGround && getSetting(1).asToggle().getValue()) {
69
            ignorePacket = true;
70
        }
71
72
        lastOnGround = mc.player.onGround();
73
    }
74
}
75
LiquidBounce (Kotlin)EXPLOITsrc/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/exploit/ModuleAntiHunger.ktKotlin · 126 lines · 5.0 KB

Prevents you from getting hungry.

SettingsWhileSwimmingKeepFloating
ModuleAntiHunger.ktKotlin · Minecraft 26.2 · 126 lines · 5.0 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of LiquidBounce (https://github.com/CCBlueX/LiquidBounce)
3
 *
4
 * Copyright (c) 2015 - 2026 CCBlueX
5
 *
6
 * LiquidBounce is free software: you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation, either version 3 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * LiquidBounce is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with LiquidBounce. If not, see <https://www.gnu.org/licenses/>.
18
 */
19
package net.ccbluex.liquidbounce.features.module.modules.exploit
20
21
import net.ccbluex.liquidbounce.config.types.group.ToggleableValueGroup
22
import net.ccbluex.liquidbounce.event.events.NotificationEvent
23
import net.ccbluex.liquidbounce.event.events.PacketEvent
24
import net.ccbluex.liquidbounce.event.events.SprintEvent
25
import net.ccbluex.liquidbounce.event.handler
26
import net.ccbluex.liquidbounce.features.module.ClientModule
27
import net.ccbluex.liquidbounce.features.module.ModuleCategories
28
import net.ccbluex.liquidbounce.utils.client.Chronometer
29
import net.ccbluex.liquidbounce.utils.client.notification
30
import net.minecraft.network.protocol.game.ServerboundMovePlayerPacket
31
import net.minecraft.network.protocol.game.ServerboundPlayerActionPacket
32
import net.minecraft.network.protocol.game.ServerboundPlayerCommandPacket
33
import net.minecraft.server.level.ServerPlayer
34
35
/**
36
 * AntiHunger Module
37
 *
38
 * Prevents hunger from decreasing, will flag anticheats.
39
 * Tested on PurityVanilla. Ran about 2000 blocks in the nether and hunger did not decrease.
40
 *
41
 * Prevents some cases of exhaustion explained in the increaseTravelMotionStats method of
42
 * @see ServerPlayer
43
 */
44
object ModuleAntiHunger : ClientModule("AntiHunger", ModuleCategories.EXPLOIT) {
45
46
    /**
47
     * Cancels hunger decrease by making the player not sprint server side
48
     */
49
    private object NoSprint : ToggleableValueGroup(this, "NoSprint", true) {
50
        private val whileSwimming by boolean("WhileSwimming", false)
51
52
        override val running
53
            get() = super.running && (!player.isSwimming || whileSwimming)
54
    }
55
56
    init { tree(NoSprint) }
57
58
    /**
59
     * Cancels hunger decrease by making the player float (not on ground) permanently
60
     */
61
    private var keepFalling by boolean("KeepFloating", true)
62
63
    private var notificationCooldown = Chronometer()
64
65
    @Suppress("unused")
66
    private val sprintHandler = handler<SprintEvent> { event ->
67
        if (NoSprint.running && (event.source == SprintEvent.Source.NETWORK
68
                || event.source == SprintEvent.Source.INPUT)) {
69
            event.sprint = false
70
        }
71
    }
72
73
    @Suppress("unused")
74
    private val packetHandler = handler<PacketEvent> { event ->
75
        when (val packet = event.packet) {
76
77
            is ServerboundPlayerCommandPacket -> {
78
                if (!NoSprint.running || !notificationCooldown.hasElapsed(500)) {
79
                    return@handler
80
                }
81
82
                // This might be the case when using SuperKnockback, but we want to notify the user
83
                if (packet.action == ServerboundPlayerCommandPacket.Action.START_SPRINTING) {
84
                    notification("AntiHunger",
85
                        message("warnSprint"),
86
                        NotificationEvent.Severity.INFO)
87
                    notificationCooldown.reset()
88
                    player.jumpFromGround()
89
                }
90
            }
91
92
            is ServerboundPlayerActionPacket -> {
93
                if (!notificationCooldown.hasElapsed(500)) {
94
                    return@handler
95
                }
96
97
                if (packet.action == ServerboundPlayerActionPacket.Action.START_DESTROY_BLOCK) {
98
                    notification("AntiHunger",
99
                        message("warnBreak"),
100
                        NotificationEvent.Severity.INFO)
101
                    notificationCooldown.reset()
102
                }
103
            }
104
105
            is ServerboundMovePlayerPacket -> {
106
                // Check if the player is inside a vehicle or breaking a block (to prevent slow-breaking)
107
                if (!keepFalling || player.isPassenger || interaction.isDestroying) {
108
                    return@handler
109
                }
110
111
                // Check if player is touching water, swimming or submerged in water.
112
                // If so, we do not want to modify the onGround packet
113
                if (player.isInWater || player.isSwimming || player.isUnderWater) {
114
                    return@handler
115
                }
116
117
                // If player is on ground and not falling, we want to send a packet with onGround set to false
118
                // We cannot get any hunger decrease if we are not on ground, so we want to keep it that way
119
                if (packet.onGround && player.fallDistance <= 0.0) {
120
                    packet.onGround = false
121
                }
122
            }
123
        }
124
    }
125
}
126