New method Tick.toDuration(long)

This commit is contained in:
Marc Baloup 2023-12-28 19:15:47 +01:00
parent 075468854d
commit 93960b83c2
1 changed files with 12 additions and 0 deletions

View File

@ -1,5 +1,7 @@
package fr.pandacube.lib.util;
import java.time.Duration;
/**
* Provides methods related to Minecraft Java server ticks.
*/
@ -44,4 +46,14 @@ public class Tick {
return tick * MS_PER_TICK;
}
/**
* Returns the {@link Duration} for the provided number of ticks.
* @param tick the duration in ticks
* @return the {@link Duration} for the provided number of ticks.
*/
public static Duration toDuration(long tick) {
return Duration.ofMillis(toMs(tick));
}
}