AutoBuff module

AutoBuff: Minecraft 26.3 cheat module, full source for every implementation (1 client: MelaHack (ThunderHack fork)).

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.

MelaHack (ThunderHack fork)COMBATsrc/main/java/thunder/hack/features/modules/combat/AutoBuff.javaJava · 130 lines · 6.4 KB

Automatically throws potions at you.

SettingsStrengthSpeedFireResistanceInstantHealingHealthRegenerationTriggerHPOnlyOnGroundPauseAura
AutoBuff.javaJava · Minecraft 26.2 · 130 lines · 6.4 KB · complete file, verbatimOriginal ↗
1
package thunder.hack.features.modules.combat;
2
3
import meteordevelopment.orbit.EventHandler;
4
import net.minecraft.core.Holder;
5
import net.minecraft.core.component.DataComponents;
6
import net.minecraft.network.protocol.game.ServerboundSetCarriedItemPacket;
7
import net.minecraft.network.protocol.game.ServerboundUseItemPacket;
8
import net.minecraft.world.InteractionHand;
9
import net.minecraft.world.effect.MobEffect;
10
import net.minecraft.world.effect.MobEffectInstance;
11
import net.minecraft.world.effect.MobEffects;
12
import net.minecraft.world.item.ItemStack;
13
import net.minecraft.world.item.SplashPotionItem;
14
import net.minecraft.world.item.alchemy.PotionContents;
15
import thunder.hack.core.manager.client.ModuleManager;
16
import thunder.hack.events.impl.EventAfterRotate;
17
import thunder.hack.events.impl.EventPostSync;
18
import thunder.hack.features.modules.Module;
19
import thunder.hack.setting.Setting;
20
import thunder.hack.setting.impl.BooleanSettingGroup;
21
import thunder.hack.utility.Timer;
22
23
public final class AutoBuff extends Module {
24
    private final Setting<Boolean> strength = new Setting<>("Strength", true);
25
    private final Setting<Boolean> speed = new Setting<>("Speed", true);
26
    private final Setting<Boolean> fire = new Setting<>("FireResistance", true);
27
    private final Setting<BooleanSettingGroup> heal = new Setting<>("InstantHealing", new BooleanSettingGroup(true));
28
    private final Setting<Integer> healthH = new Setting<>("Health", 8, 0, 20).addToGroup(heal);
29
    private final Setting<BooleanSettingGroup> regen = new Setting<>("Regeneration", new BooleanSettingGroup(true));
30
    private final Setting<TriggerOn> triggerOn = new Setting<>("Trigger", TriggerOn.LackOfRegen).addToGroup(regen);
31
    private final Setting<Integer> healthR = new Setting<>("HP", 8, 0, 20, v -> triggerOn.is(TriggerOn.Health)).addToGroup(regen);
32
    private final Setting<Boolean> onDaGround = new Setting<>("OnlyOnGround", true);
33
    private final Setting<Boolean> pauseAura = new Setting<>("PauseAura", false);
34
35
    public Timer timer = new Timer();
36
    private boolean spoofed = false;
37
38
    public AutoBuff() {
39
        super("AutoBuff", Category.COMBAT);
40
    }
41
42
    public static int getPotionSlot(Potions potion) {
43
        for (int i = 0; i < 9; ++i)
44
            if (isStackPotion(mc.player.getInventory().getItem(i), potion)) return i;
45
        return -1;
46
    }
47
48
    public static boolean isPotionOnHotBar(Potions potions) {
49
        return getPotionSlot(potions) != -1;
50
    }
51
52
    public static boolean isStackPotion(ItemStack stack, Potions potion) {
53
        if (stack == null) return false;
54
55
        if (stack.getItem() instanceof SplashPotionItem) {
56
            PotionContents potionContentsComponent = stack.getOrDefault(DataComponents.POTION_CONTENTS, PotionContents.EMPTY);
57
58
            Holder<MobEffect> id = null;
59
60
            switch (potion) {
61
                case STRENGTH -> id = MobEffects.STRENGTH;
62
                case SPEED -> id = MobEffects.SPEED;
63
                case FIRERES -> id = MobEffects.FIRE_RESISTANCE;
64
                case HEAL -> id = MobEffects.INSTANT_HEALTH;
65
                case REGEN -> id = MobEffects.REGENERATION;
66
            }
67
68
            for (MobEffectInstance effect : potionContentsComponent.getAllEffects()) {
69
                if (effect.getEffect() == id) return true;
70
            }
71
        }
72
        return false;
73
    }
74
75
    @EventHandler
76
    public void onPostRotationSet(EventAfterRotate event) {
77
        if (Aura.target != null && mc.player.getAttackStrengthScale(1) > 0.5f) return;
78
        if (mc.player.tickCount > 80 && shouldThrow()) {
79
            mc.player.setXRot(90);
80
            spoofed = true;
81
        }
82
    }
83
84
    private boolean shouldThrow() {
85
        return (!mc.player.hasEffect(MobEffects.SPEED) && isPotionOnHotBar(Potions.SPEED) && speed.getValue()) || (!mc.player.hasEffect(MobEffects.STRENGTH) && isPotionOnHotBar(Potions.STRENGTH) && strength.getValue()) || (!mc.player.hasEffect(MobEffects.FIRE_RESISTANCE) && isPotionOnHotBar(Potions.FIRERES) && fire.getValue()) || (mc.player.getHealth() + mc.player.getAbsorptionAmount() < healthH.getValue() && isPotionOnHotBar(Potions.HEAL) && heal.getValue().isEnabled()) || (!mc.player.hasEffect(MobEffects.REGENERATION) && triggerOn.is(TriggerOn.LackOfRegen) && isPotionOnHotBar(Potions.REGEN) && regen.getValue().isEnabled()) || (mc.player.getHealth() + mc.player.getAbsorptionAmount() < healthR.getValue() && triggerOn.is(TriggerOn.Health) && isPotionOnHotBar(Potions.REGEN) && regen.getValue().isEnabled());
86
    }
87
88
    @EventHandler
89
    public void onPostSync(EventPostSync e) {
90
        if (Aura.target != null && mc.player.getAttackStrengthScale(1) > 0.5f) return;
91
92
        if (onDaGround.getValue() && !mc.player.onGround()) return;
93
94
        if (mc.player.tickCount > 80 && shouldThrow() && timer.passedMs(1000) && spoofed) {
95
            if (!mc.player.hasEffect(MobEffects.SPEED) && isPotionOnHotBar(Potions.SPEED) && speed.getValue())
96
                throwPotion(Potions.SPEED);
97
98
            if (!mc.player.hasEffect(MobEffects.STRENGTH) && isPotionOnHotBar(Potions.STRENGTH) && strength.getValue())
99
                throwPotion(Potions.STRENGTH);
100
101
            if (!mc.player.hasEffect(MobEffects.FIRE_RESISTANCE) && isPotionOnHotBar(Potions.FIRERES) && fire.getValue())
102
                throwPotion(Potions.FIRERES);
103
104
            if (mc.player.getHealth() + mc.player.getAbsorptionAmount() < healthH.getValue() && heal.getValue().isEnabled() && isPotionOnHotBar(Potions.HEAL))
105
                throwPotion(Potions.HEAL);
106
107
            if (((!mc.player.hasEffect(MobEffects.REGENERATION) && triggerOn.is(TriggerOn.LackOfRegen)) || (mc.player.getHealth() + mc.player.getAbsorptionAmount() < healthR.getValue() && triggerOn.is(TriggerOn.Health))) && isPotionOnHotBar(Potions.REGEN) && regen.getValue().isEnabled())
108
                throwPotion(Potions.REGEN);
109
110
            sendPacket(new ServerboundSetCarriedItemPacket(mc.player.getInventory().getSelectedSlot()));
111
            timer.reset();
112
            spoofed = false;
113
        }
114
    }
115
116
    public void throwPotion(Potions potion) {
117
        if (pauseAura.getValue()) ModuleManager.aura.pause();
118
        sendPacket(new ServerboundSetCarriedItemPacket(getPotionSlot(potion)));
119
        sendSequencedPacket(id -> new ServerboundUseItemPacket(InteractionHand.MAIN_HAND, id, mc.player.getYRot(), mc.player.getXRot()));
120
    }
121
122
    public enum Potions {
123
        STRENGTH, SPEED, FIRERES, HEAL, REGEN
124
    }
125
126
    public enum TriggerOn {
127
        LackOfRegen, Health
128
    }
129
}
130