package com.thebrokenrail.twine.util.boat.gui;

import com.thebrokenrail.twine.Twine;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.screen.CraftingScreenHandler;
import net.minecraft.screen.ScreenHandlerType;

import java.util.function.Predicate;

public class BoatCraftingScreenHandler extends CraftingScreenHandler {
    private final Predicate<PlayerEntity> canUse;

    public BoatCraftingScreenHandler(int syncId, PlayerInventory playerInventory, Predicate<PlayerEntity> canUse) {
        super(syncId, playerInventory);
        this.canUse = canUse;
    }

    public BoatCraftingScreenHandler(int syncId, PlayerInventory playerInventory) {
        this(syncId, playerInventory, player -> true);
    }

    @Override
    public boolean canUse(PlayerEntity player) {
        return canUse.test(player);
    }

    @Override
    public ScreenHandlerType<?> getType() {
        return Twine.BOAT_CRAFTING_SCREEN_TYPE;
    }
}
