diff --git a/pandalib-util/src/main/java/fr/pandacube/lib/util/Tick.java b/pandalib-util/src/main/java/fr/pandacube/lib/util/Tick.java index 4e8d145..2546ece 100644 --- a/pandalib-util/src/main/java/fr/pandacube/lib/util/Tick.java +++ b/pandalib-util/src/main/java/fr/pandacube/lib/util/Tick.java @@ -4,30 +4,38 @@ package fr.pandacube.lib.util; * Provides methods related to Minecraft Java server ticks. */ public class Tick { + + public static final int TPS = 20; + + public static final int MS_PER_TICK = 1000 / TPS; /** - * Returns the number of tick is the provided number of seconds. - * @param seconds the duration in second + * Returns the number of ticks for the provided number of seconds. + * @param seconds the duration in seconds * @return the same duration as provided, but in Minecraft server ticks */ - public static long sec(long seconds) { - return seconds * 20; + public static long ofSec(long seconds) { + return seconds * TPS; } /** - * Returns the number of tick is the provided number of minutes. + * Returns the number of ticks for the provided number of minutes. * @param minutes the duration in minutes * @return the same duration as provided, but in Minecraft server ticks */ - public static long min(long minutes) { - return minutes * 1200; + public static long ofMin(long minutes) { + return minutes * TPS * 60; + } + + + /** + * Returns the number of milliseconds for the provided number of ticks. + * @param tick the duration in ticks + * @return the same duration as provided, but in milliseconds + */ + public static long toMs(long tick) { + return tick * MS_PER_TICK; } - - - - - - }