ClockTimeMarker .java

net.minecraft.world.clock.ClockTimeMarker (record, 38 lines): members: clock, periodTicks, showInCommands, resolveTimeToMoveTo, getRepetitionCount, ticks.

net.minecraft.world.clockrecord38 linescommon1.3 KB

API Surface (4)

record ClockTimeMarker(Holder<WorldClock> clock, int ticks, Optional<Integer> periodTicks, boolean showInCommands)
long getRepetitionCount(final long totalTicks)
long resolveTimeToMoveTo(final long totalTicks)
boolean occursAt(final long totalTicks)

Fields & Constants (1)

KEY_CODEC

Code Graph: Dependencies (3)

Edges (calls / imports / inherits / references) resolved by graphify from the AST. Every chip opens the class source.

Full Source

ClockTimeMarker.java38 lines · Minecraft 26.3 · verbatim
1
package net.minecraft.world.clock;
2
3
import com.mojang.serialization.Codec;
4
import java.util.Optional;
5
import net.minecraft.core.Holder;
6
import net.minecraft.resources.ResourceKey;
7
8
public record ClockTimeMarker(Holder<WorldClock> clock, int ticks, Optional<Integer> periodTicks, boolean showInCommands) {
9
	public static final Codec<ResourceKey<ClockTimeMarker>> KEY_CODEC = ResourceKey.codec(ClockTimeMarkers.ROOT_ID);
10
11
	public long getRepetitionCount(final long totalTicks) {
12
		if (this.periodTicks.isEmpty()) {
13
			return totalTicks >= this.ticks ? 1L : 0L;
14
		}
15
16
		int periodTicks = this.periodTicks.get();
17
		return totalTicks / periodTicks + (totalTicks % periodTicks >= this.ticks ? 1 : 0);
18
	}
19
20
	public long resolveTimeToMoveTo(final long totalTicks) {
21
		if (this.periodTicks.isEmpty()) {
22
			return this.ticks;
23
		}
24
25
		int periodTicks = this.periodTicks.get();
26
		return totalTicks + durationToNext(periodTicks, totalTicks % periodTicks, this.ticks);
27
	}
28
29
	public boolean occursAt(final long totalTicks) {
30
		return this.periodTicks.isEmpty() ? this.ticks == totalTicks : this.ticks == totalTicks % this.periodTicks.get().intValue();
31
	}
32
33
	private static long durationToNext(final int periodTicks, final long from, final long to) {
34
		long duration = to - from;
35
		return duration > 0L ? duration : periodTicks + duration;
36
	}
37
}
38

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