All Downloads are FREE. Search and download functionalities are using the official Maven repository.

personthecat.catlib.event.lifecycle.ClientTickEvent Maven / Gradle / Ivy

package personthecat.catlib.event.lifecycle;

import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.class_310;
import personthecat.catlib.event.LibEvent;
import record;
import java.util.function.Consumer;

@Environment(EnvType.CLIENT)
public class ClientTickEvent {

    public static final LibEvent> END =
        LibEvent.nonRecursive(fs -> mc -> fs.forEach(f -> f.accept(mc)));

    public static void registerSingle(final Consumer f) {
        END.register(new SingleTickListener(f));
    }

    private record SingleTickListener(Consumer wrapped) implements Consumer {
        @Override
        public void accept(final class_310 mc) {
            this.wrapped.accept(mc);
            END.deregister(this);
        }
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy