package top.r3944realms.lib39.api.callback.client;

import net.fabricmc.fabric.api.event.Event;
import net.fabricmc.fabric.api.event.EventFactory;
import net.minecraft.client.multiplayer.ClientLevel;

/**
 * The interface Client world callback.
 */
public interface ClientWorldCallback {
    /**
     * The constant LOAD.
     */
    Event<ClientWorldCallback.Load> LOAD = EventFactory.createArrayBacked(ClientWorldCallback.Load.class, (callbacks) -> (world) -> {
        for (Load callback : callbacks) {
            callback.onWorldLoad(world);
        }
    });
    /**
     * The constant UNLOAD.
     */
    Event<ClientWorldCallback.Unload> UNLOAD = EventFactory.createArrayBacked(ClientWorldCallback.Unload.class, (callbacks) -> (world) -> {
        for (Unload callback : callbacks) {
            callback.onWorldUnload(world);
        }
    });

    /**
     * The interface Unload.
     */
    @FunctionalInterface
    interface Unload {
        /**
         * On world unload.
         *
         * @param clientLevel the client level
         */
        void onWorldUnload(ClientLevel clientLevel);
    }

    /**
     * The interface Load.
     */
    @FunctionalInterface
    interface Load {
        /**
         * On world load.
         *
         * @param clientLevel the client level
         */
        void onWorldLoad(ClientLevel clientLevel);
    }
}
