Skip to content

Allow advanced recipes to accept items with different NBT #12

Open

Description

@StrangeOne101

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

Activity

  1. cpaca commented on Feb 24, 2023

    @cpaca

    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.

  2. cpaca commented on Feb 24, 2023

    @cpaca

    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"?)

  3. StrangeOne101 commented on Feb 24, 2023

    @StrangeOne101
    OwnerAuthor

    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    ApprovedApproved suggestion

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions