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<?> bmu);
    
    @Nullable
    Recipe<?> getRecipeUsed();
    
    default void awardUsedRecipes(final Player bec) {
        final Recipe<?> bmu3 = this.getRecipeUsed();
        if (bmu3 != null && !bmu3.isSpecial()) {
            bec.awardRecipes(Collections.<Recipe<?>>singleton(bmu3));
            this.setRecipeUsed(null);
        }
    }
    
    default boolean setRecipeUsed(final Level bqb, final ServerPlayer ze, final Recipe<?> bmu) {
        if (bmu.isSpecial() || !bqb.getGameRules().getBoolean(GameRules.RULE_LIMITED_CRAFTING) || ze.getRecipeBook().contains(bmu)) {
            this.setRecipeUsed(bmu);
            return true;
        }
        return false;
    }
}
