Advertisement
sshcrack

Untitled

Mar 18th, 2023
852
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.18 KB | Source Code | 0 0
  1.     public boolean scrollToWart() {
  2.         PlayerInventory inv = player.getInventory();
  3.  
  4.         ItemStack lowestStack = null;
  5.         int lowestSlot = Integer.MAX_VALUE;
  6.  
  7.         for (ItemStack stack : inv.main) {
  8.             if(!stack.isOf(Items.NETHER_WART))
  9.                 continue;
  10.  
  11.             if(lowestStack != null && lowestStack.getCount() < stack.getCount())
  12.                 continue;
  13.  
  14.  
  15.             lowestStack = stack;
  16.             lowestSlot = inv.getSlotWithStack(stack);
  17.         }
  18.  
  19.         if(lowestStack == null)
  20.             return false;
  21.  
  22.         int dest = 44;
  23.  
  24.         swapItems(lowestSlot, dest);
  25.         player.getInventory().selectedSlot = 8;
  26.         return true;
  27.     }
  28.  
  29.     private synchronized void swapItems(int from, int to) {
  30.         MainMod.LOGGER.info("Moving stack from {} to {}", from, to);
  31.         interaction.clickSlot(player.currentScreenHandler.syncId, from, 0, SlotActionType.PICKUP, player);
  32.         try {
  33.             Thread.sleep(50);
  34.         } catch (InterruptedException e) {
  35.             e.printStackTrace();
  36.         }
  37.         interaction.clickSlot(player.currentScreenHandler.syncId, to, 0, SlotActionType.PICKUP, player);
  38.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement