package net.minecraft.world.inventory;

import net.minecraft.world.level.GameRules;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.level.Level;
import java.util.Collection;
import java.util.Collections;
import net.minecraft.world.entity.player.Player;
import javax.annotation.Nullable;
import net.minecraft.world.item.crafting.Recipe;

public interface RecipeHolder {
    void setRecipeUsed(@Nullable final Recipe<?> bgw);
    
    @Nullable
    Recipe<?> getRecipeUsed();
    
    default void awardAndReset(final Player ayj) {
        final Recipe<?> bgw3 = this.getRecipeUsed();
        if (bgw3 != null && !bgw3.isSpecial()) {
            ayj.awardRecipes(Collections.<Recipe<?>>singleton(bgw3));
            this.setRecipeUsed(null);
        }
    }
    
    default boolean setRecipeUsed(final Level bjw, final ServerPlayer xe, final Recipe<?> bgw) {
        if (bgw.isSpecial() || !bjw.getGameRules().getBoolean(GameRules.RULE_LIMITED_CRAFTING) || xe.getRecipeBook().contains(bgw)) {
            this.setRecipeUsed(bgw);
            return true;
        }
        return false;
    }
}
