ScheduledTick .java

net.minecraft.world.ticks.ScheduledTick (record): members: triggerTick, priority, subTickOrder, INTRA_TICK_DRAIN_ORDER, DRAIN_ORDER, toSavedTick, probe.

net.minecraft.world.ticksrecord52 linescommon1.8 KB

API Surface (4)

int hashCode(final ScheduledTick<?> o)
boolean equals(final @Nullable ScheduledTick<?> a, final @Nullable ScheduledTick<?> b)
<T> ScheduledTick<T> probe(final T type, final BlockPos pos)
SavedTick<T> toSavedTick(final long currentTick)

Fields & Constants (3)

DRAIN_ORDER
INTRA_TICK_DRAIN_ORDER
UNIQUE_TICK_HASH

Code Graph: Dependencies (3)

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

Full Source

ScheduledTick.java52 lines · Minecraft 26.3 · verbatim
1
package net.minecraft.world.ticks;
2
3
import it.unimi.dsi.fastutil.Hash.Strategy;
4
import java.util.Comparator;
5
import net.minecraft.core.BlockPos;
6
import org.jspecify.annotations.Nullable;
7
8
public record ScheduledTick<T>(T type, BlockPos pos, long triggerTick, TickPriority priority, long subTickOrder) {
9
	public static final Comparator<ScheduledTick<?>> DRAIN_ORDER = (o1, o2) -> {
10
		int compare = Long.compare(o1.triggerTick, o2.triggerTick);
11
		if (compare != 0) {
12
			return compare;
13
		}
14
15
		compare = o1.priority.compareTo(o2.priority);
16
		return compare != 0 ? compare : Long.compare(o1.subTickOrder, o2.subTickOrder);
17
	};
18
	public static final Comparator<ScheduledTick<?>> INTRA_TICK_DRAIN_ORDER = (o1, o2) -> {
19
		int compare = o1.priority.compareTo(o2.priority);
20
		return compare != 0 ? compare : Long.compare(o1.subTickOrder, o2.subTickOrder);
21
	};
22
	public static final Strategy<ScheduledTick<?>> UNIQUE_TICK_HASH = new Strategy<ScheduledTick<?>>() {
23
		public int hashCode(final ScheduledTick<?> o) {
24
			return 31 * o.pos().hashCode() + o.type().hashCode();
25
		}
26
27
		public boolean equals(final @Nullable ScheduledTick<?> a, final @Nullable ScheduledTick<?> b) {
28
			if (a == b) {
29
				return true;
30
			} else {
31
				return a != null && b != null ? a.type() == b.type() && a.pos().equals(b.pos()) : false;
32
			}
33
		}
34
	};
35
36
	public ScheduledTick(final T type, final BlockPos pos, final long triggerTick, final long subTickOrder) {
37
		this(type, pos, triggerTick, TickPriority.NORMAL, subTickOrder);
38
	}
39
40
	public ScheduledTick {
41
		pos = pos.immutable();
42
	}
43
44
	public static <T> ScheduledTick<T> probe(final T type, final BlockPos pos) {
45
		return new ScheduledTick<>(type, pos, 0L, TickPriority.NORMAL, 0L);
46
	}
47
48
	public SavedTick<T> toSavedTick(final long currentTick) {
49
		return new SavedTick<>(this.type, this.pos, (int)(this.triggerTick - currentTick), this.priority);
50
	}
51
}
52

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