PotionSaver module

PotionSaver: Minecraft 26.3 cheat module, full source for every implementation (1 client: OfflineClient).

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.

OfflineClientPLAYERsrc/main/java/com/jellypudding/offlineclient/modules/player/PotionSaver.javaJava · 82 lines · 3.7 KB

Stops your effect timers whilst you stand still.

SettingsChosen effects onlyEffectsBad effectsOnly whilst stillIn the air
PotionSaver.javaJava · Minecraft 26.2 · 82 lines · 3.7 KB · complete file, verbatimOriginal ↗
1
package com.jellypudding.offlineclient.modules.player;
2
3
import com.jellypudding.offlineclient.module.Category;
4
import com.jellypudding.offlineclient.module.Module;
5
import com.jellypudding.offlineclient.setting.BoolSetting;
6
import com.jellypudding.offlineclient.setting.RegistryListSetting;
7
import net.minecraft.core.registries.BuiltInRegistries;
8
import net.minecraft.world.effect.MobEffect;
9
import net.minecraft.world.effect.MobEffectCategory;
10
import net.minecraft.world.effect.MobEffectInstance;
11
import net.minecraft.world.effect.MobEffects;
12
import net.minecraft.world.phys.Vec3;
13
14
import java.util.List;
15
16
// Holds the effect timers still whilst the player stands still.
17
// The count is client side and a server keeps its own.
18
public final class PotionSaver extends Module {
19
20
    // Friction leaves a small drift for a few ticks after the keys go up.
21
    private static final double STILL = 1.0E-3;
22
23
    private final BoolSetting chosenOnly = new BoolSetting("Chosen effects only",
24
        "Freeze only the effects picked below instead of every effect that does no harm.",
25
        false);
26
    private final RegistryListSetting<MobEffect> effects = new RegistryListSetting<>("Effects",
27
        "The effects to freeze. Click to pick them.", BuiltInRegistries.MOB_EFFECT, List.of(
28
            MobEffects.STRENGTH.value(), MobEffects.ABSORPTION.value(),
29
            MobEffects.RESISTANCE.value(), MobEffects.FIRE_RESISTANCE.value(),
30
            MobEffects.SPEED.value(), MobEffects.HASTE.value(),
31
            MobEffects.REGENERATION.value(), MobEffects.WATER_BREATHING.value(),
32
            MobEffects.SATURATION.value(), MobEffects.LUCK.value(),
33
            MobEffects.SLOW_FALLING.value(), MobEffects.DOLPHINS_GRACE.value(),
34
            MobEffects.CONDUIT_POWER.value(), MobEffects.HERO_OF_THE_VILLAGE.value()))
35
        .under(chosenOnly);
36
    private final BoolSetting harmful = new BoolSetting("Bad effects",
37
        "Also freeze harmful effects. Poison and wither run out normally when this is off.",
38
        false).unless(chosenOnly);
39
    private final BoolSetting onlyStill = new BoolSetting("Only whilst still",
40
        "Freeze only whilst you stand still. Off freezes the timers wherever you go.", true);
41
    private final BoolSetting inAir = new BoolSetting("In the air",
42
        "Keep freezing whilst you are falling or swimming.", false).under(onlyStill);
43
44
    public PotionSaver() {
45
        super("PotionSaver", "Stops your effect timers whilst you stand still.",
46
            Category.PLAYER);
47
        addSettings(chosenOnly, effects, harmful, onlyStill, inAir);
48
        searchTags("potion saver", "effect timer", "freeze effects");
49
    }
50
51
    // Called from the effect tick for every living entity. A single player world runs
52
    // that tick on the server thread where the client effect map must not be read.
53
    public boolean shouldFreeze(MobEffectInstance effect) {
54
        if (!isEnabled() || !mc.isSameThread() || !inGame()) {
55
            return false;
56
        }
57
        // Other entities carry their own instances of the same effect.
58
        if (mc.player.getActiveEffectsMap().get(effect.getEffect()) != effect) {
59
            return false;
60
        }
61
        if (!wanted(effect.getEffect().value())) {
62
            return false;
63
        }
64
        return !onlyStill.isOn() || standingStill();
65
    }
66
67
    private boolean wanted(MobEffect effect) {
68
        if (chosenOnly.isOn()) {
69
            return effects.contains(effect);
70
        }
71
        return harmful.isOn() || effect.getCategory() != MobEffectCategory.HARMFUL;
72
    }
73
74
    private boolean standingStill() {
75
        if (!inAir.isOn() && !mc.player.onGround()) {
76
            return false;
77
        }
78
        Vec3 motion = mc.player.getDeltaMovement();
79
        return Math.abs(motion.x) < STILL && Math.abs(motion.z) < STILL;
80
    }
81
}
82