RecipesAPI | Anvil, Grindstone, Brewing stand icon

RecipesAPI | Anvil, Grindstone, Brewing stand -----

Api for easy recipe creation for plugin maikers



RecipesAPI
I present to you a very simple api to create custome recipes without need to listen any prepare events and write multiply methods.
upload_2025-4-21_9-31-37.png

Futures:
  • Anvil recipes
  • Grindstone recipes
  • Brewing recipes
  • Custome brewing fuel
  • Remove Vanilla recipes
How to use:
Instalation:
Add to your pom.xml:
Code (Text):
<dependency>
    <groupId>pl.muldek</groupId>
    <artifactId>RecipesAPI</artifactId>
    <version>1.0-SNAPSHOT</version>
</dependency>
Or download jar file and add to your project as module.

Anvil recipe:
The easiest way to make custome anvil recipe is:
Code (Text):
// First item represent item in the top left slot
// Second is the list of items what player can place to middle slot
// Last one is the result of that recipe what appears in top right slot
AnvilRecipe r = new AnvilRecipe(new ItemStack(Material.DIAMOND_SWORD), Arrays.asList(new ItemStack(Material.NETHERITE_INGOT)), new ItemStack(Material.NETHERITE_SWORD));
// Always remember to register your recipe like that
RecipesManager.addAnvilRecipe(r);
More advanced version is:
Code (Text):
ItemStack item = new ItemStack(Material.DIAMOND_SWORD);
List<ItemStack> ingredients = Arrays.asList(new ItemStack(Material.DIAMOND), new ItemStack(Material.EMERALD));
// First item represent item in the top left slot
// Second argument is boolean to set if recipe need exact item or only the same material type
// Third is the list of items what player can place to middle slot
// Fourth is the same as third but for ingredients
// Next one is the result of that recipe what appears in top right slot
// And last one represents level cost of that recipe
AnvilRecipe r = new AnvilRecipe(item,false, ingredients,false, item,10);
r.setFunction(event -> {
    // In here you can make all magic stuff with your recipe
    // For example I make a recipe to adding sharpness level for diamond sword, but only diamond can by apply more than once
    ItemStack item0 = event.getInventory().getItem(0);
    ItemStack item1 = event.getInventory().getItem(1);
    ItemStack result = item0.clone();
    if (!item0.getItemMeta().hasEnchant(Enchantment.SHARPNESS)) {
        result.addEnchantment(Enchantment.SHARPNESS,1);
    } else {
        if (item1.getType() == Material.DIAMOND)
            result.addEnchantment(Enchantment.SHARPNESS,result.getEnchantmentLevel(Enchantment.SHARPNESS) + 1);
        else
            result = new ItemStack(Material.AIR);
    }
    // For finish function you need to return item what you want as result
    return result;
});
// Always remember to register your recipe like that
RecipesManager.addAnvilRecipe(r);

Grindstone recipe:
The easiest way to make custome anvil recipe is:
Code (Text):
// First item represents the first item of recipe can be placed in both slots
// Second is the list of items what player can place to another slot
// Last one is the result of that recipe what appears in top right slot
GrindstoneRecipe r = new GrindstoneRecipe(new ItemStack(Material.DIAMOND_SWORD), Arrays.asList(new ItemStack(Material.NETHERITE_INGOT)), new ItemStack(Material.NETHERITE_SWORD));
// Always remember to register your recipe like that
RecipesManager.addGrindstoneRecipe(r);
More advanced version is:
Code (Text):
ItemStack item = new ItemStack(Material.DIAMOND_SWORD);
List<ItemStack> ingredients = Arrays.asList(new ItemStack(Material.DIAMOND), new ItemStack(Material.EMERALD));
// First item represents the first item of recipe can be placed in both slots
// Second argument is boolean to set if recipe need exact item or only the same material type
// Third is the list of items what player can place to another slot
// Fourth is the same as third but for ingredients
// Last one is the result of that recipe what appears in top right slot
GrindstoneRecipe r = new GrindstoneRecipe(item,false, ingredients,false, item);
r.setFunction(event -> {
    // In here you can make all magic stuff with your recipe
    // For example I make a recipe to adding sharpness level for diamond sword, but only diamond can by apply more than once
    ItemStack item0 = event.getInventory().getItem(0);
    ItemStack item1 = event.getInventory().getItem(1);
    ItemStack result = item0.clone();
    if (!item0.getItemMeta().hasEnchant(Enchantment.SHARPNESS)) {
        result.addEnchantment(Enchantment.SHARPNESS,1);
    } else {
        if (item1.getType() == Material.DIAMOND)
            result.addEnchantment(Enchantment.SHARPNESS,result.getEnchantmentLevel(Enchantment.SHARPNESS) + 1);
        else
            result = new ItemStack(Material.AIR);
    }
    // For finish function you need to return item what you want as result
    return result;
});
// Always remember to register your recipe like that
RecipesManager.addGrindstoneRecipe(r);

