From 74950b7a5d0f6438aa07b602c96b50cfcbc25f96 Mon Sep 17 00:00:00 2001 From: tastybento Date: Sun, 4 Nov 2018 09:16:55 -0800 Subject: [PATCH] Fix for pasting double chests in certain orientations. https://github.com/BentoBoxWorld/bentobox/issues/326 Error was that double chests get pasted in two single blocks but the full inventory is stored for each block. This code just ignores any inventory slots greater than what the chest can handle. --- src/main/java/world/bentobox/bentobox/schems/Clipboard.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main/java/world/bentobox/bentobox/schems/Clipboard.java b/src/main/java/world/bentobox/bentobox/schems/Clipboard.java index cbf377faa..443a07680 100644 --- a/src/main/java/world/bentobox/bentobox/schems/Clipboard.java +++ b/src/main/java/world/bentobox/bentobox/schems/Clipboard.java @@ -322,7 +322,10 @@ public class Clipboard { Inventory ih = ((InventoryHolder)bs).getInventory(); if (config.isConfigurationSection(INVENTORY)) { ConfigurationSection inv = config.getConfigurationSection(INVENTORY); - inv.getKeys(false).forEach(i -> ih.setItem(Integer.valueOf(i), (ItemStack)inv.get(i))); + // Double chests are pasted as two blocks so inventory is filled twice. This code stops over filling for the first block. + inv.getKeys(false).stream() + .filter(i -> Integer.valueOf(i) < ih.getSize()) + .forEach(i -> ih.setItem(Integer.valueOf(i), (ItemStack)inv.get(i))); } } // Mob spawners