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

Fix brewing material choice block handling #2592

Merged
merged 4 commits into from Jan 30, 2024

Conversation

tal5
Copy link
Member

@tal5 tal5 commented Jan 29, 2024

Reported on Discord.

Additions

  • PaperAPITools#createPredicateRecipeChoice - ...creates a predicate recipe choice.
  • ItemScriptHelper#shouldBlockChoice - util method used in the new brewing handling.
  • ItemHelperImpl(1.20)#convertChoice - util method to convert a Predicate<ItemStack(NMS)> used internally in brewing recipes to a Bukkit recipe choice.

Changes

  • Fixed/Updated ItemScriptHelper's handling of brewing & blocking Denizen items in material choices:
    • It now properly supports custom brewing recipes & checks them for material choices.
    • It now more closely matchers vanilla behavior, where it avoids brewing items that don't match the recipe (e.g. Denizen items in a material choice), while still letting other items, if any, brew as usual - this is done by changing the event's result items instead of cancelling it.
  • ItemHelper#getCustomBrewingRecipes now properly returns a predicate recipe choice instead of null (updated related usages).
  • Removed PaperAPITools#isDenizenMix as it is no longer used.
  • PaperAPIToolsImpl no longer stores the PotionMix in the potionMixes map, as it was only ever used by PaperAPITools#isDenizenMix.

Note

The NMS method used by ItemHelper#isValidMix checks both vanilla and custom recipes, which is why the new handling checks for a custom recipe first and then if it can't find one & that's true it knows it's a vanilla recipe.
This works, but can result in custom recipes technically being checked twice - an alternative is to set the internal custom brewing recipes map to an empty map, call that method, and then set the original map back in, which might be more efficient, but would also mean more messy reflection.

@mcmonkey4eva mcmonkey4eva merged commit d35dfdc into DenizenScript:dev Jan 30, 2024
1 check passed
@tal5 tal5 deleted the Fix_Potion_Brew_Handling branch January 31, 2024 09:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants