Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow advanced recipes to accept items with different NBT #12

Open
StrangeOne101 opened this issue Nov 30, 2021 · 3 comments
Open

Allow advanced recipes to accept items with different NBT #12

StrangeOne101 opened this issue Nov 30, 2021 · 3 comments
Labels
Approved Approved suggestion

Comments

@StrangeOne101
Copy link
Owner

Such as the advanced recipe for revive kits. The soul item in the recipe will always have different NBT.

A system to register "dummy" recipes has already been implemented. This will match most of the ingredients to the advanced recipe so only the capture group needs to be tested

@StrangeOne101 StrangeOne101 added the Approved Approved suggestion label Nov 30, 2021
@cpaca
Copy link

cpaca commented Feb 24, 2023

If you're reading this and thinking "Oh, I'll just override RecipeChoice myself" - won't work. My source is I've tried. If you try to use any RecipeChoice besides the two provided to you, it'll throw an error.

https://hub.spigotmc.org/stash/projects/SPIGOT/repos/craftbukkit/browse/src/main/java/org/bukkit/craftbukkit/inventory/CraftRecipe.java

Yes, that code is CraftBukkit, not PaperMC, but I got the exact same error ("Unknown recipe stack instance" + ...) when I tried to do it too.

@cpaca
Copy link

cpaca commented Feb 24, 2023

That's not to say it isn't possible, it just means you'll have to find another method.

I've written my suggestion for how to do it below but if I do bother to write it, it won't be right now. (AKA, I'm leaving notes for either myself or someone else to do it.)

ShapedRecipe using MaterialChoice, provide a recipe list with the right holoitems on wiki or discord or whatever.

EventListener for CraftItemEvent, check if it's a HoloItem recipe, if it is try to grab the relevant recipe - either using a Recipe Registry or Bukkit.getServer().getRecipe() - and if the places where holoitems are supposed to be don't have holoitems, cancel the event and tell the player something (idk, "check discord" or "check the wiki" or "you need [holoitem name] for this recipe"?)

@StrangeOne101
Copy link
Owner Author

If you're reading this and thinking "Oh, I'll just override RecipeChoice myself" - won't work. My source is I've tried. If you try to use any RecipeChoice besides the two provided to you, it'll throw an error.

https://hub.spigotmc.org/stash/projects/SPIGOT/repos/craftbukkit/browse/src/main/java/org/bukkit/craftbukkit/inventory/CraftRecipe.java

Yes, that code is CraftBukkit, not PaperMC, but I got the exact same error ("Unknown recipe stack instance" + ...) when I tried to do it too.

This extends ExactChoice, so it won't throw an error. Although it's pretty hacky, and not guaranteed to always work, it seemed to work from my testing

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Approved Approved suggestion
Projects
None yet
Development

No branches or pull requests

2 participants