X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=src%2Fcraftdef.h;h=7c14e702a1fb2ff2176fc814f4803a6d499b03b5;hb=c7bcebb62856ae5fdb23a13e6fa1052eae700ddf;hp=37ae6df4353b24466961433835faa69556f5f7ba;hpb=fe6c666da26e08b726bd21f34d25558cf456bd1f;p=minetest.git diff --git a/src/craftdef.h b/src/craftdef.h index 37ae6df43..7c14e702a 100644 --- a/src/craftdef.h +++ b/src/craftdef.h @@ -80,6 +80,9 @@ struct CraftInput method(method_), width(width_), items(items_) {} + // Returns true if all items are empty. + bool empty() const; + std::string dump() const; }; @@ -110,9 +113,6 @@ struct CraftOutput Example: If ("bucket:bucket_water", "bucket:bucket_empty") is a replacement pair, the crafting input slot that contained a water bucket will contain an empty bucket after crafting. - - Note: replacements only work correctly when stack_max of the item - to be replaced is 1. It is up to the mod writer to ensure this. */ struct CraftReplacements { @@ -407,10 +407,22 @@ class ICraftDefManager ICraftDefManager() = default; virtual ~ICraftDefManager() = default; - // The main crafting function + /** + * The main crafting function. + * + * @param input The input grid. + * @param output CraftOutput where the result is placed. + * @param output_replacements A vector of ItemStacks where replacements are + * placed if they cannot be placed in the input. Replacements can be placed + * in the input if the stack of the replaced item has a count of 1. + * @param decrementInput If true, consume or replace input items. + * @param gamedef + * @return true if a result was found, otherwise false. + */ virtual bool getCraftResult(CraftInput &input, CraftOutput &output, std::vector &output_replacements, bool decrementInput, IGameDef *gamedef) const=0; + virtual std::vector getCraftRecipes(CraftOutput &output, IGameDef *gamedef, unsigned limit=0) const=0; @@ -431,9 +443,8 @@ class IWritableCraftDefManager : public ICraftDefManager virtual std::vector getCraftRecipes(CraftOutput &output, IGameDef *gamedef, unsigned limit=0) const=0; - virtual bool clearCraftRecipesByOutput(const CraftOutput &output, IGameDef *gamedef) = 0; - virtual bool clearCraftRecipesByInput(CraftMethod craft_method, - unsigned int craft_grid_width, const std::vector &recipe, IGameDef *gamedef) = 0; + virtual bool clearCraftsByOutput(const CraftOutput &output, IGameDef *gamedef) = 0; + virtual bool clearCraftsByInput(const CraftInput &input, IGameDef *gamedef) = 0; // Print crafting recipes for debugging virtual std::string dump() const=0;