diff --git a/src/main/java/net/minestom/server/entity/Entity.java b/src/main/java/net/minestom/server/entity/Entity.java index 0cc929cd2..db957dbf7 100644 --- a/src/main/java/net/minestom/server/entity/Entity.java +++ b/src/main/java/net/minestom/server/entity/Entity.java @@ -724,7 +724,9 @@ public class Entity implements Viewable, Tickable, Schedulable, Snapshotable, Ev final List 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 diff --git a/src/main/java/net/minestom/server/potion/Potion.java b/src/main/java/net/minestom/server/potion/Potion.java index 9fda569f6..6ad326aa0 100644 --- a/src/main/java/net/minestom/server/potion/Potion.java +++ b/src/main/java/net/minestom/server/potion/Potion.java @@ -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. *