Here you can find the source of convertMillisToTicks(long milliseconds)
Parameter | Description |
---|---|
milliseconds | The milliseconds to convert from. |
public static long convertMillisToTicks(long milliseconds)
//package com.java2s; //License from project: Open Source License public class Main { /**//w w w .jav a2 s.c o m * Convert milliseconds to minecraft ticks (20th of a second). * * @param milliseconds The milliseconds to convert from. * @return The ticks converted from the millis. */ public static long convertMillisToTicks(long milliseconds) { double nearestTickTime = round(milliseconds, 50); return (long) ((nearestTickTime / 1000) * 20); } /** * Round the value to the nearest factor. * * @param value The value to round. * @param factor The factor of where to round. * @return The rounded value. */ public static double round(double value, double factor) { return (Math.round(value / factor) * factor); } }