IRecipe#getRemainingItems not properly being called
rubensworks opened this issue ยท 3 comments
It looks like IRecipe#getRemainingItems
is not, or is incorrectly being called on recipes in the crafting grid.
Originally reported in CyclopsMC/EverlastingAbilities#73 by @Jkosio23.
Description
Originally reported in the Everlasting Abilities issue tracker.
EA has a special recipe that allows you to recycle totem items from the mod.
Every time the recipe is completed, i.e., when IRecipe#getRemainingItems
is called, a random seed is incremented so that the next recycle result is something different.
However, it looks like when this recipe is performed using the AE2 crafting grid, that IRecipe#getRemainingItems
is never called when the recipe is completed (while it should), and as such, the seed remains the same.
I had a quick glance at the AE2 source code, and it looks like the method is being called in some places. But perhaps there is a bug somewhere that causes it not to be called, maybe this todo has something to do with it.
Environment
- Minecraft Version: 1.12.2
- AE2 Version: rv5-stable-3
- Forge Version: 14.23.1.2559
Autocrafting is highly optimized in regards to performance to avoid massive issues. But this requires the steps to be deterministc, which we ensure with some safeguards. Otherwise it would constantly break down when encountering random recipes.
Thus we won't fix it for the sake of a single mod by introducing a massive performance and/or stability issue.
I understand the reasoning behind it, but it is mentioned nowhere in IRecipe
's javadoc that getRemainingItems
requires deterministic output. Therefore, AE2 should not make any assumptions on the existence of such a contract. This is bound to break other mods as well, as non-deterministic crafting is not a thing exclusive to EA.
And nowhere in IRecipe#getRemainingItems()
is it mentioned, that is has to be called, that it cannot be called more than once per craft, that it has to be called after IRecipe#getCraftingResult()
or before and never the other way, that each IRecipe
instance can only be used once and fetching a new instance via CraftingManager.findMatchingRecipe
for each successive crafting operation is necessary, and so on. So mods shouldn't make any assumption about this, too.
I know it sucks, but the crafting in forge is simply not suited for anything but manually crafting a single, noncontinuous recipe. Everything else has to either compromise and make some assumptions to ensure it does not constantly break or turn it into a DOS attack should it just craft slightly faster than a player can do. (Not speaking about a machine, which crafts exactly one or a handful of recipes, these are trivial)