Stopwatch .java

net.minecraft.world.Stopwatch (record, 17 lines): members: creationTime, accumulatedElapsedTime, elapsedMilliseconds, elapsedSeconds.

net.minecraft.worldrecord17 linescommon494 B

API Surface (3)

record Stopwatch(long creationTime, long accumulatedElapsedTime)
long elapsedMilliseconds(final long currentTime)
double elapsedSeconds(final long currentTime)

Full Source

Stopwatch.java17 lines · Minecraft 26.3 · verbatim
1
package net.minecraft.world;
2
3
public record Stopwatch(long creationTime, long accumulatedElapsedTime) {
4
	public Stopwatch(final long creationTime) {
5
		this(creationTime, 0L);
6
	}
7
8
	public long elapsedMilliseconds(final long currentTime) {
9
		long timeSinceInstanceCreation = currentTime - this.creationTime;
10
		return this.accumulatedElapsedTime + timeSinceInstanceCreation;
11
	}
12
13
	public double elapsedSeconds(final long currentTime) {
14
		return this.elapsedMilliseconds(currentTime) / 1000.0;
15
	}
16
}
17

Decompiled Minecraft 26.3 source of Stopwatch (net/minecraft/world/Stopwatch.java) with Mojang official mappings, stored verbatim on the site.