org.spongepowered.api.item.recipe.RecipeManager Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of spongeapi Show documentation
Show all versions of spongeapi Show documentation
A plugin API for Minecraft: Java Edition
The newest version!
/*
* This file is part of SpongeAPI, licensed under the MIT License (MIT).
*
* Copyright (c) SpongePowered
* Copyright (c) contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package org.spongepowered.api.item.recipe;
import org.spongepowered.api.ResourceKey;
import org.spongepowered.api.item.inventory.ItemStackLike;
import org.spongepowered.api.item.recipe.cooking.CookingRecipe;
import org.spongepowered.api.item.recipe.crafting.RecipeInput;
import org.spongepowered.api.world.server.ServerWorld;
import java.util.Collection;
import java.util.Optional;
import java.util.function.Supplier;
/**
* Manages registered recipes.
* Register new Recipes during {@link org.spongepowered.api.event.lifecycle.RegisterDataPackValueEvent}
* using {@link RecipeRegistration}s.
* To disable a recipe override it with an empty result.
*/
public interface RecipeManager {
/**
* Gets a recipe by its {@link ResourceKey key}.
*
* @param key the recipe key
*
* @return The recipe if available
*/
Optional> byKey(ResourceKey key);
/**
* Gets all registered recipes.
*
* @return All registered recipes.
*/
Collection> all();
/**
* Returns all registered recipes of given type
* @param type The recipe type
*
* @return All recipes of given type
*/
> Collection allOfType(RecipeType type);
/**
* Returns all registered recipes of given type
* @param supplier The recipe type
*
* @return All recipes of given type
*/
default > Collection allOfType(Supplier extends RecipeType> supplier) {
return this.allOfType(supplier.get());
}
/**
* Returns all registered recipes of given type and with given item as a result.
*
* @param type The recipe type
* @param result The recipe result to match
*
* @return The recipes resulting in given item.
*/
> Collection findByResult(RecipeType type, ItemStackLike result);
/**
* Gets all recipes with given item as a result.
*
* @param result the recipe result to match
*
* @return All recipes resulting in given item.
*/
default > Collection findByResult(Supplier extends RecipeType> supplier, ItemStackLike result) {
return this.findByResult(supplier.get(), result);
}
/**
* Finds a matching recipe for given type, recipe input and world
*
* @param type The recipe type
* @param input The recipe input
* @param world The world
*
* @return The matching recipes.
*/
> Optional findMatchingRecipe(RecipeType type, I input, ServerWorld world);
/**
* Finds a matching recipe for given type, recipe input and world
*
* @param supplier The recipe type
* @param input The recipe input
* @param world The world
*
* @return The matching recipes.
*/
default > Optional findMatchingRecipe(Supplier extends RecipeType> supplier, I input, ServerWorld world) {
return this.findMatchingRecipe(supplier.get(), input, world);
}
/**
* Finds a matching cooking recipe for given type and ingredient
*
* @param type The recipe type
* @param ingredient The ingredient
*
* @return The matching recipe.
*/
Optional findCookingRecipe(RecipeType type, ItemStackLike ingredient);
/**
* Finds a matching cooking recipe for given type and ingredient
*
* @param supplier The recipe type
* @param ingredient The ingredient
*
* @return The matching recipe.
*/
default Optional findCookingRecipe(Supplier extends RecipeType> supplier, ItemStackLike ingredient) {
return this.findCookingRecipe(supplier.get(), ingredient);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy