Search in sources :

Example 1 with WindowClick

use of me.earth.earthhack.impl.modules.combat.autoarmor.util.WindowClick in project 3arthh4ck by 3arthqu4ke.

the class ListenerMotion method invoke.

@Override
public void invoke(MotionUpdateEvent event) {
    if (module.action == null && !module.timer.passed(module.delay.getValue()) || !Managers.NCP.getClickTimer().passed(module.globalDelay.getValue()) || mc.player.isCreative() || !InventoryUtil.validScreen() || AUTO_ARMOR.returnIfPresent(AutoArmor::isActive, false) || !module.inInventory.getValue() && mc.currentScreen instanceof GuiInventory || !module.cleanInLoot.getValue() && !mc.world.getEntitiesWithinAABB(EntityItem.class, RotationUtil.getRotationPlayer().getEntityBoundingBox()).isEmpty() && (!module.cleanWithFull.getValue() || !isInvFull())) {
        return;
    }
    if (event.getStage() == Stage.PRE) {
        // TODO: use invalidate thingy to only calc when necessary?
        if (module.stack.getValue() && stack() || module.xCarry.getValue() && doXCarry()) {
            return;
        }
        Map<Item, ItemToDrop> items = new HashMap<>();
        boolean prio = module.prioHotbar.getValue();
        Item drag = null;
        ItemStack draggedStack = mc.player.inventory.getItemStack();
        if (check(draggedStack, -2, items)) {
            drag = draggedStack.getItem();
        } else if (!draggedStack.isEmpty()) {
            return;
        }
        for (int i = prio ? 44 : 9; prio ? i > 8 : i <= 44; // noinspection ConstantConditions (??? am i stupid ???)
        i = (prio ? --i : ++i)) {
            ItemStack stack = InventoryUtil.get(i);
            check(stack, i, items);
        }
        WindowClick action = null;
        if (drag != null) {
            ItemToDrop dragged = items.get(drag);
            if (dragged != null && dragged.shouldDrop()) {
                action = new WindowClick(-999, ItemStack.EMPTY, mc.player.inventory.getItemStack());
            }
        } else {
            for (ItemToDrop toDrop : items.values()) {
                if (toDrop.shouldDrop()) {
                    int s = toDrop.getSlot();
                    action = new WindowClick(-1, ItemStack.EMPTY, s, InventoryUtil.get(s), -1, p -> p.windowClick(0, s, 1, ClickType.THROW, mc.player));
                    break;
                }
            }
        }
        if (action != null) {
            if (module.rotate.getValue()) {
                if (MovementUtil.isMoving()) {
                    // behind us
                    event.setYaw(event.getYaw() - 180.0f);
                } else {
                    event.setYaw(getYaw(event.getYaw()));
                }
                // slightly up so we throw further
                event.setPitch(-5.0f);
                module.action = action;
            } else {
                module.action = action;
                module.runAction();
            }
        }
    } else {
        module.runAction();
    }
}
Also used : WindowClick(me.earth.earthhack.impl.modules.combat.autoarmor.util.WindowClick) Managers(me.earth.earthhack.impl.managers.Managers) Item(net.minecraft.item.Item) ModuleCache(me.earth.earthhack.api.cache.ModuleCache) RotationUtil(me.earth.earthhack.impl.util.math.rotation.RotationUtil) Setting(me.earth.earthhack.api.setting.Setting) HashMap(java.util.HashMap) MotionUpdateEvent(me.earth.earthhack.impl.event.events.network.MotionUpdateEvent) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) ItemStack(net.minecraft.item.ItemStack) PositionUtil(me.earth.earthhack.impl.util.math.position.PositionUtil) Stage(me.earth.earthhack.api.event.events.Stage) Map(java.util.Map) Caches(me.earth.earthhack.impl.modules.Caches) InventoryUtil(me.earth.earthhack.impl.util.minecraft.InventoryUtil) AutoArmor(me.earth.earthhack.impl.modules.combat.autoarmor.AutoArmor) ModuleListener(me.earth.earthhack.impl.event.listeners.ModuleListener) EntityItem(net.minecraft.entity.item.EntityItem) GuiInventory(net.minecraft.client.gui.inventory.GuiInventory) Items(net.minecraft.init.Items) CollectionUtil(me.earth.earthhack.impl.util.misc.collections.CollectionUtil) EnumFacing(net.minecraft.util.EnumFacing) Set(java.util.Set) BlockPos(net.minecraft.util.math.BlockPos) AbstractMap(java.util.AbstractMap) List(java.util.List) TreeMap(java.util.TreeMap) MovementUtil(me.earth.earthhack.impl.util.minecraft.MovementUtil) ClickType(net.minecraft.inventory.ClickType) Locks(me.earth.earthhack.impl.util.thread.Locks) Item(net.minecraft.item.Item) EntityItem(net.minecraft.entity.item.EntityItem) WindowClick(me.earth.earthhack.impl.modules.combat.autoarmor.util.WindowClick) HashMap(java.util.HashMap) ItemStack(net.minecraft.item.ItemStack) GuiInventory(net.minecraft.client.gui.inventory.GuiInventory) EntityItem(net.minecraft.entity.item.EntityItem)

