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.
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 aPredicate<ItemStack(NMS)>
used internally in brewing recipes to a Bukkit recipe choice.Changes
ItemScriptHelper
's handling of brewing & blocking Denizen items in material choices:ItemHelper#getCustomBrewingRecipes
now properly returns a predicate recipe choice instead ofnull
(updated related usages).PaperAPITools#isDenizenMix
as it is no longer used.PaperAPIToolsImpl
no longer stores thePotionMix
in thepotionMixes
map, as it was only ever used byPaperAPITools#isDenizenMix
.