diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/Item.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/Item.java index 712c66f6d..43238d739 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/Item.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/Item.java @@ -270,6 +270,7 @@ public class Item implements Bundlable { if (item == this) { container.items.remove(this); item.onDetach(); + container.grabItems(); //try to put more items into the bag as it now has free space return this; } else if (item instanceof Bag) { Bag bag = (Bag)item; diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/bags/Bag.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/bags/Bag.java index b7eb9665d..2714dd87d 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/bags/Bag.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/bags/Bag.java @@ -69,18 +69,7 @@ public class Bag extends Item implements Iterable { @Override public boolean collect( Bag container ) { - for (Item item : container.items.toArray( new Item[0] )) { - if (canHold( item )) { - int slot = Dungeon.quickslot.getSlot(item); - item.detachAll(container); - if (!item.collect(this)) { - item.collect(container); - } - if (slot != -1) { - Dungeon.quickslot.setSlot(slot, item); - } - } - } + grabItems(container); if (super.collect( container )) { @@ -102,6 +91,27 @@ public class Bag extends Item implements Iterable { updateQuickslot(); } + public void grabItems(){ + if (this != Dungeon.hero.belongings.backpack) { + grabItems(Dungeon.hero.belongings.backpack); + } + } + + public void grabItems( Bag container ){ + for (Item item : container.items.toArray( new Item[0] )) { + if (canHold( item )) { + int slot = Dungeon.quickslot.getSlot(item); + item.detachAll(container); + if (!item.collect(this)) { + item.collect(container); + } + if (slot != -1) { + Dungeon.quickslot.setSlot(slot, item); + } + } + } + } + @Override public boolean isUpgradable() { return false;