2025-11-24 22:52:51 +03:00

40 lines
1.6 KiB
Java

/*
* 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<MinecraftServer>
{
public static final MapCodec<FunctionCallback> 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<MinecraftServer> queue, long time) {
ServerFunctionManager functionManager = server.getFunctions();
functionManager.get(this.functionId).ifPresent(function -> functionManager.execute((CommandFunction<CommandSourceStack>)function, functionManager.getGameLoopSender()));
}
@Override
public MapCodec<FunctionCallback> codec() {
return CODEC;
}
}