Skip to content

Commit

Permalink
Fixes #4508: Correctly construct the sparse lists.
Browse files Browse the repository at this point in the history
  • Loading branch information
yueh committed Jul 26, 2020
1 parent 59e40cc commit f18c654
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 22 deletions.
Expand Up @@ -18,9 +18,6 @@

package appeng.container.implementations;

import java.util.ArrayList;
import java.util.List;

import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.entity.player.ServerPlayerEntity;
Expand Down Expand Up @@ -264,21 +261,13 @@ private ItemStack[] getOutputs() {
return new ItemStack[] { out };
}
} else {
final List<ItemStack> list = new ArrayList<>(3);
boolean hasValue = false;

for (final OptionalFakeSlot outputSlot : this.outputSlots) {
final ItemStack out = outputSlot.getStack();

if (!out.isEmpty() && out.getCount() > 0) {
list.add(out);
hasValue = true;
}
}
final ItemStack[] list = new ItemStack[3];

if (hasValue) {
return list.toArray(new ItemStack[list.size()]);
for (int i = 0; i < this.outputSlots.length; i++) {
final ItemStack out = this.outputSlots[i].getStack();
list[i] = out;
}
return list;
}

return null;
Expand Down
7 changes: 2 additions & 5 deletions src/main/java/appeng/helpers/CraftingPatternDetails.java
Expand Up @@ -109,13 +109,10 @@ public CraftingPatternDetails(final IAEItemStack is, final World w) {
this.standardRecipe = null;
this.correctOutput = ItemStack.EMPTY;

for (int x = 0; x < products.size(); x++) {
for (int x = 0; x < 3; x++) {
final IAEItemStack ais = products.get(x);
final ItemStack gs = ais.createItemStack();

if (!gs.isEmpty()) {
out.add(ais.copy());
}
out.add(ais != null ? ais.copy() : null);
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/appeng/items/misc/EncodedPatternItem.java
Expand Up @@ -208,7 +208,7 @@ public ItemStack getOutput(final ItemStack item) {

final ICraftingPatternDetails details = Api.instance().crafting().decodePattern(item, w);

out = details != null ? details.getOutputs()[0].createItemStack() : ItemStack.EMPTY;
out = details != null ? details.getCondensedOutputs()[0].createItemStack() : ItemStack.EMPTY;

SIMPLE_CACHE.put(item, out);
return out;
Expand Down

0 comments on commit f18c654

Please sign in to comment.