From d3f1dc6fb3ce65551cf5e642e4e3415e3e3a520c Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Wed, 24 Jun 2020 18:50:39 +0200 Subject: [PATCH] Fixes #1855 plus a few optimizations --- CHANGELOG.md | 3 ++ .../core/networks/cargo/CargoNet.java | 38 +++++++++++++------ .../core/networks/cargo/CargoUtils.java | 1 + 3 files changed, 31 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fe7b1cf0f..94ba74d59 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -37,6 +37,8 @@ * Performance improvements to Rainbow Blocks * Crafting Tin cans now produces 8 items instead of 4 * Multi Tool lore now says "Crouch" instead of "Hold Shift" +* items which cannot be distributed by a Cargo Net will be dropped on the ground now instead of getting deleted +* Small performance improvements to the Cargo Net #### Fixes * Fixed #2005 @@ -44,6 +46,7 @@ * Fixed a chunk caching issue for GEO resources * Fixed Infused Magnet working even if you haven't researched it * Fixed Rainbow blocks duplication glitch when timing the block break right +* Fixed #1855 ## Release Candidate 13 (16 Jun 2020) https://thebusybiscuit.github.io/builds/TheBusyBiscuit/Slimefun4/stable/#13 diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/cargo/CargoNet.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/cargo/CargoNet.java index 31b952c72..ee42a1f93 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/cargo/CargoNet.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/cargo/CargoNet.java @@ -87,7 +87,10 @@ public class CargoNet extends ChestTerminalNetwork { @Override public NetworkComponent classifyLocation(Location l) { String id = BlockStorage.checkID(l); - if (id == null) return null; + + if (id == null) { + return null; + } switch (id) { case "CARGO_MANAGER": @@ -157,8 +160,8 @@ public class CargoNet extends ChestTerminalNetwork { // Chest Terminal Stuff Set destinations = new HashSet<>(); - List output16 = output.get(16); + if (output16 != null) { destinations.addAll(output16); } @@ -264,17 +267,30 @@ public class CargoNet extends ChestTerminalNetwork { stack = distributeItem(stack, inputNode, outputs); } - DirtyChestMenu menu = CargoUtils.getChestMenu(inputTarget); + if (stack != null) { + DirtyChestMenu menu = CargoUtils.getChestMenu(inputTarget); - if (menu != null) { - menu.replaceExistingItem(previousSlot, stack); - } - else if (CargoUtils.hasInventory(inputTarget)) { - BlockState state = inputTarget.getState(); + if (menu != null) { + if (menu.getItemInSlot(previousSlot) == null) { + menu.replaceExistingItem(previousSlot, stack); + } + else { + inputTarget.getWorld().dropItem(inputTarget.getLocation().add(0, 1, 0), stack); + } + } + else if (CargoUtils.hasInventory(inputTarget)) { + BlockState state = inputTarget.getState(); - if (state instanceof InventoryHolder) { - Inventory inv = ((InventoryHolder) state).getInventory(); - inv.setItem(previousSlot, stack); + if (state instanceof InventoryHolder) { + Inventory inv = ((InventoryHolder) state).getInventory(); + + if (inv.getItem(previousSlot) == null) { + inv.setItem(previousSlot, stack); + } + else { + inputTarget.getWorld().dropItem(inputTarget.getLocation().add(0, 1, 0), stack); + } + } } } } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/cargo/CargoUtils.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/cargo/CargoUtils.java index c9a4eeb2d..47bee5f73 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/cargo/CargoUtils.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/cargo/CargoUtils.java @@ -194,6 +194,7 @@ final class CargoUtils { } } } + return null; }