/* * Decompiled with CFR 0.152. * * Could not load the following classes: * com.mojang.datafixers.kinds.App * com.mojang.datafixers.kinds.Applicative * com.mojang.serialization.MapCodec * com.mojang.serialization.codecs.RecordCodecBuilder */ package net.minecraft.world.level.timers; import com.mojang.datafixers.kinds.App; import com.mojang.datafixers.kinds.Applicative; import com.mojang.serialization.MapCodec; import com.mojang.serialization.codecs.RecordCodecBuilder; import net.minecraft.commands.CommandSourceStack; import net.minecraft.commands.functions.CommandFunction; import net.minecraft.resources.Identifier; import net.minecraft.server.MinecraftServer; import net.minecraft.server.ServerFunctionManager; import net.minecraft.world.level.timers.TimerCallback; import net.minecraft.world.level.timers.TimerQueue; public record FunctionCallback(Identifier functionId) implements TimerCallback { public static final MapCodec CODEC = RecordCodecBuilder.mapCodec(i -> i.group((App)Identifier.CODEC.fieldOf("Name").forGetter(FunctionCallback::functionId)).apply((Applicative)i, FunctionCallback::new)); @Override public void handle(MinecraftServer server, TimerQueue queue, long time) { ServerFunctionManager functionManager = server.getFunctions(); functionManager.get(this.functionId).ifPresent(function -> functionManager.execute((CommandFunction)function, functionManager.getGameLoopSender())); } @Override public MapCodec codec() { return CODEC; } }