help making custom crafting inventory

Discussion in 'Plugin Development' started by Cat 700, Mar 14, 2020.

Thread Status:
Not open for further replies.
  1. Offline

    Cat 700

    I am trying to make a custom crafting inventory but don't know how I should check it for the recipe. I also don't know how I should save the recipe cause I was planning on making a callable function to make the recipe but I don't know how I should save all the recipes for it.
     
  2. Offline

    vildaberper

    If thease recipes are limited to 3x3 you can use the existing API, but set the resulting ItemStack to null if it is not your custom crafting inventory.
    For larger recipes you would need a recipe matcher. Performance is not a huge issue here since it all happens in your plugin. I would recommend looking into ShapedRecipe.
     
  3. Offline

    Cat 700

    it is 4x4
     
  4. Offline

    bowlerguy66

    1. You'll have to make a custom inventory of any size, and then choose the slots that you want to save as your 4x4 crafting area.
    2. I'd recommend placing filler items (like stained glass) in slots other than the crafting slots so it's obvious for the player to see where they're crafting.
    3. You can store recipes by making your own Object where several important pieces of crafting information are stored:
    - The result item
    - The shape of the recipe (maybe stored as an array of Material enums that correspond to the shape of the table)
    4. When you have your recipe object, you can iterate over your recipes each time there's an InventoryClickEvent to check whether a recipe was validated or not.
    Good luck!
     
  5. Offline

    Cat 700

    I have done all that but how do I make the recipes, save the recipes, and continuously check the recipes?
     
    Last edited: Mar 14, 2020
  6. Offline

    bowlerguy66

    If I were doing this I would replicate the code that Bukkit already has but on the 4x4 scale; to check for a completed recipe, just use the InventoryClickEvent and then loop through your existing recipes there. Also, tag or reply to people's posts so they get notifications when you reply.
     
  7. Offline

    Cat 700

    @bowlerguy66 ok will tag now and thanks but how would I make code like that because I can't use the shaped recipe with 4x4 and IDK how to make my own custom shaped recipe variable
     
    Last edited: Mar 14, 2020
  8. Offline

    bowlerguy66

    @Cat 700 In recipes with bukkit, there are three strings that are each 3 characters long to make the recipe, so for your code you would make an array of 4 Strings that are 4 characters long. Then, you would assign materials/itemstacks to each character
    Code:
        String[] recipe = new String[4];
        recipe[0] = "    ";
        recipe[1] = "    ";
        recipe[2] = "    ";
        recipe[3] = "    ";
        Map<Character, Material> materials = new HashMap<Character, Material>();
        materials.put('@', Material.OAK_LOG);
        materials.put('&', Material.STONE);
    
     
  9. Offline

    Cat 700

  10. Offline

    Machine Maker

    Basically, you have to write your own logic. There isn't a way to use Bukkit's builtin recipe system for your own custom crafting menu.
     
  11. Offline

    Cat 700

    I made everything for the recipes to work except when I put the result in it doesn't show that the result is there for the player.





    edit: code: https://pastebin.com/8SY2whkA. I have a bukkit runnable to update the inventory but it isn't working to update because the result (slot.get(16)) is not showing up but when I click it it does
     
    Last edited: Mar 22, 2020
  12. Offline

    Cat 700

    [deleted by editing because merging posting]
     
    Last edited: Mar 17, 2020
Thread Status:
Not open for further replies.

Share This Page