Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if (k == 0 || k == 1) { //if left or right click
- int stackSize = 64;
- if (k == 1) { //if right click
- stackSize = 1;
- }
- Slot cslot = super.getSlotAtCoords(i, j);
- if (cslot!=null) { //if they actually clicked a slot
- ItemStack slotstack = cslot.getStack();
- ItemStack pstack = mc.thePlayer.inventory.getItemStack();
- if (slotstack!=null) { //if there is an item in that slot
- if(pstack==null) { //if the player is not holding an item with the cursor
- if (cslot.slotNumber>=72&&cslot.slotNumber<=80) { //hotbar slots
- stackSize = slotstack.stackSize;
- }
- ItemStack newstack = new ItemStack(slotstack.itemID, stackSize, slotstack.getItemDamage());
- mc.thePlayer.inventory.setItemStack(newstack);
- if (cslot.slotNumber>=72&&cslot.slotNumber<=80) { //hotbar slots
- cslot.putStack(null);
- }
- } else { //if the player is holding an item with the cursor
- if (cslot.slotNumber>=72&&cslot.slotNumber<=80) { //hotbar slots
- mc.thePlayer.inventory.setItemStack(slotstack); //switch the held item with the slot item
- cslot.putStack(pstack);
- //if they're the same item type and they're stackable and the slot stack isn't already full
- if (pstack.isItemEqual(cslot.getStack())&&pstack.isStackable()&&cslot.getStack().stackSize<64) {
- ItemStack cstack = cslot.getStack();
- if (k == 0) { //if left click
- while (cslot.getStack().stackSize<64&&pstack.stackSize>=1) {
- pstack.stackSize-=1;
- cslot.putStack(new ItemStack(cstack.itemID, cstack.stackSize+1, cstack.getItemDamage()));
- }
- } else { //if right click
- pstack.stackSize-=1;
- cslot.putStack(new ItemStack(cstack.itemID, cstack.stackSize+1, cstack.getItemDamage()));
- }
- if (pstack.stackSize==0) {
- mc.thePlayer.inventory.setItemStack(null);
- }
- }
- } else {
- mc.thePlayer.inventory.setItemStack(null);
- }
- }
- } else { //if there is not an item in that slot
- if (pstack!=null) { //if the player is holding an item with the cursor
- if (cslot.slotNumber>=72&&cslot.slotNumber<=80) { //if clicked in hotbar slots
- if (k == 0) { //if left click
- cslot.putStack(pstack);
- mc.thePlayer.inventory.setItemStack(null);
- } else { //if right click
- cslot.putStack(new ItemStack(pstack.itemID, 1, pstack.getItemDamage()));
- mc.thePlayer.inventory.setItemStack(new ItemStack(pstack.itemID, pstack.stackSize-1, pstack.getItemDamage()));
- }
- } else { //if clicked in item selection area
- mc.thePlayer.inventory.setItemStack(null);
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement