SHARE
TWEET

Untitled

a guest Sep 19th, 2019 77 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. public class ModuleAutoSoup
  2.   extends DefaultModule
  3. {
  4.   private boolean shouldSoup = false;
  5.   private MethodInvoker invo = Resilience.getInstance().getInvoker();
  6.   private InventoryUtils invUtils = new InventoryUtils();
  7.  
  8.  
  9.  
  10.   private int prevSlot = -1;
  11.   private int soupId = 282, bowlId = 281;
  12.  
  13.   public ModuleAutoSoup() {
  14.     super("AutoSoup", 24);
  15.     setCategory(ModuleCategory.COMBAT);
  16.     setDescription("Automatically eats soup when health is low. (For KitPvP)");
  17.   }
  18.  
  19.  
  20.   public void onHealthUpdate(EventHealthUpdate e) {
  21.     if (e.getHealth() < (Resilience.getInstance().getValues()).autoSoupHealth.getValue()) {
  22.       this.shouldSoup = true;
  23.     } else {
  24.       this.shouldSoup = false;
  25.     }
  26.   }
  27.  
  28.  
  29.  
  30.   public void onUpdate(EventOnUpdate event) {
  31.     if (this.shouldSoup) {
  32.      
  33.       if (this.prevSlot == -1) {
  34.         this.prevSlot = this.invo.getCurInvSlot();
  35.       }
  36.      
  37.       int slotHotbar = this.invUtils.getSlotOfHotbarItem(this.soupId);
  38.      
  39.       if (slotHotbar != -1) {
  40.         this.invo.setInvSlot(slotHotbar);
  41.         this.invUtils.sendItemUse(this.invo.getItemAtSlot(slotHotbar));
  42.       } else {
  43.         int invSlot = this.invUtils.getSlotOfInvItem(this.soupId);
  44.        
  45.         if (invSlot != -1)
  46.         {
  47.           int freeSlot = this.invUtils.getFreeSlotInInv(this.bowlId);
  48.           int freeHotbarSlot = this.invUtils.getFreeSlotInHotbar(0);
  49.          
  50.           if (freeHotbarSlot != -1) {
  51.             this.invUtils.click(freeSlot, 1);
  52.             this.invUtils.click(invSlot, 1);
  53.           } else {
  54.             int hotBarSlotBad = this.invUtils.getSlotOfHotbarItem(this.bowlId);
  55.            
  56.             if (hotBarSlotBad != -1) {
  57.               this.invo.dropItemStack(hotBarSlotBad);
  58.               this.invUtils.click(invSlot, 1);
  59.               this.invUtils.sendItemUse(this.invo.getItemAtSlot(invSlot));
  60.             }
  61.            
  62.             this.invUtils.click(invSlot, 1);
  63.             this.invUtils.click(freeSlot, 1);
  64.           }
  65.        
  66.         }
  67.      
  68.       }
  69.     } else if (this.prevSlot != -1 && this.invo.getCurInvSlot() != this.prevSlot) {
  70.       this.invo.setInvSlot(this.prevSlot);
  71.       this.prevSlot = -1;
  72.     }
  73.   }
  74.  
  75.  
  76.  
  77.  
  78.   public void onEnable() { Resilience.getInstance().getEventManager().register(this); }
  79.  
  80.  
  81.  
  82.  
  83.   public void onDisable() { Resilience.getInstance().getEventManager().unregister(this); }
  84. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top