Fixes #4508: Correctly construct the sparse lists. (#4511)

* Fixes #4508: Correctly construct the sparse lists.

Also renamed all uncondensed getters to sparse and all condensed to the simple ones.

* Apply suggestions from code review

Co-authored-by: shartte <shartte@users.noreply.github.com>

* Streamlined collapsing the sparse lists

* Extracted helper to condense stacks

* Sort lists desc by stack size

Co-authored-by: shartte <shartte@users.noreply.github.com>
This commit is contained in:
yueh
2020-07-27 11:21:06 +02:00
committed by GitHub
parent 6cb6c21495
commit 662dbca3e1
8 changed files with 152 additions and 136 deletions
@@ -19,6 +19,7 @@
package appeng.items.misc;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.WeakHashMap;
@@ -155,8 +156,8 @@ public class EncodedPatternItem extends AEBaseItem {
final boolean isCrafting = details.isCraftable();
final boolean substitute = details.canSubstitute();
final IAEItemStack[] in = details.getCondensedInputs();
final IAEItemStack[] out = details.getCondensedOutputs();
final Collection<IAEItemStack> in = details.getInputs();
final Collection<IAEItemStack> out = details.getOutputs();
final ITextComponent label = (isCrafting ? GuiText.Crafts.textComponent() : GuiText.Creates.textComponent())
.appendText(": ");
@@ -208,7 +209,7 @@ public class EncodedPatternItem extends AEBaseItem {
final ICraftingPatternDetails details = Api.instance().crafting().decodePattern(item, w);
out = details != null ? details.getOutputs()[0].createItemStack() : ItemStack.EMPTY;
out = details != null ? details.getOutputs().get(0).createItemStack() : ItemStack.EMPTY;
SIMPLE_CACHE.put(item, out);
return out;