Brewing recipe:
Brewing recipes you can make with normal fuel or special fuel defianed for that recipe and consumed after brewing.
That recipe use normal fuel and consume default amount.
The easiest way to make custome anvil recipe is:
Code (Text):
// First argument is ingredient item placed in top slot
// Second argument is list of items what can be placed in three bottom slots and in the end of brewing will be changed
List<ItemStack> items = Arrays.asList(new ItemStack(Material.LEATHER_HELMET),
        new ItemStack(Material.LEATHER_CHESTPLATE),
        new ItemStack(Material.LEATHER_LEGGINGS),
        new ItemStack(Material.LEATHER_BOOTS));
BrewingRecipe recipe = new BrewingRecipe(new ItemStack(Material.BLACK_DYE), items);
recipe.setFunction( pair -> {
    // In here you can make all magic stuff with your recipe
    // pair is the object what stores item what are changed with that recipe and brewery inventory if you want to check or change another stuff
    // For example I make a recipe to dye leather armor with black dye
    ItemStack item = pair.item();
    if (item.getItemMeta() instanceof LeatherArmorMeta meta) {
        meta.setColor(Color.BLACK);
        item.setItemMeta(meta);
    }
    return item;
});
RecipesManager.addBrewingRecipe(recipe);
More advanced version is:
Code (Text):
ItemStack ingredient = new ItemStack(Material.BLACK_DYE);[/LEFT]
List<ItemStack> items = Arrays.asList(new ItemStack(Material.LEATHER_HELMET),
        new ItemStack(Material.LEATHER_CHESTPLATE),
        new ItemStack(Material.LEATHER_LEGGINGS),
        new ItemStack(Material.LEATHER_BOOTS));
// First argument is ingredient item placed in top slot
// Second argument is a boolean to set if recipe need exact ingredient or only the same material type
// Third argument is list of items what can be placed in three bottom slots and in the end of brewing will be changed
// Fourth is the same as third but for items
// Fifth one is fuel consumption, default value is 1
// And last is the brewing time, default value is 400
BrewingRecipe recipe = new BrewingRecipe(ingredient,false, items,false,1,400);
recipe.setFunction( pair -> {
    // In here you can make all magic stuff with your recipe
    // pair is the object what stores item what are changed with that recipe and brewery inventory if you want to check or change another stuff
    // For example I make a recipe to dye leather armor with black dye
    ItemStack item = pair.item();
    if (item.getItemMeta() instanceof LeatherArmorMeta meta) {
        meta.setColor(Color.BLACK);
        item.setItemMeta(meta);
    }
    return item;
});
RecipesManager.addBrewingRecipe(recipe);
In that recipe you can set fuel item needs to this recipe and consumed after brewing.
More advanced version is:
Code (Text):
ItemStack ingredient = new ItemStack(Material.BLACK_DYE);
List<ItemStack> items = Arrays.asList(new ItemStack(Material.LEATHER_HELMET),
        new ItemStack(Material.LEATHER_CHESTPLATE),
        new ItemStack(Material.LEATHER_LEGGINGS),
        new ItemStack(Material.LEATHER_BOOTS));
ItemStack fuel = new ItemStack(Material.COAL);
// First argument is ingredient item placed in top slot
// Second argument is a boolean to set if recipe need exact ingredient or only the same material type
// Third argument is list of items what can be placed in three bottom slots and in the end of brewing will be changed
// Fourth is the same as third but for items
// Fifth one represents custom fuel for that recipe
// Sixth argument is e boolean to set if fuel must be the same item or only the same material type
// And last is the brewing time, default value is 400
BrewingRecipe recipe = new BrewingRecipe(ingredient,false, items,false, fuel,false,400);
recipe.setFunction( pair -> {
    // In here you can make all magic stuff with your recipe
    // pair is the object what stores item what are changed with that recipe and brewery inventory if you want to check or change another stuff
    // For example I make a recipe to dye leather armor with black dye
    ItemStack item = pair.item();
    if (item.getItemMeta() instanceof LeatherArmorMeta meta) {
        meta.setColor(Color.BLACK);
        item.setItemMeta(meta);
    }
    return item;
});
RecipesManager.addBrewingRecipe(recipe);

Custom brewing fuel:
Allways you can add some custome brewing fuels what works exacly like normal blaze powder but can change his load.
There are only that simple method to add new fuel item:
Code (Text):
// First is the fuel item
// Second is boolean to set if you want to use exact fuel item or only the same material type
// Last argument represents how many fuel loads when fuel are consumed, full loaded brewing stand is 20
RecipesManager.addBrewingFuel(new ItemStack(Material.COAL),false,10);

Remove crafting recipe:
To remove crafting recipe for some item use that:
Code (Text):
// To remove all recipes with some material as result use
RecipesManager.removeCraftingRecipe(Material.LEATHER_BOOTS);
// To remove all recipes with certain item stack with lore or enchantments use that
RecipesManager.removeCraftingRecipe(yourItemStack);

To do:
If you hawe any sugestion plese comment.
Resource Information
Author:
----------
Total Downloads: 26
First Release: Apr 20, 2025
Last Update: Apr 21, 2025
Category: ---------------
All-Time Rating:
0 ratings
Version -----
Released: --------------------
Downloads: ------
Version Rating:
----------------------
-- ratings