1.16.5 How to make there be multiple items per slot in crafting recipe

Discussion in 'Spigot Plugin Development' started by Duke12345, Jun 23, 2021.

  1. I am new to plugin development and would like to make a crafting recipe take more than one item per slot.

    Here is the code I have so far:

    Code (Java):
            ShapedRecipe sr = new ShapedRecipe(NamespacedKey.minecraft("hermes_boots"), item);
            sr.shape("  ", " R ", "FDF");
           
            sr.setIngredient('R', Material.RED_DYE);
            sr.setIngredient('F', Material.FEATHER);
            sr.setIngredient('D', Material.DIAMOND);
           
    // Want to make there have to be 8 diamonds instead of one      

            Bukkit.getServer().addRecipe(sr);
     
    I would like to make there have to be eight diamonds instead of one.

    Thanks in advance for any help!
     
  2. Is this possible to do?
     
  3. Only way, I think it could be done is creating custom crafting table GUI.
     
  4. I did this in an old plugin of mine called 'CustomRecipes' (now abanondened, but still available for download) but to do this I used lots of nms trickery. You'd need to create your own class that implements IRecipe, and override the method that decides what to leave behind in the crafting grid. The source code is on github (https://github.com/Jannyboy11/CustomRecipes/), you can look for the class 'CountRecipe'.
     
  5. I was able to achieve this by using PrepareItemCraftEvent.

    Check if the recipe is your custom recipe, then change the item output in the inventory.