Skip to content

Commit

Permalink
Add safeguard and logging for recipes leading to duplicate (infinitel…
Browse files Browse the repository at this point in the history
…y-looping) compression variants
  • Loading branch information
62832 committed Nov 6, 2024
1 parent cc8ce5d commit 8c0b9ee
Showing 1 changed file with 17 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,16 @@ private CompressionChain generateChain(
variants.addFirst(baseVariant);

for (var lower = getNextVariant(baseVariant, decompressed, false, access); lower != null; ) {
variants.addFirst(lower.item().getItem());
var item = lower.item.getItem();

if (variants.contains(item)) {
MEGACells.LOGGER.warn(
"Duplicate lower compression variant detected: {}. Check any recipe involving this item for problems.",
lower);
break;
}

variants.addFirst(item);
multipliers.addFirst(lower.factor());
lower = getNextVariant(lower.item().getItem(), decompressed, false, access);
}
Expand All @@ -110,6 +119,13 @@ private CompressionChain generateChain(
}

for (var higher = getNextVariant(baseVariant, compressed, true, access); higher != null; ) {
if (chain.contains(higher)) {
MEGACells.LOGGER.warn(
"Duplicate higher compression variant detected: {}}. Check any recipe involving this item for problems.",
higher);
break;
}

chain.add(higher);
higher = getNextVariant(higher.item().getItem(), compressed, true, access);
}
Expand Down

0 comments on commit 8c0b9ee

Please sign in to comment.