Paper
Paper copied to clipboard
Fix exact choice recipe book clicks
Potential fix for https://github.com/PaperMC/Paper/issues/7821
This is pretty workaround-y, basically creating an int ID to represent any possible nbt combination and it probably breaks something. but it does fix that issue so.
Tried building this locally to test myself but couldn't get it to work? Atleast if its meant to have the autofill work with custom nbt items.
Recipe still only shows as "craftable" when non-nbt variant is in players inventory. Clicking it with all the NBT items in the inventory does not autofill (manually placing them makes the recipe work ofc) Unlike before though, the vanilla equivalent items are not autofilled when they are present
Clip below should show everything, triple checked the nbt of items in inv, the recipe ones and result items. All were identical.
With patch:
https://user-images.githubusercontent.com/62521371/170740226-0b7b1a6e-3890-4def-90e1-f2e7e68864b9.mp4
Without:
https://user-images.githubusercontent.com/62521371/170740937-74d68244-b20b-4be9-98de-adb5cf46d1e4.mp4
~~Items with damage values, enchantments, or custom display names do not work with auto filling. That isn't something this pr tries to fix. If you have custom nbt that isn't that, like custom lore, attributes, or something else it should work.~~
This now works with exact recipe choices, but note the caveats listed in the pr description.
Ah alright, kinda sad but seems to work atleast without displayname like intended. Would this only be when the item registered in the recipe has a displayname? So if i register the recipe with a clone of the itemstack but remove the displayname it would still work?
also when thinking about it yeah displayname and damage makes sense to not be taken into account 💀 forgot anvil renaming and enchanting was a thing apparently

So if i register the recipe with a clone of the itemstack but remove the displayname it would still work?
~~No. When the game tries to find stacks that match the recipe it just ignores itemstacks in your inventory that have a display name, enchants, or damage. It might be possible to address this in the future, but that's not what this PR does.~~
This now works, see Caveats listed in pr description.
I can confirm that this PR fixes #7821.
Previous behavior was that the correct recipe would not be sent to the player if it was marked as craftable. The material for the items in that recipe are sticks, so the recipe is seen as craftable by the client.

EDIT:
After 24 hours of testing, including running it on production, I have not seen any side effects from this PR's changes, and that the issue is fixed. I will continue posting updates.
EDIT:
After a a few days of production use, no issues stemming from this.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
I wonder if there's some better way to track items like this, via some registering system for plugins to say, "This item should be treated separately in recipes". Right now, every unique nbt tag on an itemstack will create a separate id, and that could get rather big as there's really infinite nbt combinations.
Dramatically refactored this to an, imo, much better and more extensible system for predicate choice coming later. Details of how this works in PR description.