update: infinite potion duration support (#106)

* upgrade: infinite potion duration

* fix: no more aqgit

---------

Co-authored-by: mworzala <mattheworzala@gmail.com>
(cherry picked from commit bb4d925ec4)
This commit is contained in:
DeidaraMC 2024-01-15 20:37:21 -05:00 committed by Matt Worzala
parent c421971eaa
commit 35f9489280
2 changed files with 8 additions and 1 deletions

View File

@ -724,7 +724,9 @@ public class Entity implements Viewable, Tickable, Schedulable, Snapshotable, Ev
final List<TimedPotion> effects = this.effects;
if (effects.isEmpty()) return;
effects.removeIf(timedPotion -> {
final long potionTime = (long) timedPotion.getPotion().duration() * MinecraftServer.TICK_MS;
long duration = timedPotion.getPotion().duration();
if (duration == Potion.INFINITE_DURATION) return false;
final long potionTime = duration * MinecraftServer.TICK_MS;
// Remove if the potion should be expired
if (time >= timedPotion.getStartingTime() + potionTime) {
// Send the packet that the potion should no longer be applied

View File

@ -48,6 +48,11 @@ public record Potion(@NotNull PotionEffect effect, byte amplifier,
*/
public static final byte ICON_FLAG = 0x04;
/**
* A duration constant which sets a Potion duration to infinite.
*/
public static final int INFINITE_DURATION = -1;
/**
* Creates a new Potion with no flags.
*