diff --git a/src/engine/net/client/ClientMessagePump.java b/src/engine/net/client/ClientMessagePump.java index 8c305915..45095cbb 100644 --- a/src/engine/net/client/ClientMessagePump.java +++ b/src/engine/net/client/ClientMessagePump.java @@ -1444,11 +1444,25 @@ public class ClientMessagePump implements NetMsgHandler { return; } - buy = Item.createItemForPlayer(sourcePlayer, ib); - if (buy != null) { - me.transferEnchants(buy); - itemMan.addItemToInventory(buy); - //itemMan.updateInventory(); + if(ib.getType().ordinal() == Enum.ItemType.RESOURCE.ordinal()) { + int count = 1; + for(Item item : itemMan.getInventory()){ + if(item.getItemBaseID() == ib.getUUID()){ + if(item.getNumOfItems() + count <= Warehouse.getMaxResources().get(ib.getUUID())){ + count += item.getNumOfItems(); + itemMan.delete(item); + } + } + } + Item resource = new MobLoot(sourcePlayer,ib,count,false).promoteToItem(sourcePlayer); + itemMan.addItemToInventory(resource); + }else { + buy = Item.createItemForPlayer(sourcePlayer, ib); + if (buy != null) { + me.transferEnchants(buy); + itemMan.addItemToInventory(buy); + //itemMan.updateInventory(); + } } } } diff --git a/src/engine/objects/CharacterItemManager.java b/src/engine/objects/CharacterItemManager.java index f1f45c95..0b664877 100644 --- a/src/engine/objects/CharacterItemManager.java +++ b/src/engine/objects/CharacterItemManager.java @@ -1255,21 +1255,7 @@ public class CharacterItemManager { 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())){ - count += item.getNumOfItems(); - delete(item); - } - } - } - Item resource = new MobLoot(this.getOwner(),i.getItemBase(),count,false).promoteToItem((PlayerCharacter)this.getOwner()); - this.inventory.add(resource); - this.itemIDtoType.put(resource.getObjectUUID(), resource.getObjectType().ordinal()); - return true; - } + this.inventory.add(i); this.itemIDtoType.put(i.getObjectUUID(), i.getObjectType().ordinal()); return true;