package net.minecraft.world.level.timers; import com.google.common.annotations.VisibleForTesting; import com.mojang.serialization.Codec; import com.mojang.serialization.MapCodec; import java.util.function.Function; import net.minecraft.resources.ResourceLocation; import net.minecraft.server.MinecraftServer; import net.minecraft.util.ExtraCodecs; public class TimerCallbacks { public static final TimerCallbacks SERVER_CALLBACKS = new TimerCallbacks() .register(ResourceLocation.withDefaultNamespace("function"), FunctionCallback.CODEC) .register(ResourceLocation.withDefaultNamespace("function_tag"), FunctionTagCallback.CODEC); private final ExtraCodecs.LateBoundIdMapper>> idMapper = new ExtraCodecs.LateBoundIdMapper<>(); private final Codec> codec = this.idMapper.codec(ResourceLocation.CODEC).dispatch("Type", TimerCallback::codec, Function.identity()); public TimerCallbacks register(ResourceLocation name, MapCodec> codec) { this.idMapper.put(name, codec); return this; } public Codec> codec() { return this.codec; } }