Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class ModuleAutoSoup
- extends DefaultModule
- {
- private boolean shouldSoup = false;
- private MethodInvoker invo = Resilience.getInstance().getInvoker();
- private InventoryUtils invUtils = new InventoryUtils();
- private int prevSlot = -1;
- private int soupId = 282, bowlId = 281;
- public ModuleAutoSoup() {
- super("AutoSoup", 24);
- setCategory(ModuleCategory.COMBAT);
- setDescription("Automatically eats soup when health is low. (For KitPvP)");
- }
- public void onHealthUpdate(EventHealthUpdate e) {
- if (e.getHealth() < (Resilience.getInstance().getValues()).autoSoupHealth.getValue()) {
- this.shouldSoup = true;
- } else {
- this.shouldSoup = false;
- }
- }
- public void onUpdate(EventOnUpdate event) {
- if (this.shouldSoup) {
- if (this.prevSlot == -1) {
- this.prevSlot = this.invo.getCurInvSlot();
- }
- int slotHotbar = this.invUtils.getSlotOfHotbarItem(this.soupId);
- if (slotHotbar != -1) {
- this.invo.setInvSlot(slotHotbar);
- this.invUtils.sendItemUse(this.invo.getItemAtSlot(slotHotbar));
- } else {
- int invSlot = this.invUtils.getSlotOfInvItem(this.soupId);
- if (invSlot != -1)
- {
- int freeSlot = this.invUtils.getFreeSlotInInv(this.bowlId);
- int freeHotbarSlot = this.invUtils.getFreeSlotInHotbar(0);
- if (freeHotbarSlot != -1) {
- this.invUtils.click(freeSlot, 1);
- this.invUtils.click(invSlot, 1);
- } else {
- int hotBarSlotBad = this.invUtils.getSlotOfHotbarItem(this.bowlId);
- if (hotBarSlotBad != -1) {
- this.invo.dropItemStack(hotBarSlotBad);
- this.invUtils.click(invSlot, 1);
- this.invUtils.sendItemUse(this.invo.getItemAtSlot(invSlot));
- }
- this.invUtils.click(invSlot, 1);
- this.invUtils.click(freeSlot, 1);
- }
- }
- }
- } else if (this.prevSlot != -1 && this.invo.getCurInvSlot() != this.prevSlot) {
- this.invo.setInvSlot(this.prevSlot);
- this.prevSlot = -1;
- }
- }
- public void onEnable() { Resilience.getInstance().getEventManager().register(this); }
- public void onDisable() { Resilience.getInstance().getEventManager().unregister(this); }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement