Advertisement
Guest User

Untitled

a guest
Jan 22nd, 2019
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 KB | None | 0 0
  1. public class Lag implements Runnable {
  2. public static int TICK_COUNT= 0;
  3. public static long[] TICKS= new long[600];
  4. public static long LAST_TICK= 0L;
  5.  
  6. public static double getTPS()
  7. {
  8. return getTPS(100);
  9. }
  10.  
  11. public static double getTPS(int ticks)
  12. {
  13. if (TICK_COUNT< ticks) {
  14. return 20.0D;
  15. }
  16. int target = (TICK_COUNT- 1 - ticks) % TICKS.length;
  17. long elapsed = System.currentTimeMillis() - TICKS[target];
  18.  
  19. return ticks / (elapsed / 1000.0D);
  20. }
  21.  
  22. public static long getElapsed(int tickID)
  23. {
  24. if (TICK_COUNT- tickID >= TICKS.length)
  25. {
  26. }
  27.  
  28. long time = TICKS[(tickID % TICKS.length)];
  29. return System.currentTimeMillis() - time;
  30. }
  31.  
  32. public void run()
  33. {
  34. TICKS[(TICK_COUNT% TICKS.length)] = System.currentTimeMillis();
  35.  
  36. TICK_COUNT+= 1;
  37. }
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement