Paper
Paper copied to clipboard
Custom crafting recipes are not working
Expected behavior
When a custom recipe is added to the server, you should be able to craft the result of the recipe
Observed/Actual behavior
Crafting the recipe does not yield a result
Steps/models to reproduce
Add a custom recipe via a plugin:
public class CustomRecipeTester
extends JavaPlugin
{
public String pluginName;
public void onDisable() {}
public void onEnable() {
ItemStack is = new ItemStack(Material.LEATHER_HELMET, 1);
ItemMeta im = is.getItemMeta();
im.setDisplayName("A Thing");
im.setCustomModelData(Integer.valueOf(1));
im.setLore(List.of("The essential thing!"));
is.setItemMeta(im);
NamespacedKey key = new NamespacedKey("customrecipetester", "athing");
ShapedRecipe r = new ShapedRecipe(key, is);
r.shape(new String[] { " ", "SWS", " " });
r.setIngredient('S', Material.COBBLESTONE);
r.setIngredient('W', Material.WARPED_BUTTON);
getServer().addRecipe((Recipe)r);
}
}
Plugin and Datapack List
Only the test plugin detailed above
Paper version
Paper version 1.21-27-master@76c2f16 (2024-06-22T18:19:36Z) (Implementing API version 1.21-R0.1-SNAPSHOT)
Other
The same plugin works as expected on a Spigot server
Don't include the full space rows. In your shaped recipes, you shouldn't have complete rows or complete columns of spaces, those can just be deleted.
This has not been the case in previous versions of Paper server - including 1.20.6 (Paper version 1.20.6-147-ver/1.20.6@e41d44f (2024-06-17T19:24:35Z) (Implementing API version 1.20.6-R0.1-SNAPSHOT))
My custom recipes from version 1.20.4 do not work in 1.21 either
Unusually, one of my recipes works and the other doesn't. One is a pickaxe and one is an axe, the axe doesn't work but the pickaxe does. It might be that the pickaxe recipe can be flipped horizontally?
Don't include the full space rows or columns. In your shaped recipes, you shouldn't have complete rows or complete columns of spaces, those can just be deleted.
Do this
I think I'm experiencing a similar issue with shapeless recipes. The recipe can be added to the server and given to the player without any errors. Clicking on it in the recipe book correctly fills the items in the crafting grid, but does not produce a result. Also, for some reason the recipe book is not listing my recipe as "Craftable" and is only visible when setting it to "Showing All" even though it's still able to fill the items
Okay, I have fixed all my shaped recipes that had either all spaced columns or rows and they are now working - albeit some recipes can be crafted in not the most aesthetically pleasing arrangements - though it probably mirrors vanilla more closely in that respect.
However, custom shapeless recipes where the result is altered in the PrepareItemCraftEvent are not working - the recipe result CraftingInventory#getResult is returning null
Update This turns out to be not related to the PrepareItemCraftEvent but the fact that the shapeless recipe uses a custom item.
All shapeless recipes work as expected on Spigot.
I have fixed my recipes by changing a custom item in the recipe. I removed the Enchant and the "HideEnchantments" Item Flag and now the recipe is working.
The fix supplied here solved the issue for me: https://github.com/PaperMC/Paper/issues/10971
I can confirm also, Shapeless recipes with custom ingredients just don't work. (Sorry, I did not see the link above to the PR that fixes this)
Presumably resolved by https://github.com/PaperMC/Paper/pull/10973, please post here if you still experience this issue. Closing this for now.