From 86edb0df6a4c0730b28ae3271d05e8abad5fa391 Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Wed, 10 Mar 2021 13:36:28 +0100 Subject: [PATCH] Fixes #2876 --- CHANGELOG.md | 1 + .../core/networks/cargo/ItemFilter.java | 18 ++++++++++++++++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3c306a347..1f9aa03ef 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -52,6 +52,7 @@ * Fixed #2805 * Fixed #2861 * Fixed #2856 +* Fixed #2876 ## Release Candidate 20 (30 Jan 2021) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/cargo/ItemFilter.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/cargo/ItemFilter.java index 5b5a780d3..713b3395e 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/cargo/ItemFilter.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/cargo/ItemFilter.java @@ -89,15 +89,29 @@ class ItemFilter implements Predicate { try { CargoNode node = (CargoNode) item; - if (node.hasItemFilter()) { + if (!node.hasItemFilter()) { // Node does not have a filter, allow everything clear(true); } else { + int[] slots = CargoUtils.getFilteringSlots(); + int inventorySize = menu.toInventory().getSize(); + + if (inventorySize < slots[slots.length - 1]) { + /* + * Related to #2876 + * The reason was a missing negation int he filtering statement above. + * However if that ever happens again, we will know the reason and be able + * to send a warning in response to it. + */ + item.warn("Cargo Node was marked as a 'filtering' node but has an insufficient inventory size (" + inventorySize + ")"); + return; + } + this.items.clear(); this.checkLore = Objects.equals(blockData.getString("filter-lore"), "true"); this.rejectOnMatch = !Objects.equals(blockData.getString("filter-type"), "whitelist"); - for (int slot : CargoUtils.getFilteringSlots()) { + for (int slot : slots) { ItemStack stack = menu.getItemInSlot(slot); if (stack != null && stack.getType() != Material.AIR) {