Browse Source

resource dupe

lakebane-master
FatBoy-DOTC 10 months ago
parent
commit
2d93e408c3
  1. 14
      src/engine/net/client/ClientMessagePump.java
  2. 16
      src/engine/objects/CharacterItemManager.java

14
src/engine/net/client/ClientMessagePump.java

@ -1444,6 +1444,19 @@ public class ClientMessagePump implements NetMsgHandler { @@ -1444,6 +1444,19 @@ public class ClientMessagePump implements NetMsgHandler {
return;
}
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);
@ -1452,6 +1465,7 @@ public class ClientMessagePump implements NetMsgHandler { @@ -1452,6 +1465,7 @@ public class ClientMessagePump implements NetMsgHandler {
}
}
}
}
} else if (msg.getItemType() == GameObjectType.Item.ordinal()) {
CharacterItemManager npcCim = npc.getCharItemManager();

16
src/engine/objects/CharacterItemManager.java

@ -1255,21 +1255,7 @@ public class CharacterItemManager { @@ -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;

Loading…
Cancel
Save