Improved performance of ItemStack merging (fix #385)

This commit is contained in:
asdanjer 2023-07-13 00:29:22 +02:00 committed by GitHub
parent e0d65453b6
commit d200616fe1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -457,16 +457,20 @@ public class Util extends Queue {
try { try {
int c1 = 0; int c1 = 0;
for (ItemStack o1 : items) { for (ItemStack o1 : items) {
int c2 = 0; if (o1 != null) {
for (ItemStack o2 : items) { if (o1.getAmount() != 0) {
if (o1 != null && o2 != null && c2 > c1 && o1.isSimilar(o2) && !Util.isAir(o1.getType())) { // Ignores amount int c2 = 0;
int namount = o1.getAmount() + o2.getAmount(); for (ItemStack o2 : items) {
o1.setAmount(namount); if (o2 != null && c2 > c1 && o1.isSimilar(o2) && !Util.isAir(o1.getType())) { // Ignores amount
o2.setAmount(0); int namount = o1.getAmount() + o2.getAmount();
o1.setAmount(namount);
o2.setAmount(0);
}
c2++;
}
} }
c2++;
} }
c1++; c1++;
} }
} }
catch (Exception e) { catch (Exception e) {