[SPIGOT-8014] Add method for getting and setting remaining items in CrafterCraftEvent Created: 28/Feb/25 Updated: 09/Mar/25 Resolved: 09/Mar/25 |
|
Status: | Resolved |
Project: | Spigot |
Component/s: | None |
Affects Version/s: | None |
Fix Version/s: | None |
Type: | New Feature | Priority: | Minor |
Reporter: | Andre_601 | Assignee: | Unassigned |
Resolution: | Fixed | Votes: | 0 |
Labels: | None |
Version: | CraftBukkit version 4440-Spigot-e5a64e7-43f66f6 (MC: 1.21.4) (Implementing API version 1.21.4-R0.1-SNAPSHOT) |
Guidelines Read: | Yes |
Description |
The Crafter has the ability to "spit out" remaining items from a crafting recipe alongside the actually crafted item. With that said is there currently no easy way to obtain possible ItemStacks of remaining ingredient items, or set them within the CrafterCraftEvent. The only current aproach, if even doable at all by plugin devs, is to get the Crafter Block from the event, iterate through each crafting slot and check whether ItemStack#getType().getCraftingRemainingItem() returns a non-null ItemStack, which is simply tedious. If technically doable should the CrafterCraftEvent receive additional methods for optaining ItemStack instances - probably as a Collection<ItemStack>? - of remaining Item ingredients and also a setter method to set those for the Crafter to spit out. |
Comments |
Comment by md_5 [ 09/Mar/25 ] |
I've added a list method. It is mutable to allow setting |
Comment by Andre_601 [ 01/Mar/25 ] |
Wouldn't it be a reasonable aproach to have a ItemCraftResult returned instead of an ItemStack? I don't know the exact internals here and if that is doable, but if it was would I say it's better than having just the ItemStack, for the fact alone you can get the oveflowing items too. |
Comment by md_5 [ 01/Mar/25 ] |
For getting, there is a method which would work: https://hub.spigotmc.org/javadocs/spigot/org/bukkit/Server.html#craftItemResult(org.bukkit.inventory.ItemStack[],org.bukkit.World) |