TimerCallbacks .java

net.minecraft.world.level.timers.TimerCallbacks (class): members: SERVER_CALLBACKS, idMapper, register, codec. strings: "function_tag", "function".

net.minecraft.world.level.timersclass27 linescommon1.1 KB

API Surface (2)

TimerCallbacks<C> register(final Identifier id, final MapCodec<? extends TimerCallback<C>> codec)
Codec<TimerCallback<C>> codec()

Fields & Constants (3)

SERVER_CALLBACKS
idMapper
codec

String literals (2)

"function"
"function_tag"

Code Graph: Dependencies (4)

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

Full Source

TimerCallbacks.java27 lines · Minecraft 26.3 · verbatim
1
package net.minecraft.world.level.timers;
2
3
import com.google.common.annotations.VisibleForTesting;
4
import com.mojang.serialization.Codec;
5
import com.mojang.serialization.MapCodec;
6
import java.util.function.Function;
7
import net.minecraft.resources.Identifier;
8
import net.minecraft.server.MinecraftServer;
9
import net.minecraft.util.ExtraCodecs;
10
11
public class TimerCallbacks<C> {
12
	public static final TimerCallbacks<MinecraftServer> SERVER_CALLBACKS = new TimerCallbacks<MinecraftServer>()
13
		.register(Identifier.withDefaultNamespace("function"), FunctionCallback.CODEC)
14
		.register(Identifier.withDefaultNamespace("function_tag"), FunctionTagCallback.CODEC);
15
	private final ExtraCodecs.LateBoundIdMapper<Identifier, MapCodec<? extends TimerCallback<C>>> idMapper = new ExtraCodecs.LateBoundIdMapper<>();
16
	private final Codec<TimerCallback<C>> codec = this.idMapper.codec(Identifier.CODEC).dispatch(TimerCallback::codec, Function.identity());
17
18
	public TimerCallbacks<C> register(final Identifier id, final MapCodec<? extends TimerCallback<C>> codec) {
19
		this.idMapper.put(id, codec);
20
		return this;
21
	}
22
23
	public Codec<TimerCallback<C>> codec() {
24
		return this.codec;
25
	}
26
}
27

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