Skip to content

A simple Java API for adding custom crafting, furnace, smoker, and blast furnace recipes on Spigot servers. Easy to use with support for NBT tags and full recipe customization. Compatible with the latest Spigot versions. Download, integrate, and start creating custom recipes in minutes!

License

Notifications You must be signed in to change notification settings

CantBeKarma/RecipesAPI

 
 

Repository files navigation

RecipesAPI

Release

RecipesAPI is a lightweight and easy-to-use API that allows you to create custom recipes for your Spigot server. Whether you want to add custom shaped or shapeless crafting recipes, furnace smelting recipes, or other custom item interactions, this API makes it simple to do so.

Features

  • Create Custom Recipes: Add shaped, shapeless, and furnace, and other type recipes with ease.
  • Advanced Recipe Handling: Support for custom ingredients with meta data (e.g., items with custom names).
  • Easy Integration: Simple API to integrate into any Spigot plugin.
  • Version Compatibility: Works with recent Spigot versions and allows you to create recipes dynamically. Folia compatibility if you use FoliaLib.

Installation

  1. Prerequisites:
    • Make sure you have Java 21+ and Spigot installed on your system.
  2. Add RecipesAPI to your project via JitPack. Add the following to your build.gradle:
repositories {
    maven { url 'https://jitpack.io' }
}

dependencies {
    implementation 'com.github.Traqueur-dev:RecipesAPI:VERSION'
}
  1. Since you are using Shadow Plugin for building, make sure to relocate the API to avoid conflicts:
shadowJar {
    relocate 'fr.traqueur.recipes', 'your.plugin.package.recipes'
}
  1. Build your plugin with ./gradlew build.

Usage Example

Below is an example of how to use RecipesAPI in your Spigot plugin. This example demonstrates adding four types of recipes: a simple shapeless crafting recipe, a shaped crafting recipe, a custom ingredient shapeless recipe, and a furnace recipe. You can see how easy it is to create and register recipes with the API. The exemple plugin is available in the test-plugin directory.

public final class TestPlugin extends JavaPlugin {

    private RecipesAPI recipesAPI;

    @Override
    public void onEnable() {
        // Initialize RecipesAPI
        recipesAPI = new RecipesAPI(this, true);

        // Create a simple shapeless crafting recipe (DIRT -> 64 DIAMOND)
        ItemRecipe recipe = new RecipeBuilder()
                .setType(RecipeType.CRAFTING_SHAPELESS)
                .setName("example-simple")
                .setResult(new ItemStack(Material.DIAMOND))
                .setAmount(64)
                .addIngredient(Material.DIRT)
                .build();

        // Create a shaped crafting recipe (DIRT and DIAMOND -> 64 DIAMOND)
        ItemRecipe recipe2 = new RecipeBuilder()
                .setType(RecipeType.CRAFTING_SHAPED)
                .setName("example-shaped")
                .setResult(new ItemStack(Material.DIAMOND))
                .setAmount(64)
                .setPattern("DDD", "DID", "DDD")
                .addIngredient(Material.DIRT, 'D')
                .addIngredient(Material.DIAMOND, 'I')
                .build();

        // Create a shapeless recipe with a custom ingredient (named PAPER)
        ItemStack ingredient = new ItemStack(Material.PAPER);
        ItemMeta meta = ingredient.getItemMeta();
        meta.setDisplayName("Dirt Magic");
        ingredient.setItemMeta(meta);

        ItemRecipe recipe3 = new RecipeBuilder()
                .setType(RecipeType.CRAFTING_SHAPELESS)
                .setName("example-complex")
                .setResult(new ItemStack(Material.DIAMOND))
                .setAmount(64)
                .addIngredient(ingredient)
                .build();

        // Create a furnace smelting recipe (PAPER -> 64 DIAMOND)
        ItemRecipe recipe4 = new RecipeBuilder()
                .setType(RecipeType.SMELTING)
                .setName("example-furnace")
                .setResult(new ItemStack(Material.DIAMOND))
                .setAmount(64)
                .addIngredient(ingredient)
                .setCookingTime(10)
                .build();

        // Add the recipes to the API
        recipesAPI.addRecipe(recipe);
        recipesAPI.addRecipe(recipe2);
        recipesAPI.addRecipe(recipe3);
        recipesAPI.addRecipe(recipe4);

        // Register the recipes with the server
        recipesAPI.registerRecipes();
    }
}

How to Use

  • Shapeless Recipe: Add items to crafting in any arrangement.
  • Shaped Recipe: Define specific patterns for crafting items.
  • Custom Ingredients: Use items with custom names or metadata in recipes.
  • Furnace Recipes: Create custom smelting recipes with adjustable cooking time.

API Documentation

The API is simple and intuitive to use. You can easily:

  • Define crafting types: RecipeType.CRAFTING_SHAPELESS, RecipeType.CRAFTING_SHAPED, RecipeType.SMELTING, etc.
  • Add ingredients: Either regular materials or custom items with ItemMeta.
  • Set crafting patterns: For shaped recipes, you can define the crafting grid with .setPattern().
  • Control output: Set the resulting item and amount.

You can check javadoc here : Javadoc

License

This project is licensed under the MIT License.

About

A simple Java API for adding custom crafting, furnace, smoker, and blast furnace recipes on Spigot servers. Easy to use with support for NBT tags and full recipe customization. Compatible with the latest Spigot versions. Download, integrate, and start creating custom recipes in minutes!

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Java 100.0%