Improved Tick utility class
This commit is contained in:
parent
8f31ea54d1
commit
2f0b59a032
@ -5,29 +5,37 @@ package fr.pandacube.lib.util;
|
|||||||
*/
|
*/
|
||||||
public class Tick {
|
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.
|
* Returns the number of ticks for the provided number of seconds.
|
||||||
* @param seconds the duration in second
|
* @param seconds the duration in seconds
|
||||||
* @return the same duration as provided, but in Minecraft server ticks
|
* @return the same duration as provided, but in Minecraft server ticks
|
||||||
*/
|
*/
|
||||||
public static long sec(long seconds) {
|
public static long ofSec(long seconds) {
|
||||||
return seconds * 20;
|
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
|
* @param minutes the duration in minutes
|
||||||
* @return the same duration as provided, but in Minecraft server ticks
|
* @return the same duration as provided, but in Minecraft server ticks
|
||||||
*/
|
*/
|
||||||
public static long min(long minutes) {
|
public static long ofMin(long minutes) {
|
||||||
return minutes * 1200;
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user