package net.minecraft.world.inventory;

import java.util.function.BiConsumer;
import java.util.Optional;
import java.util.function.BiFunction;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.Level;

public interface ContainerLevelAccess {
    public static final ContainerLevelAccess NULL = new ContainerLevelAccess() {
        @Override
        public <T> Optional<T> evaluate(final BiFunction<Level, BlockPos, T> biFunction) {
            return Optional.<T>empty();
        }
    };
    
    default ContainerLevelAccess create(final Level bqb, final BlockPos fu) {
        return new ContainerLevelAccess() {
            @Override
            public <T> Optional<T> evaluate(final BiFunction<Level, BlockPos, T> biFunction) {
                return Optional.<T>of(biFunction.apply(bqb, fu));
            }
        };
    }
    
     <T> Optional<T> evaluate(final BiFunction<Level, BlockPos, T> biFunction);
    
    default <T> T evaluate(final BiFunction<Level, BlockPos, T> biFunction, final T object) {
        return this.<T>evaluate(biFunction).orElse(object);
    }
    
    default void execute(final BiConsumer<Level, BlockPos> biConsumer) {
        this.<Optional<Object>>evaluate((bqb, fu) -> {
            biConsumer.accept(bqb, fu);
            return Optional.empty();
        });
    }
}
