Skip to content

Commit

Permalink
make substitution pattern fallback to normal pattern sometimes crash (#…
Browse files Browse the repository at this point in the history
…208)

* fix inverted beSubstitutionsBtn

* fix substitution pattern fallback to normal pattern sometimes crash if no substitutable pattern matches
  • Loading branch information
asdflj authored Dec 14, 2022
1 parent 457e6b7 commit 267793b
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/main/java/appeng/me/cache/CraftingGridCache.java
Original file line number Diff line number Diff line change
Expand Up @@ -415,11 +415,13 @@ public ImmutableCollection<ICraftingPatternDetails> getCraftingFor(
final int slotIndex,
final World world) {
final ImmutableList<ICraftingPatternDetails> res;
boolean normalMode = false;
if (details != null && details.canSubstitute()) {
final Collection<IAEItemStack> substitutions =
this.craftableItemSubstitutes.findFuzzy(whatToCraft, FuzzyMode.IGNORE_ALL);
if (substitutions.isEmpty()) {
res = this.craftableItems.get(whatToCraft);
normalMode = true;
} else {
ImmutableList.Builder<ICraftingPatternDetails> allPatterns = ImmutableList.builder();
for (IAEItemStack alternative : substitutions) {
Expand All @@ -443,7 +445,7 @@ public ImmutableCollection<ICraftingPatternDetails> getCraftingFor(
}
}
// no perfect match found, look for substitutions
if (details.canSubstitute()) {
if (details.canSubstitute() && !normalMode) {
for (final Map.Entry<IAEItemStack, ImmutableList<ICraftingPatternDetails>> entry :
this.craftableItems.entrySet()) {
final boolean canBeASubstitute =
Expand Down

0 comments on commit 267793b

Please sign in to comment.