mirror of
https://github.com/Minestom/Minestom.git
synced 2025-01-04 23:47:59 +01:00
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:
parent
c421971eaa
commit
35f9489280
@ -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
|
||||
|
@ -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.
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user