package net.minecraft.world.level.timers;

import net.minecraft.nbt.CompoundTag;
import java.util.Iterator;
import net.minecraft.tags.Tag;
import net.minecraft.server.ServerFunctionManager;
import net.minecraft.commands.CommandFunction;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.MinecraftServer;

public class FunctionTagCallback implements TimerCallback<MinecraftServer> {
    private final ResourceLocation tagId;
    
    public FunctionTagCallback(final ResourceLocation uh) {
        this.tagId = uh;
    }
    
    @Override
    public void handle(final MinecraftServer minecraftServer, final TimerQueue<MinecraftServer> ded, final long long3) {
        final ServerFunctionManager uu6 = minecraftServer.getFunctions();
        final Tag<CommandFunction> adf7 = uu6.getTag(this.tagId);
        for (final CommandFunction cw9 : adf7.getValues()) {
            uu6.execute(cw9, uu6.getGameLoopSender());
        }
    }
    
    public static class Serializer extends TimerCallback.Serializer<MinecraftServer, FunctionTagCallback> {
        public Serializer() {
            super(new ResourceLocation("function_tag"), FunctionTagCallback.class);
        }
        
        @Override
        public void serialize(final CompoundTag le, final FunctionTagCallback dea) {
            le.putString("Name", dea.tagId.toString());
        }
        
        @Override
        public FunctionTagCallback deserialize(final CompoundTag le) {
            final ResourceLocation uh3 = new ResourceLocation(le.getString("Name"));
            return new FunctionTagCallback(uh3);
        }
    }
}
