diff --git a/gradle.properties b/gradle.properties index 68626f3..bce16ad 100644 --- a/gradle.properties +++ b/gradle.properties @@ -9,7 +9,7 @@ loader_version=0.14.9 # Mod Properties - mod_version = 1.19.2.5 + mod_version = 1.19.2.6 maven_group = de.jottyfan.minecraft archives_base_name = quickiefabric diff --git a/src/main/java/de/jottyfan/minecraft/quickiefabric/blockentity/BlockStackerEntity.java b/src/main/java/de/jottyfan/minecraft/quickiefabric/blockentity/BlockStackerEntity.java index 476a199..dd18fd7 100644 --- a/src/main/java/de/jottyfan/minecraft/quickiefabric/blockentity/BlockStackerEntity.java +++ b/src/main/java/de/jottyfan/minecraft/quickiefabric/blockentity/BlockStackerEntity.java @@ -133,39 +133,26 @@ public class BlockStackerEntity extends BlockEntity implements NamedScreenHandle } Boolean found = false; - Item matchItem = findNextItem(whiteList, checked); - while(!found && matchItem != null) { - checked.add(matchItem); - List matchItems = new ArrayList<>(); - matchItems.add(matchItem); - found = transferOneStack(source, dest, matchItems, true, !hasItems(whiteList)); - matchItem = findNextItem(whiteList, checked); - } - - // blacklist behaviour - // for all the items that are not in the (already handled) whitelist and not in the blacklist, handle the transport - List ignoreItems = new ArrayList<>(); - for (ItemStack stack : blackList) { - if (stack != null && !stack.isEmpty()) { - ignoreItems.add(stack.getItem()); + if (hasItems(whiteList)) { + Item matchItem = findNextItem(whiteList, checked); + while(!found && matchItem != null) { + checked.add(matchItem); + List matchItems = new ArrayList<>(); + matchItems.add(matchItem); + found = transferOneStack(source, dest, matchItems, true); + matchItem = findNextItem(whiteList, checked); } + } else { + // transport all but the items of the blacklist + found = transferOneStack(source, dest, checked, false); } - for (ItemStack stack : whiteList) { - if (stack != null && !stack.isEmpty()) { - ignoreItems.add(stack.getItem()); - } - } - if (!found) { - found = transferOneStack(source, dest, ignoreItems, false, !hasItems(whiteList)); - } - return found; } private static final Boolean transferOneStack(LootableContainerBlockEntity source, LootableContainerBlockEntity dest, - List ignoreItems, Boolean whitelist, Boolean emptyWhitelist) { + List ignoreItems, Boolean whitelist) { Boolean result = false; - Integer sourceSlot = findItemStackPos(source, ignoreItems, whitelist, emptyWhitelist); + Integer sourceSlot = findItemStackPos(source, ignoreItems, whitelist); if (sourceSlot != null && !Items.AIR.equals(source.getStack(sourceSlot).getItem())) { ItemStack sourceStack = source.getStack(sourceSlot); Integer destSlot = findItemStackPos(dest, sourceStack); @@ -243,7 +230,7 @@ public class BlockStackerEntity extends BlockEntity implements NamedScreenHandle return null; } - private static final Integer findItemStackPos(LootableContainerBlockEntity lcbe, List filterItems, Boolean whitelist, Boolean emptyWhitelist) { + private static final Integer findItemStackPos(LootableContainerBlockEntity lcbe, List filterItems, Boolean whitelist) { if (whitelist == null) { whitelist = true; LOGGER.error("whitelist is null"); @@ -251,18 +238,15 @@ public class BlockStackerEntity extends BlockEntity implements NamedScreenHandle if (filterItems == null || filterItems.size() < 1) { if (whitelist) { return null; - } else if (emptyWhitelist) { - return findItemStackPos(lcbe, false); } else { - LOGGER.error("no filter items, but whitelist is not empty"); - return null; + return findItemStackPos(lcbe, false); } } else { Integer counter = lcbe.size(); while (counter > 0) { counter--; ItemStack stack = lcbe.getStack(counter); - Boolean found = whitelist ? filterItems.contains(stack.getItem()) : (!emptyWhitelist && !filterItems.contains(stack.getItem())); + Boolean found = whitelist ? filterItems.contains(stack.getItem()) : !filterItems.contains(stack.getItem()); if (found) { return counter; }