Paper icon indicating copy to clipboard operation
Paper copied to clipboard

Custom crafting recipes are not working

Open eccentricdevotion opened this issue 1 year ago • 10 comments

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

custom-crafting-paper-vs-spigot

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

eccentricdevotion avatar Jun 23 '24 02:06 eccentricdevotion

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.

Machine-Maker avatar Jun 23 '24 06:06 Machine-Maker

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))

eccentricdevotion avatar Jun 23 '24 06:06 eccentricdevotion

My custom recipes from version 1.20.4 do not work in 1.21 either

NikeyV1 avatar Jun 23 '24 17:06 NikeyV1

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?

vlink102 avatar Jun 23 '24 21:06 vlink102

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

Machine-Maker avatar Jun 23 '24 21:06 Machine-Maker

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 image

Frogperson avatar Jun 24 '24 00:06 Frogperson

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.

eccentricdevotion avatar Jun 24 '24 04:06 eccentricdevotion

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.

NikeyV1 avatar Jun 24 '24 09:06 NikeyV1

The fix supplied here solved the issue for me: https://github.com/PaperMC/Paper/issues/10971

eccentricdevotion avatar Jun 25 '24 01:06 eccentricdevotion

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)

ShaneBeee avatar Jul 16 '24 20:07 ShaneBeee

Presumably resolved by https://github.com/PaperMC/Paper/pull/10973, please post here if you still experience this issue. Closing this for now.

lynxplay avatar Jul 30 '24 20:07 lynxplay