package top.r3944realms.lib39.util;

import net.minecraft.world.level.Level;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.Nullable;

/**
 * The interface Level helper.
 */
public interface ILevelHelper {
    /**
     * Gets level.
     *
     * @return the level
     */
    Level getLevel();

    /**
     * The enum Level helper.
     */
    enum LevelHelper implements ILevelHelper {
        /**
         * Server level helper.
         */
        SERVER,
        /**
         * Client level helper.
         */
        CLIENT;
        /**
         * The Level.
         */
        Level level;
        @Override
        @Nullable
        public Level getLevel() {
            return level;
        }

        /**
         * Sets level.
         *
         * @param level the level
         */
        @ApiStatus.Internal
        public void setLevel(Level level) {
            this.level = level;
        }
    }

    /**
     * Gets server level.
     *
     * @return the server level
     */
    @Nullable
    static Level getServerLevel() {
        return LevelHelper.SERVER.getLevel();
    }

    /**
     * Gets client level.
     *
     * @return the client level
     */
    @Nullable
    @OnlyIn(Dist.CLIENT)
    static Level getClientLevel() {
        return LevelHelper.CLIENT.getLevel();
    }
}
