Stopwatch.java

net.minecraft.world.Stopwatch

信息

  • 全限定名:net.minecraft.world.Stopwatch
  • 类型:public record
  • 包:net.minecraft.world
  • 源码路径:src/main/java/net/minecraft/world/Stopwatch.java
  • 起始行号:L3
  • 职责:

    TODO

字段/常量

内部类/嵌套类型

构造器

public Stopwatch(long creationTime) @ L4

  • 构造器名:Stopwatch
  • 源码定位:L4
  • 修饰符:public

参数:

  • creationTime: long

说明:

TODO

方法

下面的方法块按源码顺序生成。

public long elapsedMilliseconds(long currentTime) @ L8

  • 方法名:elapsedMilliseconds
  • 源码定位:L8
  • 返回类型:long
  • 修饰符:public

参数:

  • currentTime: long

说明:

TODO

public double elapsedSeconds(long currentTime) @ L13

  • 方法名:elapsedSeconds
  • 源码定位:L13
  • 返回类型:double
  • 修饰符:public

参数:

  • currentTime: long

说明:

TODO

代码

public record Stopwatch(long creationTime, long accumulatedElapsedTime) {
    public Stopwatch(long creationTime) {
        this(creationTime, 0L);
    }
 
    public long elapsedMilliseconds(long currentTime) {
        long timeSinceInstanceCreation = currentTime - this.creationTime;
        return this.accumulatedElapsedTime + timeSinceInstanceCreation;
    }
 
    public double elapsedSeconds(long currentTime) {
        return this.elapsedMilliseconds(currentTime) / 1000.0;
    }
}

引用的其他类