632b781af97903
本帖最后由 632b781af97903 于 2022-8-14 21:53 编辑

别发wiki;看过了 还是没理解那个转换方式

可以选择给转换公式或改好下边的
下边的勉强能用,但是有点小问题
如果要改的尽量改成ess插件的这种格式



  1. double tick = 1000;
  2. String t[] = (((tick + 6000) / 1000) + "").split("\\.");
  3. long a = Long.valueOf(t[0]);
  4. long b = Long.valueOf(t[1]) / 16;
  5. System.out.println(a + ":" + b);
复制代码



Don_Trueno
首先你得知道mc内20tick等于现实1s,mc一天等于现实1200s
所以mc一天等于24000tick    且0tick为上午6:00
所以(tick+6000)除以1000,余数是小时,商*(60/1000)为分钟
long a=tick/1000+6
long b=tick%1000*60/1000
(不清楚有没有取余符号%)

阿夸阿夸
本帖最后由 阿夸阿夸 于 2022-8-14 22:12 编辑

既然你想要 Essentials 的转换格式,为啥不看看它的源码呢
https://github.com/EssentialsX/E ... ickFormat.java#L221

  1. // Assume the server time starts at 0. It would start on a day.
  2. // But we will simulate that the server started with 0 at midnight.
  3. ticks = ticks - ticksAtMidnight + ticksPerDay;

  4. // How many ingame days have passed since the server start?
  5. final long days = ticks / ticksPerDay;
  6. ticks -= days * ticksPerDay;

  7. // How many hours on the last day?
  8. final long hours = ticks / ticksPerHour;
  9. ticks -= hours * ticksPerHour;

  10. // How many minutes on the last day?
  11. final long minutes = (long) Math.floor(ticks / ticksPerMinute);
  12. final double dticks = ticks - minutes * ticksPerMinute;

  13. // How many seconds on the last day?
  14. final long seconds = (long) Math.floor(dticks / ticksPerSecond);
复制代码
其中的 hours, minutes, seconds 就是时:分:秒这样的格式