RecipesAPI
I present to you a very simple api to create custome recipes without need to listen any prepare events and write multiply methods.
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>
<groupId>pl.muldek</groupId>
<artifactId>RecipesAPI</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
Anvil recipe:
Spoiler: Anvil recipe - simple
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);
// 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);
Spoiler: Anvil recipe - advanced
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);
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:
Spoiler: Grindstone recipe - simple
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);
// 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);
Spoiler: Grindstone recipe - advanced
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);
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.
Spoiler: Brewing recipe - simple
That recipe use normal fuel and consume default amount.
The easiest way to make custome anvil recipe is:
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);
// 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);
Spoiler: Brewing recipe - advanced with normal fuel
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);
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);
Spoiler: Brewing recipe - advanced with custom fuel item
In that recipe you can set fuel item needs to this recipe and consumed after brewing.
More advanced version is:
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);
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.
Spoiler: Brewing fuel
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);
// 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:
Spoiler: Brewing fuel
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);
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.Quick facts
- Edition: Minecraft Java
- File type: .jar
- Minecraft version listed: 1.21
- How to install: Install the matching mod loader (Forge, Fabric or NeoForge) for your Minecraft version. → Download the .jar. → Put it in the .minecraft/mods folder and launch that loader profile.
- Where to get it: Opens on Spigot — not every file is mirrored on our own servers.
Install steps are the general flow for this file type — How to install Minecraft Java mods & modpacks walks through it step by step.
RecipesAPI | Anvil, Grindstone, Brewing stand is a free Minecraft Java mod. Compatible with Minecraft 1.21. Downloaded 49 times (via Spigot). Download it and open it directly in the game.