[SPIGOT-3526] PrepareItemCraftEvent#getInventory().setResult(ItemStack) weird Results Created: 19/Aug/17  Updated: 20/Feb/20

Status: Open
Project: Spigot
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Minor
Reporter: Anda Block Assignee: Unassigned
Resolution: Unresolved Votes: 1
Labels: bug

Issue Links:
Duplicate
is duplicated by SPIGOT-5589 Shift-clicking a custom item set in P... Resolved

 Description   

I tried to create Custom Recipes with specific ItemMeta, so Bukkit.addRecipe() wouldn't work. Because of that i decided to check on the PrepareItemCraftEvent if the wanted shape of ItemStacks is placed in the CraftingMatrix and used getInventory().setResult() to set the Custom Result. As long as all ItemStacks in the Matrix have an amount of 1, everything works fine. As soon as one ItemStack has an higher amount than 1, it becomes weird. The amount of all Items with an higher amount than 1 will get reduced by 1 and after that get doubled. So for an example an amount of 5 would result into 8 ((5-1)*2).

 

I'm not sure if this is a real bug, because i'm not sure if this is the intended way to do something like this.

 

Some Code to reproduce:

https://pastebin.com/x1cN7Qqe



 Comments   
Comment by md_5 [ 02/Jan/19 ]

<~md_5> ah I think I know why the event is wonky
<~md_5> its because no one using it clears the items when the user "crafts"
<~md_5> so everything gets doubled

Basically you should use CraftItemEvent to clear the inventory when someone successfully crafts.

However with the new RecipeChoice API you can now set NBT matches on ingredients for furnace and shaped recipes.

Comment by Anda Block [ 25/Aug/17 ]

Sorry for awnsering so late. I solved the problem by registering a recipe with the materials i need for my custom recipe and AIR as result. Now I check on the PrepareEvent if all the Items have the extra properties, if that is the case, i change the result. Thank you for taking your time.

Comment by md_5 [ 20/Aug/17 ]

You need to set the result of CraftItemEvent also.
The prepare event only governs the display of the item.

Generated at Sat Dec 13 15:24:10 UTC 2025 using Jira 10.3.13#10030013-sha1:56dd970ae30ebfeda3a697d25be1f6388b68a422.