diff --git a/CHANGELOG.md b/CHANGELOG.md index 81dc20baa..fffbe97d8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -38,6 +38,7 @@ * Fixed a threading issue related to BlockStates and persistent data * Fixed an error when the server was shutting down * Fixed #2721 +* Fixed #2662 ## Release Candidate 19 (11 Jan 2021) 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 7b73eafe8..c79ec0b6a 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 @@ -16,6 +16,7 @@ import org.bukkit.inventory.Inventory; import org.bukkit.inventory.InventoryHolder; import org.bukkit.inventory.ItemStack; +import io.github.thebusybiscuit.cscorelib2.inventory.InvUtils; import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin; import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils; import io.github.thebusybiscuit.slimefun4.utils.itemstack.ItemStackWrapper; @@ -310,7 +311,15 @@ final class CargoUtils { } @Nullable - private static ItemStack insertIntoVanillaInventory(ItemStack stack, Inventory inv) { + private static ItemStack insertIntoVanillaInventory(@Nonnull ItemStack stack, @Nonnull Inventory inv) { + /* + * If the Inventory does not accept this Item Type, bounce the item back. + * Example: Shulker boxes within shulker boxes (fixes #2662) + */ + if (!InvUtils.isItemAllowed(stack.getType(), inv.getType())) { + return stack; + } + ItemStack[] contents = inv.getContents(); int[] range = getInputSlotRange(inv, stack); int minSlot = range[0];