Resource Recipes System compatible with all versions.

Discussion in 'Spigot Plugin Development' started by Royalix, Feb 25, 2020.

  1. Hello, I've written an recipes system for my engine and wanted to share it with you.
    It's an recipes system combining patterns for building them. It supports both 2x2 and 3x3 recipes.
    And 2x2 recipes will work in 3x3 env. It's pretty simple and would say it's clean too.

    Thanks to @Yona168 for some help with the math.

    How to use?
    So first off let's build an recipe.

    Code (Text):
            ORecipe
                    .builder()
                    .pattern("D X A", "A X A")
                    .item('D', new ItemStack(Material.DIAMOND))
                    .item('A', new ItemStack(Material.ARROW))
                    .result(new ItemStack(Material.ANVIL))
                    .build();
    Then register it with
    Code (Text):
    RecipesController.getInstance().register(recipe);
    Make sure you register recipes controller in the events system
    Code (Text):
    Bukkit.getPluginManager().registerEvents(RecipesController.getInstance(), plugin);
    Now you're all set and ready to go!

    Source code at https://gitlab.com/oskardhavel/recipes-system-mc
    Jars https://jitpack.io/#com.gitlab.oskardhavel/recipes-system-mc

    You're welcome to do pull requests to improve it <3

    One recommendation for people who plan to have a lot of recipes is to make the item check with NBT instead of meta checks, meta checks are much slower than checking comparing NBT.

    There's bugs afaik it's not well tested, so your input is welcome!
    TO-DO
    • Implement result request system for the ORecipe class, so one recipe may return multiple results depending on the player.
    • Add support for recipe item amount's to be higher than 1.
    • After item is being changed, reset the result...
     
    #1 Royalix, Feb 25, 2020
    Last edited: Feb 25, 2020
    • Useful Useful x 2
  2. Looks nice! Thanks for your work.