From a2bcce9ab18203f425f0e8525e77df9bc532e010 Mon Sep 17 00:00:00 2001 From: t00thpick1 Date: Sat, 17 Dec 2016 17:32:16 -0500 Subject: [PATCH] I believe this resolves berserk allowing you to take drops into your equipment slots. --- .../gmail/nossr50/skills/unarmed/Unarmed.java | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/gmail/nossr50/skills/unarmed/Unarmed.java b/src/main/java/com/gmail/nossr50/skills/unarmed/Unarmed.java index bba1dfedd..aeb17d2c1 100644 --- a/src/main/java/com/gmail/nossr50/skills/unarmed/Unarmed.java +++ b/src/main/java/com/gmail/nossr50/skills/unarmed/Unarmed.java @@ -26,7 +26,8 @@ public class Unarmed { if (inventory.containsAtLeast(dropStack, 1)) { int nextSlot = 0; - for (ItemStack itemstack : inventory) { + ItemStack[] items = inventory.getStorageContents(); + for (ItemStack itemstack : items) { if (dropStack.isSimilar(itemstack)) { int itemAmount = itemstack.getAmount(); int itemMax = itemstack.getMaxStackSize(); @@ -36,13 +37,15 @@ public class Unarmed { if (dropAmount + itemAmount <= itemMax) { drop.remove(); addStack.setAmount(dropAmount + itemAmount); - inventory.setItem(nextSlot, addStack); + items[nextSlot] = addStack; + inventory.setStorageContents(items); return true; } addStack.setAmount(itemMax); dropAmount = dropAmount + itemAmount - itemMax; - inventory.setItem(nextSlot, addStack); + items[nextSlot] = addStack; + inventory.setStorageContents(items); } if (dropAmount == 0) { @@ -57,13 +60,15 @@ public class Unarmed { if (firstEmpty == inventory.getHeldItemSlot()) { int nextSlot = firstEmpty + 1; - for (Iterator iterator = inventory.iterator(nextSlot); iterator.hasNext(); ) { - ItemStack itemstack = iterator.next(); + ItemStack[] items = inventory.getStorageContents(); + for (; nextSlot < items.length; nextSlot++) { + ItemStack itemstack = items[nextSlot]; if (itemstack == null) { drop.remove(); dropStack.setAmount(dropAmount); - inventory.setItem(nextSlot, dropStack); + items[nextSlot] = dropStack; + inventory.setStorageContents(items); return true; }