diff options
author | Glease <4586901+Glease@users.noreply.github.com> | 2021-06-16 17:28:35 +0800 |
---|---|---|
committer | Glease <4586901+Glease@users.noreply.github.com> | 2021-06-16 17:28:35 +0800 |
commit | a0abfe331dae9692ef86e1e2809259cbff728f6b (patch) | |
tree | c75c14ca650e147ef06ea3efbec5fc3711809461 /src/main/java/gregtech/api | |
parent | 062d9814c4bad9be10f25d78871cef5d708a712c (diff) | |
download | GT5-Unofficial-a0abfe331dae9692ef86e1e2809259cbff728f6b.tar.gz GT5-Unofficial-a0abfe331dae9692ef86e1e2809259cbff728f6b.tar.bz2 GT5-Unofficial-a0abfe331dae9692ef86e1e2809259cbff728f6b.zip |
Fix UnsupportedOperationException for listContainsItem
Signed-off-by: Glease <4586901+Glease@users.noreply.github.com>
Diffstat (limited to 'src/main/java/gregtech/api')
-rw-r--r-- | src/main/java/gregtech/api/util/GT_Utility.java | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/src/main/java/gregtech/api/util/GT_Utility.java b/src/main/java/gregtech/api/util/GT_Utility.java index e9a9d6a436..8cbb44fe07 100644 --- a/src/main/java/gregtech/api/util/GT_Utility.java +++ b/src/main/java/gregtech/api/util/GT_Utility.java @@ -886,13 +886,16 @@ public class GT_Utility { public static boolean listContainsItem(Collection<ItemStack> aList, ItemStack aStack, boolean aTIfListEmpty, boolean aInvertFilter) { if (aStack == null || aStack.stackSize < 1) return false; if (aList == null) return aTIfListEmpty; - aList.removeIf(Objects::isNull); - if (aList.size() < 1) return aTIfListEmpty; - Iterator<ItemStack> tIterator = aList.iterator(); - ItemStack tStack = null; - while (tIterator.hasNext()) - if ((tStack = tIterator.next()) != null && areStacksEqual(aStack, tStack)) return !aInvertFilter; - return aInvertFilter; + boolean tEmpty = true; + for (ItemStack tStack : aList) { + if (tStack != null) { + tEmpty = false; + if (areStacksEqual(aStack, tStack)) { + return !aInvertFilter; + } + } + } + return tEmpty ? aTIfListEmpty : aInvertFilter; } public static boolean areStacksOrToolsEqual(ItemStack aStack1, ItemStack aStack2) { |