Skip to content

Commit

Permalink
Add effect duration setting to PotionSpoof
Browse files Browse the repository at this point in the history
  • Loading branch information
0xTas committed Oct 26, 2024
1 parent 3eb7d98 commit 4ed5b00
Showing 1 changed file with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,15 @@ public class PotionSpoof extends Module {
.build()
);

private final Setting<Integer> effectDuration = sgGeneral.add(new IntSetting.Builder()
.name("effect-duration")
.description("How many ticks to spoof the effect for.")
.range(1, 32767)
.sliderRange(20, 500)
.defaultValue(420)
.build()
);

public PotionSpoof() {
super(Categories.Player, "potion-spoof", "Spoofs potion statuses for you. SOME effects DO NOT work.");
}
Expand All @@ -73,9 +82,9 @@ private void onTick(TickEvent.Post event) {
if (mc.player.hasStatusEffect(Registries.STATUS_EFFECT.getEntry(entry.getKey()))) {
StatusEffectInstance instance = mc.player.getStatusEffect(Registries.STATUS_EFFECT.getEntry(entry.getKey()));
((StatusEffectInstanceAccessor) instance).setAmplifier(level - 1);
if (instance.getDuration() < 1000) ((StatusEffectInstanceAccessor) instance).setDuration(1000);
if (instance.getDuration() < effectDuration.get()) ((StatusEffectInstanceAccessor) instance).setDuration(effectDuration.get());
} else {
mc.player.addStatusEffect(new StatusEffectInstance(Registries.STATUS_EFFECT.getEntry(entry.getKey()), 1000, level - 1));
mc.player.addStatusEffect(new StatusEffectInstance(Registries.STATUS_EFFECT.getEntry(entry.getKey()), effectDuration.get(), level - 1));
}
}
}
Expand Down

0 comments on commit 4ed5b00

Please sign in to comment.