Refactor recipes#1098
Refactor recipes#1098kashike wants to merge 9 commits intoSpongePowered:bleedingfrom kashike:feature/recipe
Conversation
|
😃 |
|
@JBYoshi You caught me. 😆 |
|
This is a really nice idea. |
| * @return The resultant item type | ||
| */ | ||
| List<ItemType> getResultTypes(); | ||
| ItemType getResultType(); |
There was a problem hiding this comment.
As far as I can tell, recipes may only return a single ItemStack as a result, so a single ItemType makes sense - correct me if wrong.
There was a problem hiding this comment.
Recipes can have more than one output, this was established a long time ago
#242 (comment)
|
Just out of curiosity, where did the term 'aisle' come from? |
|
How would you handle data stuff? |
|
@kashike So I have to create 16 recipies to create 1 item with 16 different data states? |
|
@ST-DDT I was hyped about this till you mentioned this |
|
@ST-DDT That is what vanilla itself does, yes. |
|
Since mods can create their own class off of |
| * @return fluent interface | ||
| */ | ||
| Builder addResult(ItemStack result); | ||
| Builder result(ItemStack result); |
This is why the work I'm currently doing on Mixin is so important. Yes it will allow us to address stuff like this. |
| * @return The ingredient | ||
| */ | ||
| Optional<ItemStack> getIngredient(Vector2i pos); | ||
| Optional<ItemStack> getIngredient(char symbol); |
There was a problem hiding this comment.
I'm not sure on the usefulness of this method because it requires knowledge of how the recipe was created in the builder. I think an (x, y) coord would be better suited here.
There was a problem hiding this comment.
Hmm yeah might as well I guess
|
@Mumfrey in a mock-up implementation I did a long time ago (simon816/SpongeCommon@0184019) I was able to get around the problem by capturing the |
| * Gets the aisle. | ||
| * | ||
| * @return The aisle | ||
| */ |
There was a problem hiding this comment.
Is that a copy? The Javadocs should mention this.
|
Yeah we aren't doing wrapping. This is solvable with changes coming to Mixin where we can mix into implementors of IRecipe. |
|
What's about an option to only assign an ItemType to a char? That would fix @ST-DDT 's problem |
|
@Feeliiix Would you like something like... Builder where(char symbol, @Nullable ItemStack ingredient) throws IllegalArgumentException;
Builder where(char symbol, @Nullable ItemType ingredient) throws IllegalArgumentException;? |
|
Yes, exactly. |
|
It's very well possible that the |
|
We could accept |
|
+1 to ItemStackSnapshot. |
|
|
||
| public interface FurnaceRecipe extends Recipe { | ||
|
|
||
| float getExperience(GridInventory grid); |
There was a problem hiding this comment.
...and not something more targeted to an actual Furnace?
There was a problem hiding this comment.
And it should return a doube. Missing javadoc.
|
As a suggestion, should we have a 'CustomRecipe' or whatever, that accepts a predicate or function? Basically that would allow plugins to create recipes similar to the fancy ones like armour dying. |
| * | ||
| * @param grid An ItemGrid as input | ||
| * @param grid A grid inventory as input | ||
| * @return A list of ItemStacks or {@link Optional#empty()} if the given |
There was a problem hiding this comment.
or {@link Optional#empty()} to or an empty list
| boolean remove(CraftingRecipe recipe); | ||
|
|
||
| /** | ||
| * Gets a {@link Collection} of all recipes this registry is aware of. |
| * Sets the aisle pattern for the shaped recipe. | ||
| * | ||
| * @param aisle A string array of ingredients | ||
| * @return fluent interface |
| */ | ||
| int getHeight(); | ||
|
|
||
| interface Builder extends ResettableBuilder<ShapedCraftingRecipe, Builder> { |
| * @param result The resultant stacks | ||
| * @return fluent interface | ||
| */ | ||
| Builder results(Collection<ItemStack> result); |
| /** | ||
| * A ShapedCraftingRecipe is a Recipe that has shape and fits into a grid. | ||
| */ | ||
| public interface ShapedCraftingRecipe extends CraftingRecipe { |
There was a problem hiding this comment.
Return a guava table of item stacks?
|
@kashike Status? |
|
Can I offer my help here? I'd like to get recipes merged. |
|
I like the idea of using |
|
@Limeth I've gone ahead and added you to my forks. Feel free to make new commits, just don't modify the existing ones. 👍 |
| * @return The builder | ||
| */ | ||
| Builder addResult(ItemStack result); | ||
| Builder results(ItemStack... results); |
There was a problem hiding this comment.
This can be default implemented.
| * @param ingredients The ingredients | ||
| * @return The builder | ||
| */ | ||
| Builder ingredients(ItemStack... ingredients); |
There was a problem hiding this comment.
This can be default implemented.
| * @param result The resultant stacks | ||
| * @return The builder | ||
| */ | ||
| Builder results(ItemStack... result); |
There was a problem hiding this comment.
This can be default implemented.
|
|
||
| public interface FurnaceRecipe extends Recipe { | ||
|
|
||
| float getExperience(GridInventory grid); |
There was a problem hiding this comment.
And it should return a doube. Missing javadoc.
| * @return The builder | ||
| */ | ||
| ShapelessRecipe build(); | ||
| Builder results(Collection<ItemStack> result); |
There was a problem hiding this comment.
Why do you use a Collection here and for the ShapedRecipe an Iterable?
|
@kashike I'm getting confused as to why there are now three PR's attempting to refactor recipes. From what I can see, there's #1098 (this one), #1449 (Limeth's continuation of this one), and #1419 (Maxqia's refactor). Normally, we should only have at most two PR's, but as it stands, there's some issues with all of them (this one being not updated). I'd like to get these PR's organized and some cleanup of reviews/comments from @SpongePowered/developers. |
|
:P mine just kinda enveloped this one in response to Limeth's PR, My PR contains a lot of this PR's code... |
API | Common
Adds #1027
Resolves #1028
This PR changes
ShapedCraftingRecipe(previouslyShapedRecipe) from using an x and yint-based system to an aisle-based system, withcharbeing used to get/set ingredients.Example usage:
