From 912ebd47423333c3e16195e0afd235e0aaf50031 Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Sat, 9 Mar 2024 19:59:21 -0600 Subject: [PATCH] resource stacking bug --- src/engine/objects/CharacterItemManager.java | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) 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; }