[SPIGOT-6272] Allow for custom RecipeChoice predicates Created: 09/Dec/20  Updated: 13/Jan/21

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

Type: New Feature Priority: Minor
Reporter: Aria Sangarin Assignee: Unassigned
Resolution: Unresolved Votes: 0
Labels: None

Version: CraftBukkit version git-Spigot-a19903d-5b74714 (MC: 1.16.4) (Implementing API version 1.16.4-R0.1-SNAPSHOT)
Guidelines Read: Yes

 Description   

Would be awesome if plugins could implement their own versions of RecipeChoice.
I understand that this is "illegal" from reading the JavaDoc, but was wondering why and if there was a different approach. Currently trying to add a recipe where an item needs a special NBTTag in crafting and used ExactChoice for this, but this sadly makes the item invalid if enchanted or renamed.

I've tried to do this with events, but this created buggy behavior when shift-crafting and was also quite a pain to setup when thinking about compatibility and more.
So yeah, to sum up, would be awesome if I could write my own predicate for ingredients in recipes so that I could check for a specific NBT value instead of an exact copy of an itemstack.



 Comments   
Comment by Aria Sangarin [ 13/Jan/21 ]

Okay I've tested this and it seems it's not possible to do anything right now. Is there any chance to get a dangerous API that could potentially allow me to base recipe validation entirely on NBT tags? The current code we have right now (using events) is causing a lot of weird client-side issues and sometimes even server-side duplication, etc. Using the already existing bukkit recipe api is also not optimal as any item that has been slightly modified (renamed, enchanted, etc.) will not fit the ExactChoice requirements.

I hope something can be worked out!

Comment by Aria Sangarin [ 10/Dec/20 ]

Ahh yeah, so recipes don't have references to an unloaded plugins classes, right?

Is there any chance that this could be implemented and marked as Deprecated with a note on why it's dangerous to use?

 

Edit*: Or is it the case that it's already possible and RecipeChoice is "illegal" because of this?

Comment by md_5 [ 10/Dec/20 ]

The main barrier is that the recipe would have to be deleted on plugin unload to prevent leaks

Generated at Sat Apr 05 09:53:48 UTC 2025 using Jira 10.3.3#10030003-sha1:d220e3fefc8dfc6d47f522d3b9a20c1455e12b7b.