Example 2 with WindowClick

use of me.earth.earthhack.impl.modules.combat.autoarmor.util.WindowClick in project 3arthh4ck by 3arthqu4ke.

the class AutoArmor method runClick.

/**
 * Polls and runs the first WindowClick from the
 * queued clicks if the timer has passed
 * the delay.
 */
protected void runClick() {
    if (InventoryUtil.validScreen() && mc.playerController != null) {
        if (timer.passed(delay.getValue())) {
            Locks.acquire(Locks.WINDOW_CLICK_LOCK, () -> {
                Managers.NCP.startMultiClick();
                WindowClick windowClick = windowClicks.poll();
                while (windowClick != null) {
                    if (safe.getValue() && !windowClick.isValid()) {
                        windowClicks.clear();
                        queuedSlots.clear();
                        Managers.NCP.releaseMultiClick();
                        return;
                    }
                    windowClick.runClick(mc.playerController);
                    desyncMap.put(windowClick.getSlot(), new DesyncClick(windowClick));
                    timer.reset(delay.getValue());
                    if (!windowClick.isDoubleClick()) {
                        Managers.NCP.releaseMultiClick();
                        return;
                    }
                    windowClick = windowClicks.poll();
                }
            });
        }
    } else {
        windowClicks.clear();
        queuedSlots.clear();
    }
}
Also used : WindowClick(me.earth.earthhack.impl.modules.combat.autoarmor.util.WindowClick) DesyncClick(me.earth.earthhack.impl.modules.combat.autoarmor.util.DesyncClick)

Example 3 with WindowClick

use of me.earth.earthhack.impl.modules.combat.autoarmor.util.WindowClick in project 3arthh4ck by 3arthqu4ke.

the class AutoArmor method queueClick.

/**
 * Creates a new {@link WindowClick} for the given parameters,
 * queues it via {@link AutoArmor#queueClick(WindowClick)} and
 * returns it.
 */
public WindowClick queueClick(int slot, ItemStack inSlot, ItemStack inDrag, int target) {
    WindowClick click = new WindowClick(slot, inSlot, inDrag, target);
    queueClick(click);
    click.setFast(fast.getValue());
    return click;
}
Also used : WindowClick(me.earth.earthhack.impl.modules.combat.autoarmor.util.WindowClick)

Aggregations

WindowClick (me.earth.earthhack.impl.modules.combat.autoarmor.util.WindowClick)3 AbstractMap (java.util.AbstractMap)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 List (java.util.List)1 Map (java.util.Map)1 Set (java.util.Set)1 TreeMap (java.util.TreeMap)1 ModuleCache (me.earth.earthhack.api.cache.ModuleCache)1 Stage (me.earth.earthhack.api.event.events.Stage)1 Setting (me.earth.earthhack.api.setting.Setting)1 MotionUpdateEvent (me.earth.earthhack.impl.event.events.network.MotionUpdateEvent)1 ModuleListener (me.earth.earthhack.impl.event.listeners.ModuleListener)1 Managers (me.earth.earthhack.impl.managers.Managers)1 Caches (me.earth.earthhack.impl.modules.Caches)1 AutoArmor (me.earth.earthhack.impl.modules.combat.autoarmor.AutoArmor)1 DesyncClick (me.earth.earthhack.impl.modules.combat.autoarmor.util.DesyncClick)1 PositionUtil (me.earth.earthhack.impl.util.math.position.PositionUtil)1 RotationUtil (me.earth.earthhack.impl.util.math.rotation.RotationUtil)1