Merge remote-tracking branch 'origin/master' into fabric/master
# Conflicts: # .github/workflows/release.yml
This commit is contained in:
@@ -267,13 +267,19 @@ public class PatternTermContainer extends MEMonitorableContainer
|
||||
return new ItemStack[] { out };
|
||||
}
|
||||
} else {
|
||||
boolean hasValue = false;
|
||||
final ItemStack[] list = new ItemStack[3];
|
||||
|
||||
for (int i = 0; i < this.outputSlots.length; i++) {
|
||||
final ItemStack out = this.outputSlots[i].getStack();
|
||||
list[i] = out;
|
||||
if (!out.isEmpty()) {
|
||||
hasValue = true;
|
||||
}
|
||||
}
|
||||
if (hasValue) {
|
||||
return list;
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
@@ -115,7 +115,12 @@ public class ApiCrafting implements ICraftingHelper {
|
||||
// We use the shared itemstack for an identity lookup.
|
||||
IAEItemStack ais = Api.instance().storage().getStorageChannel(IItemStorageChannel.class).createStack(is);
|
||||
|
||||
return new CraftingPatternDetails(ais, world);
|
||||
try {
|
||||
return new CraftingPatternDetails(ais, world);
|
||||
} catch (IllegalStateException e) {
|
||||
AELog.warn("Could not decode an invalid pattern %s: %s", is, e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private boolean attemptRecovery(EncodedPatternItem patternItem, ItemStack itemStack, World world) {
|
||||
|
||||
@@ -299,14 +299,27 @@ public class EncodedPatternItem extends AEBaseItem implements AEToolItem {
|
||||
final ListTag tagIn = new ListTag();
|
||||
final ListTag tagOut = new ListTag();
|
||||
|
||||
boolean hasInput = false;
|
||||
for (final ItemStack i : in) {
|
||||
tagIn.add(createItemTag(i));
|
||||
if (!i.isEmpty()) {
|
||||
hasInput = true;
|
||||
}
|
||||
}
|
||||
|
||||
Preconditions.checkArgument(hasInput, "cannot encode a pattern that has no inputs.");
|
||||
|
||||
boolean hasNonEmptyOutput = false;
|
||||
for (final ItemStack i : out) {
|
||||
tagOut.add(createItemTag(i));
|
||||
if (!i.isEmpty()) {
|
||||
hasNonEmptyOutput = true;
|
||||
}
|
||||
}
|
||||
|
||||
// Patterns without any outputs are corrupt! Never encode such a pattern.
|
||||
Preconditions.checkArgument(hasNonEmptyOutput, "cannot encode a pattern that has no output.");
|
||||
|
||||
encodedValue.put(EncodedPatternItem.NBT_INGREDIENTS, tagIn);
|
||||
encodedValue.put(EncodedPatternItem.NBT_PRODUCTS, tagOut);
|
||||
return encodedValue;
|
||||
|
||||
Reference in New Issue
Block a user