corrected whitelist / blacklist behaviour
This commit is contained in:
parent
8528811147
commit
cca9c78e95
@ -9,7 +9,7 @@
|
|||||||
loader_version=0.14.9
|
loader_version=0.14.9
|
||||||
|
|
||||||
# Mod Properties
|
# Mod Properties
|
||||||
mod_version = 1.19.2.5
|
mod_version = 1.19.2.6
|
||||||
maven_group = de.jottyfan.minecraft
|
maven_group = de.jottyfan.minecraft
|
||||||
archives_base_name = quickiefabric
|
archives_base_name = quickiefabric
|
||||||
|
|
||||||
|
@ -133,39 +133,26 @@ public class BlockStackerEntity extends BlockEntity implements NamedScreenHandle
|
|||||||
}
|
}
|
||||||
Boolean found = false;
|
Boolean found = false;
|
||||||
|
|
||||||
|
if (hasItems(whiteList)) {
|
||||||
Item matchItem = findNextItem(whiteList, checked);
|
Item matchItem = findNextItem(whiteList, checked);
|
||||||
while(!found && matchItem != null) {
|
while(!found && matchItem != null) {
|
||||||
checked.add(matchItem);
|
checked.add(matchItem);
|
||||||
List<Item> matchItems = new ArrayList<>();
|
List<Item> matchItems = new ArrayList<>();
|
||||||
matchItems.add(matchItem);
|
matchItems.add(matchItem);
|
||||||
found = transferOneStack(source, dest, matchItems, true, !hasItems(whiteList));
|
found = transferOneStack(source, dest, matchItems, true);
|
||||||
matchItem = findNextItem(whiteList, checked);
|
matchItem = findNextItem(whiteList, checked);
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
// blacklist behaviour
|
// transport all but the items of the blacklist
|
||||||
// for all the items that are not in the (already handled) whitelist and not in the blacklist, handle the transport
|
found = transferOneStack(source, dest, checked, false);
|
||||||
List<Item> ignoreItems = new ArrayList<>();
|
|
||||||
for (ItemStack stack : blackList) {
|
|
||||||
if (stack != null && !stack.isEmpty()) {
|
|
||||||
ignoreItems.add(stack.getItem());
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
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;
|
return found;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final Boolean transferOneStack(LootableContainerBlockEntity source, LootableContainerBlockEntity dest,
|
private static final Boolean transferOneStack(LootableContainerBlockEntity source, LootableContainerBlockEntity dest,
|
||||||
List<Item> ignoreItems, Boolean whitelist, Boolean emptyWhitelist) {
|
List<Item> ignoreItems, Boolean whitelist) {
|
||||||
Boolean result = false;
|
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())) {
|
if (sourceSlot != null && !Items.AIR.equals(source.getStack(sourceSlot).getItem())) {
|
||||||
ItemStack sourceStack = source.getStack(sourceSlot);
|
ItemStack sourceStack = source.getStack(sourceSlot);
|
||||||
Integer destSlot = findItemStackPos(dest, sourceStack);
|
Integer destSlot = findItemStackPos(dest, sourceStack);
|
||||||
@ -243,7 +230,7 @@ public class BlockStackerEntity extends BlockEntity implements NamedScreenHandle
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final Integer findItemStackPos(LootableContainerBlockEntity lcbe, List<Item> filterItems, Boolean whitelist, Boolean emptyWhitelist) {
|
private static final Integer findItemStackPos(LootableContainerBlockEntity lcbe, List<Item> filterItems, Boolean whitelist) {
|
||||||
if (whitelist == null) {
|
if (whitelist == null) {
|
||||||
whitelist = true;
|
whitelist = true;
|
||||||
LOGGER.error("whitelist is null");
|
LOGGER.error("whitelist is null");
|
||||||
@ -251,18 +238,15 @@ public class BlockStackerEntity extends BlockEntity implements NamedScreenHandle
|
|||||||
if (filterItems == null || filterItems.size() < 1) {
|
if (filterItems == null || filterItems.size() < 1) {
|
||||||
if (whitelist) {
|
if (whitelist) {
|
||||||
return null;
|
return null;
|
||||||
} else if (emptyWhitelist) {
|
|
||||||
return findItemStackPos(lcbe, false);
|
|
||||||
} else {
|
} else {
|
||||||
LOGGER.error("no filter items, but whitelist is not empty");
|
return findItemStackPos(lcbe, false);
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Integer counter = lcbe.size();
|
Integer counter = lcbe.size();
|
||||||
while (counter > 0) {
|
while (counter > 0) {
|
||||||
counter--;
|
counter--;
|
||||||
ItemStack stack = lcbe.getStack(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) {
|
if (found) {
|
||||||
return counter;
|
return counter;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user