Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public boolean wearFromInventory(int invSlot) {
- final Item wear = inv.get(invSlot);
- if (wear == null) {
- return false;
- }
- EquipmentType type = getType(wear);
- final Item worn = get(type.slot);
- if (worn != null && worn.id == wear.id) {
- if (!ItemDef.forId(worn.id).isStackable()) {
- return false;
- }
- long totalAmount = worn.amt + wear.amt;
- if (totalAmount > MAX_ITEM_AMT) {
- inv.set(Item.valueOf(worn.id, (int) (totalAmount - MAX_ITEM_AMT)), invSlot);
- set(Item.valueOf(worn.id, MAX_ITEM_AMT), type.slot);
- return true;
- } else {
- set(Item.valueOf(worn.id, inv.del(invSlot).amt + worn.amt), type.slot);
- return true;
- }
- } else {
- set(inv.del(invSlot), type.slot);
- }
- return false;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement