Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void trade(ItemStack item, int cost)
- {
- int totalErium = 0;
- for (ItemStack stack: theplayer.inventory.mainInventory)
- if (stack != null && stack.itemID == mod_ArcticCraft.eriumStone.shiftedIndex)
- totalErium += stack.stackSize;
- if (totalErium < cost)
- {
- theplayer.addChatMessage("You don't have enough Erium to make this trade.");
- return;
- }
- // removes the stuff from the inventory.
- for (int i = 0; i < theplayer.inventory.mainInventory.length; i++)
- {
- ItemStack stack = theplayer.inventory.mainInventory[i];
- if (stack != null && stack.itemID == mod_ArcticCraft.eriumStone.shiftedIndex)
- {
- if (stack.stackSize >= cost)
- {
- stack.stackSize -= cost;
- if (stack.stackSize == 0)
- theplayer.inventory.mainInventory[i] = null;
- break; // or return, and and the method.
- }
- else if (stack.stackSize < cost)
- {
- cost -= stack.stackSize;
- theplayer.inventory.mainInventory[i] = null;
- }
- }
- }
- theplayer.inventory.addItemStackToInventory(item);
- }
Add Comment
Please, Sign In to add comment