mirror of
https://github.com/Minestom/Minestom.git
synced 2025-01-06 16:37:38 +01:00
update: infinite potion duration support (#106)
* upgrade: infinite potion duration * fix: no more aqgit --------- Co-authored-by: mworzala <mattheworzala@gmail.com>
This commit is contained in:
parent
3be7b09b7d
commit
bb4d925ec4
@ -724,7 +724,9 @@ public class Entity implements Viewable, Tickable, Schedulable, Snapshotable, Ev
|
|||||||
final List<TimedPotion> effects = this.effects;
|
final List<TimedPotion> effects = this.effects;
|
||||||
if (effects.isEmpty()) return;
|
if (effects.isEmpty()) return;
|
||||||
effects.removeIf(timedPotion -> {
|
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
|
// Remove if the potion should be expired
|
||||||
if (time >= timedPotion.getStartingTime() + potionTime) {
|
if (time >= timedPotion.getStartingTime() + potionTime) {
|
||||||
// Send the packet that the potion should no longer be applied
|
// 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;
|
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.
|
* Creates a new Potion with no flags.
|
||||||
*
|
*
|
||||||
|
Loading…
Reference in New Issue
Block a user