@@ -73,6 +73,22 @@ public class AutoGap extends Module {
7373 );
7474
7575 // Potions
76+ private final Setting <Boolean > beforeExpiry = sgPotions .add (new BoolSetting .Builder ()
77+ .name ("before-expiry" )
78+ .description ("If it should eat before potion effects expire." )
79+ .defaultValue (false )
80+ .build ()
81+ );
82+
83+ private final Setting <Integer > expiryThreshold = sgPotions .add (new IntSetting .Builder ()
84+ .name ("expiry-threshold" )
85+ .description ("Time in ticks before the potion effect expires to start eating." )
86+ .defaultValue (60 )
87+ .min (0 )
88+ .sliderMax (200 )
89+ .visible (beforeExpiry ::get )
90+ .build ()
91+ );
7692
7793 private final Setting <Boolean > potionsRegeneration = sgPotions .add (new BoolSetting .Builder ()
7894 .name ("potions-regeneration" )
@@ -255,18 +271,27 @@ private boolean shouldEatPotions() {
255271 Map <RegistryEntry <StatusEffect >, StatusEffectInstance > effects = mc .player .getActiveStatusEffects ();
256272
257273 // Regeneration
258- if (potionsRegeneration .get () && !effects .containsKey (StatusEffects .REGENERATION )) return true ;
274+ if (potionsRegeneration .get ()) {
275+ StatusEffectInstance effect = effects .get (StatusEffects .REGENERATION );
276+ if (effect == null || (beforeExpiry .get () && effect .getDuration () <= expiryThreshold .get ())) return true ;
277+ }
259278
260279 // Fire resistance
261- if (potionsFireResistance .get () && !effects .containsKey (StatusEffects .FIRE_RESISTANCE )) {
262- requiresEGap = true ;
263- return true ;
280+ if (potionsFireResistance .get ()) {
281+ StatusEffectInstance effect = effects .get (StatusEffects .FIRE_RESISTANCE );
282+ if (effect == null || (beforeExpiry .get () && effect .getDuration () <= expiryThreshold .get ())) {
283+ requiresEGap = true ;
284+ return true ;
285+ }
264286 }
265287
266288 // Absorption
267- if (potionsAbsorption .get () && !effects .containsKey (StatusEffects .ABSORPTION )) {
268- requiresEGap = true ;
269- return true ;
289+ if (potionsAbsorption .get ()) {
290+ StatusEffectInstance effect = effects .get (StatusEffects .ABSORPTION );
291+ if (effect == null || (beforeExpiry .get () && effect .getDuration () <= expiryThreshold .get ())) {
292+ requiresEGap = true ;
293+ return true ;
294+ }
270295 }
271296
272297 return false ;
0 commit comments