Closed ZephireNZ closed 8 years ago
People coming from bukkit will be really happy about this change :O
<bendem> [...] shouldn't the result be influenced by the matrix in here https://github.com/GlowstoneMC/Glowkit/pull/34/files#diff-00a92dfb9708d83e3d47cf603d43b186R23
<@SpaceManiac> see the doc on the other method
<bendem> well, that would mean you can't add dynamic recipe from plugins, or you should find a way to make sure plugin dev actually set the matrix to use it in getResult
<bendem> aka, wouldn't it be better to have a class there instead of an interface?
<bendem> like make a class like the other which would be constructed like new DynamicRecipe(result).setMatcher(matcher) with an ItemStackMatcher interface
<bendem> that would match the current behavior of other recipes
<bendem> I should write that on the pr
@bendem: Before I go any further, care to elaborate?
There are 3 things bothering me in this interface.
I thought of something like this could maybe be a way of doing it.
EDIT: We came up with this(edit: gist died) on irc, which prevents parsing the matrix once when matching and once when getting the result.
Changed state to WIP because the Glowstone side is still not complete
Fair enough. Once I get my computer going, I think I'm going to remove the clear part for now anyway. Once the recipes are pulled, I'll work on getting all crafting recipes to clear the matrix properly.
@ZephireNZ After seeing the implementation, I think it would make sense to let the recipe clean the matrix. Maybe something like new DynamicRecipe(itemMatcher, itemCleaner)
where ItemCleaner is an interface like
interface ItemCleaner {
public ItemStack[] clean(ItemStack[]);
}
or just adding a new ItemStack[] clean(ItemStack[])
method to ItemMatcher.
(I'd personally go with the first option because it would allow users to not implement the method for the default behavior and because java 8 lambdas)
Like I said, I'll get these changes pulled first, then I'll work on getting the matrix to be cleaned. Currently all other recipes are also not cleaned, so I could will probably get both working in one go.
This PR provides the ability for Glowstone as well as modders to create dynamic recipes. These need to access NBT or damage values, and have massive numbers of combinations - making static recipes unhelpful.
The API is purposefully quite bare compared to Shaped and Shapless recipes, so that the implementation is easy.
Edited by turt2live
Related links: