diff --git a/src/engine/objects/CharacterItemManager.java b/src/engine/objects/CharacterItemManager.java index 8c346166..44e5ddd6 100644 --- a/src/engine/objects/CharacterItemManager.java +++ b/src/engine/objects/CharacterItemManager.java @@ -1241,7 +1241,7 @@ public class CharacterItemManager { // This adds item to inventory for loot. Validity checks already handled public synchronized boolean addItemToInventory(Item i) { - if (i.getItemBase().getType().equals(ItemType.GOLD)) + if (i.getItemBase().getType().equals(ItemType.GOLD)) { if (this.absCharacter.getObjectType() == GameObjectType.Mob) { if (this.goldInventory == null) loadGoldItems(); @@ -1252,13 +1252,22 @@ public class CharacterItemManager { updateInventory(); return true; } - return false; } - + } + if(ItemBase.getItemBase(i.getItemBaseID()).getType().ordinal() == Enum.ItemType.RESOURCE.ordinal()) { + int count = i.getNumOfItems(); + for(Item item : this.inventory){ + if(item.getItemBaseID() == i.getItemBaseID()){ + if(item.getNumOfItems() + count <= Warehouse.getMaxResources().get(i.getItemBaseID())){ + this.junk(item); + count += item.getNumOfItems(); + } + } + } + } this.inventory.add(i); this.itemIDtoType.put(i.getObjectUUID(), i.getObjectType().ordinal()); - return true; }