Search in sources :

Example 1 with MotionUpdateEvent

use of me.earth.earthhack.impl.event.events.network.MotionUpdateEvent in project 3arthh4ck by 3arthqu4ke.

the class ListenerMotion method doObby.

private void doObby(MotionUpdateEvent event, Vec3i[] offsets) {
    if (event.getStage() == Stage.PRE) {
        // TODO: this looks very similar to AutoTrap,
        // maybe its possible to abstract this even further?
        module.rotations = null;
        module.blocksPlaced = 0;
        for (BlockPos confirmed : module.confirmed) {
            module.placed.remove(confirmed);
        }
        module.placed.entrySet().removeIf(entry -> System.currentTimeMillis() - entry.getValue() >= module.confirm.getValue());
        BlockPos playerPos = PositionUtil.getPosition();
        BlockPos[] positions = new BlockPos[offsets.length];
        for (int i = 0; i < offsets.length; i++) {
            Vec3i offset = offsets[i];
            if (module.mode.getValue() == AntiTrapMode.Fill) {
                if (mc.world.getBlockState(playerPos.add(offset.getX() / 2, 0, offset.getZ() / 2)).getBlock() == Blocks.BEDROCK) {
                    continue;
                }
            }
            positions[i] = playerPos.add(offset);
        }
        if (module.offhand.getValue()) {
            if (!InventoryUtil.isHolding(Blocks.OBSIDIAN)) {
                module.previous = OFFHAND.returnIfPresent(Offhand::getMode, null);
                OFFHAND.computeIfPresent(o -> o.setMode(OffhandMode.CRYSTAL));
                return;
            }
        } else {
            module.slot = InventoryUtil.findHotbarBlock(Blocks.OBSIDIAN);
            if (module.slot == -1) {
                ModuleUtil.disable(module, TextColor.RED + "No Obsidian found.");
                return;
            }
        }
        boolean done = true;
        List<BlockPos> toPlace = new LinkedList<>();
        for (BlockPos pos : positions) {
            if (pos == null) {
                continue;
            }
            if (module.mode.getValue() == AntiTrapMode.Fill && !module.highFill.getValue() && pos.getY() > playerPos.getY()) {
                continue;
            }
            if (mc.world.getBlockState(pos).getMaterial().isReplaceable()) {
                toPlace.add(pos);
                done = false;
            }
        }
        if (done) {
            module.disable();
            return;
        }
        boolean hasPlaced = false;
        Optional<BlockPos> crystalPos = toPlace.stream().filter(pos -> !mc.world.getEntitiesWithinAABB(EntityEnderCrystal.class, new AxisAlignedBB(pos)).isEmpty() && mc.world.getBlockState(pos).getMaterial().isReplaceable()).findFirst();
        if (crystalPos.isPresent()) {
            BlockPos pos = crystalPos.get();
            hasPlaced = module.placeBlock(pos);
        }
        // Only after here we need to use the Helper to get the BlockStates.
        if (!hasPlaced) {
            for (BlockPos pos : toPlace) {
                if (!module.placed.containsKey(pos) && HELPER.getBlockState(pos).getMaterial().isReplaceable()) {
                    module.confirmed.remove(pos);
                    if (module.placeBlock(pos)) {
                        break;
                    }
                }
            }
        }
        if (module.rotate.getValue() != Rotate.None) {
            if (module.rotations != null) {
                event.setYaw(module.rotations[0]);
                event.setPitch(module.rotations[1]);
            }
        } else {
            Locks.acquire(Locks.PLACE_SWITCH_LOCK, module::execute);
        }
    } else {
        Locks.acquire(Locks.PLACE_SWITCH_LOCK, module::execute);
    }
}
Also used : RayTraceUtil(me.earth.earthhack.impl.util.math.RayTraceUtil) Blocks(net.minecraft.init.Blocks) EntityEnderCrystal(net.minecraft.entity.item.EntityEnderCrystal) Rotate(me.earth.earthhack.impl.util.helpers.blocks.modes.Rotate) AxisAlignedBB(net.minecraft.util.math.AxisAlignedBB) ModuleCache(me.earth.earthhack.api.cache.ModuleCache) RotationUtil(me.earth.earthhack.impl.util.math.rotation.RotationUtil) BlockUtil(me.earth.earthhack.impl.util.minecraft.blocks.BlockUtil) EnumHand(net.minecraft.util.EnumHand) MotionUpdateEvent(me.earth.earthhack.impl.event.events.network.MotionUpdateEvent) PositionUtil(me.earth.earthhack.impl.util.math.position.PositionUtil) CPacketPlayerTryUseItemOnBlock(net.minecraft.network.play.client.CPacketPlayerTryUseItemOnBlock) Vec3i(net.minecraft.util.math.Vec3i) CPacketAnimation(net.minecraft.network.play.client.CPacketAnimation) Stage(me.earth.earthhack.api.event.events.Stage) AntiTrapMode(me.earth.earthhack.impl.modules.combat.antitrap.util.AntiTrapMode) Caches(me.earth.earthhack.impl.modules.Caches) InventoryUtil(me.earth.earthhack.impl.util.minecraft.InventoryUtil) ModuleUtil(me.earth.earthhack.impl.util.client.ModuleUtil) LinkedList(java.util.LinkedList) HELPER(me.earth.earthhack.impl.util.helpers.blocks.ObbyModule.HELPER) ModuleListener(me.earth.earthhack.impl.event.listeners.ModuleListener) TextColor(me.earth.earthhack.impl.util.text.TextColor) Items(net.minecraft.init.Items) BlockPos(net.minecraft.util.math.BlockPos) OffhandMode(me.earth.earthhack.impl.modules.combat.offhand.modes.OffhandMode) List(java.util.List) Swing(me.earth.earthhack.impl.util.minecraft.Swing) Offhand(me.earth.earthhack.impl.modules.combat.offhand.Offhand) EntityPlayer(net.minecraft.entity.player.EntityPlayer) Optional(java.util.Optional) CPacketPlayer(net.minecraft.network.play.client.CPacketPlayer) Comparator(java.util.Comparator) EntityUtil(me.earth.earthhack.impl.util.minecraft.entity.EntityUtil) Locks(me.earth.earthhack.impl.util.thread.Locks) AxisAlignedBB(net.minecraft.util.math.AxisAlignedBB) Vec3i(net.minecraft.util.math.Vec3i) EntityEnderCrystal(net.minecraft.entity.item.EntityEnderCrystal) BlockPos(net.minecraft.util.math.BlockPos) LinkedList(java.util.LinkedList)

Example 2 with MotionUpdateEvent

use of me.earth.earthhack.impl.event.events.network.MotionUpdateEvent in project 3arthh4ck by 3arthqu4ke.

the class ListenerMotion method invoke.

@Override
public void invoke(MotionUpdateEvent event) {
    if (event.getStage() == Stage.PRE) {
        module.clicked.clear();
        module.blocksPlaced = 0;
        module.rotations = null;
        module.pistonSlot = InventoryUtil.findHotbarBlock(Blocks.PISTON, Blocks.STICKY_PISTON);
        if (module.pistonSlot == -1 && shouldDisable(PistonStage.PISTON)) {
            module.disableWithMessage("<" + module.getDisplayName() + "> " + TextColor.RED + "No Pistons found!");
            return;
        }
        module.redstoneSlot = InventoryUtil.findHotbarBlock(Blocks.REDSTONE_BLOCK, Blocks.REDSTONE_TORCH);
        if (module.redstoneSlot == -1 && shouldDisable(PistonStage.REDSTONE)) {
            module.disableWithMessage("<" + module.getDisplayName() + "> " + TextColor.RED + "No Redstone found!");
            return;
        }
        module.crystalSlot = InventoryUtil.findHotbarItem(Items.END_CRYSTAL);
        if (module.crystalSlot == -1 && shouldDisable(PistonStage.CRYSTAL)) {
            module.disableWithMessage("<" + module.getDisplayName() + "> " + TextColor.RED + "No Crystals found!");
            return;
        }
        if (module.reset && module.nextTimer.passed(module.next.getValue()) && module.current != null) {
            module.current.setValid(false);
        }
        if (module.current == null || !module.current.isValid()) {
            module.current = module.findTarget();
            if (module.current == null || !module.current.isValid()) {
                return;
            }
        }
        module.stage = module.current.getOrder()[module.index];
        while (module.index < 3 && module.stage == null) {
            module.index++;
            module.stage = module.current.getOrder()[module.index];
        }
        while (module.blocksPlaced < module.blocks.getValue()) {
            if (!runPre() || module.rotations != null && module.rotate.getValue() == Rotate.Normal) {
                break;
            }
        }
        if (module.blocksPlaced > 0) {
            module.timer.reset(module.delay.getValue());
        }
        if (module.rotations != null) {
            event.setYaw(module.rotations[0]);
            event.setPitch(module.rotations[1]);
        }
    } else {
        if (module.current == null || !module.current.isValid()) {
            return;
        }
        Locks.acquire(Locks.PLACE_SWITCH_LOCK, () -> {
            module.slot = mc.player.inventory.currentItem;
            boolean sneak = module.blocksPlaced == 0 || module.actions.isEmpty() || module.smartSneak.getValue() && !(Managers.ACTION.isSneaking() || module.clicked.stream().anyMatch(b -> SpecialBlocks.shouldSneak(b, false)));
            if (!sneak) {
                mc.player.connection.sendPacket(new CPacketEntityAction(mc.player, CPacketEntityAction.Action.START_SNEAKING));
            }
            CollectionUtil.emptyQueue(module.actions);
            if (!sneak) {
                mc.player.connection.sendPacket(new CPacketEntityAction(mc.player, CPacketEntityAction.Action.STOP_SNEAKING));
            }
            if (mc.player.inventory.currentItem != module.slot) {
                InventoryUtil.switchTo(module.slot);
            }
        });
    }
}
Also used : RayTraceUtil(me.earth.earthhack.impl.util.math.RayTraceUtil) Blocks(net.minecraft.init.Blocks) Managers(me.earth.earthhack.impl.managers.Managers) EntityEnderCrystal(net.minecraft.entity.item.EntityEnderCrystal) Rotate(me.earth.earthhack.impl.util.helpers.blocks.modes.Rotate) CPacketUseEntity(net.minecraft.network.play.client.CPacketUseEntity) AxisAlignedBB(net.minecraft.util.math.AxisAlignedBB) ModuleCache(me.earth.earthhack.api.cache.ModuleCache) RotationUtil(me.earth.earthhack.impl.util.math.rotation.RotationUtil) BlockUtil(me.earth.earthhack.impl.util.minecraft.blocks.BlockUtil) EnumHand(net.minecraft.util.EnumHand) MotionUpdateEvent(me.earth.earthhack.impl.event.events.network.MotionUpdateEvent) SpecialBlocks(me.earth.earthhack.impl.util.minecraft.blocks.SpecialBlocks) ItemStack(net.minecraft.item.ItemStack) RayTraceResult(net.minecraft.util.math.RayTraceResult) CPacketPlayerTryUseItemOnBlock(net.minecraft.network.play.client.CPacketPlayerTryUseItemOnBlock) Vec3d(net.minecraft.util.math.Vec3d) CPacketAnimation(net.minecraft.network.play.client.CPacketAnimation) Stage(me.earth.earthhack.api.event.events.Stage) Caches(me.earth.earthhack.impl.modules.Caches) InventoryUtil(me.earth.earthhack.impl.util.minecraft.InventoryUtil) PistonStage(me.earth.earthhack.impl.modules.combat.pistonaura.util.PistonStage) ModuleListener(me.earth.earthhack.impl.event.listeners.ModuleListener) Entity(net.minecraft.entity.Entity) TextColor(me.earth.earthhack.impl.util.text.TextColor) Items(net.minecraft.init.Items) CollectionUtil(me.earth.earthhack.impl.util.misc.collections.CollectionUtil) EnumFacing(net.minecraft.util.EnumFacing) BlockPos(net.minecraft.util.math.BlockPos) NoGlitchBlocks(me.earth.earthhack.impl.modules.player.noglitchblocks.NoGlitchBlocks) Swing(me.earth.earthhack.impl.util.minecraft.Swing) CPacketEntityAction(net.minecraft.network.play.client.CPacketEntityAction) CPacketPlayer(net.minecraft.network.play.client.CPacketPlayer) EntityUtil(me.earth.earthhack.impl.util.minecraft.entity.EntityUtil) Locks(me.earth.earthhack.impl.util.thread.Locks) CPacketEntityAction(net.minecraft.network.play.client.CPacketEntityAction)

Example 3 with MotionUpdateEvent

use of me.earth.earthhack.impl.event.events.network.MotionUpdateEvent in project 3arthh4ck by 3arthqu4ke.

the class ListenerMotion method invoke.

@Override
public void invoke(MotionUpdateEvent event) {
    if (event.getStage() == Stage.PRE) {
    } else {
    }
    if (module.steal.getValue() && mc.currentScreen == null && !module.shouldRegear) {
        BlockPos craftingPos = module.getShulkerBox();
        float[] rotations = RotationUtil.getRotations(craftingPos, EnumFacing.UP);
        RayTraceResult ray = RotationUtil.rayTraceTo(craftingPos, mc.world);
        float[] f = RayTraceUtil.hitVecToPlaceVec(craftingPos, ray.hitVec);
        if (module.rotate.getValue() == Rotate.Normal) {
            event.setYaw(rotations[0]);
            event.setPitch(rotations[1]);
        } else if (module.rotate.getValue() != Rotate.None) {
            PacketUtil.doRotation(rotations[0], rotations[1], mc.player.onGround);
        }
        NetworkUtil.send(new CPacketPlayerTryUseItemOnBlock(craftingPos, ray.sideHit, EnumHand.MAIN_HAND, f[0], f[1], f[2]));
        return;
    }
    if (module.shouldRegear && mc.currentScreen == null) {
        BlockPos optimal = module.getOptimalPlacePos(false);
        int slot;
        boolean swapped = false;
        if (module.placeEchest.getValue() && module.getBlock(Blocks.ENDER_CHEST) == null && InventoryUtil.findHotbarBlock(Blocks.ENDER_CHEST) != -1 && !module.hasKit() && optimal != null) {
            slot = InventoryUtil.findHotbarBlock(Blocks.ENDER_CHEST);
            if (slot == -1)
                return;
            module.slot = slot;
            EnumFacing facing = BlockUtil.getFacing(optimal);
            module.placeBlock(optimal.offset(facing), facing.getOpposite());
            if (module.rotate.getValue() == Rotate.Normal && module.rotations != null) {
                event.setYaw(module.rotations[0]);
                event.setPitch(module.rotations[1]);
            }
            module.execute();
            return;
        }
        if (module.grabShulker.getValue() && module.getBlock(Blocks.ENDER_CHEST) != null && module.getShulkerBox() == null && mc.currentScreen == null && !module.hasKit()) {
            BlockPos craftingPos = module.getBlock(Blocks.ENDER_CHEST);
            float[] rotations = RotationUtil.getRotations(craftingPos, EnumFacing.UP);
            RayTraceResult ray = RotationUtil.rayTraceTo(craftingPos, mc.world);
            float[] f = RayTraceUtil.hitVecToPlaceVec(craftingPos, ray.hitVec);
            if (module.rotate.getValue() == Rotate.Normal) {
                event.setYaw(rotations[0]);
                event.setPitch(rotations[1]);
            } else if (module.rotate.getValue() != Rotate.None) {
                PacketUtil.doRotation(rotations[0], rotations[1], mc.player.onGround);
            }
            NetworkUtil.send(new CPacketPlayerTryUseItemOnBlock(craftingPos, ray.sideHit, EnumHand.MAIN_HAND, f[0], f[1], f[2]));
            return;
        }
        if (module.placeShulker.getValue() && module.getShulkerBox() == null && module.hasKit() && optimal != null) {
            optimal = module.getOptimalPlacePos(true);
            if (optimal == null)
                return;
            slot = InventoryUtil.findInHotbar(stack -> stack.getItem() instanceof ItemBlock && ((ItemBlock) stack.getItem()).getBlock() instanceof BlockShulkerBox);
            int inventorySlot = InventoryUtil.findInInventory(stack -> stack.getItem() instanceof ItemBlock && ((ItemBlock) stack.getItem()).getBlock() instanceof BlockShulkerBox, true);
            if (slot == -1) {
                if (inventorySlot == -1)
                    return;
                slot = InventoryUtil.hotbarToInventory(8);
                mc.playerController.windowClick(0, inventorySlot, 0, ClickType.PICKUP, mc.player);
                mc.playerController.windowClick(0, slot, 0, ClickType.PICKUP, mc.player);
                mc.playerController.windowClick(0, inventorySlot, 0, ClickType.PICKUP, mc.player);
                swapped = true;
            }
            module.slot = slot;
            EnumFacing facing = EnumFacing.DOWN;
            module.placeBlock(optimal.offset(facing), facing.getOpposite());
            if (module.rotate.getValue() == Rotate.Normal && module.rotations != null) {
                event.setYaw(module.rotations[0]);
                event.setPitch(module.rotations[1]);
            }
            module.execute();
            if (swapped) {
                mc.playerController.windowClick(0, inventorySlot, 0, ClickType.PICKUP, mc.player);
                mc.playerController.windowClick(0, slot, 0, ClickType.PICKUP, mc.player);
                mc.playerController.windowClick(0, inventorySlot, 0, ClickType.PICKUP, mc.player);
            }
            return;
        }
        BlockPos craftingPos = module.getShulkerBox();
        if (craftingPos == null)
            return;
        float[] rotations = RotationUtil.getRotations(craftingPos, EnumFacing.UP);
        RayTraceResult ray = RotationUtil.rayTraceTo(craftingPos, mc.world);
        float[] f = RayTraceUtil.hitVecToPlaceVec(craftingPos, ray.hitVec);
        if (module.rotate.getValue() == Rotate.Normal) {
            event.setYaw(rotations[0]);
            event.setPitch(rotations[1]);
        } else if (module.rotate.getValue() != Rotate.None) {
            PacketUtil.doRotation(rotations[0], rotations[1], mc.player.onGround);
        }
        NetworkUtil.send(new CPacketPlayerTryUseItemOnBlock(craftingPos, ray.sideHit, EnumHand.MAIN_HAND, f[0], f[1], f[2]));
        module.shouldRegear = false;
    }
}
Also used : ModuleListener(me.earth.earthhack.impl.event.listeners.ModuleListener) PacketUtil(me.earth.earthhack.impl.util.network.PacketUtil) RayTraceUtil(me.earth.earthhack.impl.util.math.RayTraceUtil) Blocks(net.minecraft.init.Blocks) Rotate(me.earth.earthhack.impl.util.helpers.blocks.modes.Rotate) RotationUtil(me.earth.earthhack.impl.util.math.rotation.RotationUtil) BlockUtil(me.earth.earthhack.impl.util.minecraft.blocks.BlockUtil) EnumHand(net.minecraft.util.EnumHand) EnumFacing(net.minecraft.util.EnumFacing) BlockShulkerBox(net.minecraft.block.BlockShulkerBox) BlockPos(net.minecraft.util.math.BlockPos) MotionUpdateEvent(me.earth.earthhack.impl.event.events.network.MotionUpdateEvent) NetworkUtil(me.earth.earthhack.impl.util.network.NetworkUtil) RayTraceResult(net.minecraft.util.math.RayTraceResult) CPacketPlayerTryUseItemOnBlock(net.minecraft.network.play.client.CPacketPlayerTryUseItemOnBlock) Stage(me.earth.earthhack.api.event.events.Stage) InventoryUtil(me.earth.earthhack.impl.util.minecraft.InventoryUtil) ItemBlock(net.minecraft.item.ItemBlock) ClickType(net.minecraft.inventory.ClickType) BlockShulkerBox(net.minecraft.block.BlockShulkerBox) EnumFacing(net.minecraft.util.EnumFacing) RayTraceResult(net.minecraft.util.math.RayTraceResult) BlockPos(net.minecraft.util.math.BlockPos) ItemBlock(net.minecraft.item.ItemBlock) CPacketPlayerTryUseItemOnBlock(net.minecraft.network.play.client.CPacketPlayerTryUseItemOnBlock)

Example 4 with MotionUpdateEvent

use of me.earth.earthhack.impl.event.events.network.MotionUpdateEvent in project 3arthh4ck by 3arthqu4ke.

the class ListenerMotion method start.

public static void start(Surround module, MotionUpdateEvent event) {
    module.rotations = null;
    module.attacking = null;
    module.blocksPlaced = 0;
    module.center();
    if (module.updatePosAndBlocks()) {
        // confirmed blocks can now be checked for blockstate changes.
        module.placed.removeAll(module.confirmed);
        boolean hasPlaced = false;
        // ensure that we attack the pos with the crystal first before
        // the others, so we dont have to deal with switchcooldown.
        Optional<BlockPos> crystalPos = module.targets.stream().filter(pos -> !mc.world.getEntitiesWithinAABB(EntityEnderCrystal.class, new AxisAlignedBB(pos)).isEmpty() && mc.world.getBlockState(pos).getMaterial().isReplaceable()).findFirst();
        if (crystalPos.isPresent()) {
            BlockPos pos = crystalPos.get();
            module.confirmed.remove(pos);
            hasPlaced = module.placeBlock(pos);
        }
        if (!hasPlaced || !module.crystalCheck.getValue()) {
            List<BlockPos> surrounding = new ArrayList<>(module.targets);
            if (module.getPlayer().motionX != 0.0 || module.getPlayer().motionZ != 0.0) {
                // place in front of us first to stop our movement.
                // I am aware that this looks really bad
                BlockPos pos = new BlockPos(module.getPlayer()).add(module.getPlayer().motionX * 10000, 0, module.getPlayer().motionZ * 10000);
                surrounding.sort(Comparator.comparingDouble(p -> p.distanceSq(pos.getX() + 0.5, pos.getY(), pos.getZ() + 0.5)));
            }
            for (BlockPos pos : surrounding) {
                if (!module.placed.contains(pos) && mc.world.getBlockState(pos).getMaterial().isReplaceable()) {
                    module.confirmed.remove(pos);
                    if (module.placeBlock(pos)) {
                        break;
                    }
                }
            }
        }
    }
    if (module.blocksPlaced == 0) {
        module.placed.clear();
    }
    if (module.rotate.getValue() != Rotate.None) {
        if (module.rotations != null) {
            Managers.ROTATION.setBlocking(true);
            event.setYaw(module.rotations[0]);
            event.setPitch(module.rotations[1]);
            if (Surround.FREECAM.isEnabled()) {
                Surround.FREECAM.get().rotate(module.rotations[0], module.rotations[1]);
            }
        }
    } else if (module.setPosition) {
        // if we dont need to rotate and are centered, send immediately.
        Locks.acquire(Locks.PLACE_SWITCH_LOCK, module::execute);
    }
}
Also used : ModuleListener(me.earth.earthhack.impl.event.listeners.ModuleListener) Managers(me.earth.earthhack.impl.managers.Managers) EntityEnderCrystal(net.minecraft.entity.item.EntityEnderCrystal) Rotate(me.earth.earthhack.impl.util.helpers.blocks.modes.Rotate) AxisAlignedBB(net.minecraft.util.math.AxisAlignedBB) BlockPos(net.minecraft.util.math.BlockPos) MotionUpdateEvent(me.earth.earthhack.impl.event.events.network.MotionUpdateEvent) ArrayList(java.util.ArrayList) List(java.util.List) Stage(me.earth.earthhack.api.event.events.Stage) Optional(java.util.Optional) Comparator(java.util.Comparator) Locks(me.earth.earthhack.impl.util.thread.Locks) AxisAlignedBB(net.minecraft.util.math.AxisAlignedBB) EntityEnderCrystal(net.minecraft.entity.item.EntityEnderCrystal) ArrayList(java.util.ArrayList) BlockPos(net.minecraft.util.math.BlockPos)

Example 5 with MotionUpdateEvent

use of me.earth.earthhack.impl.event.events.network.MotionUpdateEvent 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)

Aggregations

MotionUpdateEvent (me.earth.earthhack.impl.event.events.network.MotionUpdateEvent)9 Stage (me.earth.earthhack.api.event.events.Stage)6 ModuleListener (me.earth.earthhack.impl.event.listeners.ModuleListener)6 BlockPos (net.minecraft.util.math.BlockPos)6 Rotate (me.earth.earthhack.impl.util.helpers.blocks.modes.Rotate)5 RotationUtil (me.earth.earthhack.impl.util.math.rotation.RotationUtil)5 InventoryUtil (me.earth.earthhack.impl.util.minecraft.InventoryUtil)5 Locks (me.earth.earthhack.impl.util.thread.Locks)5 List (java.util.List)4 ModuleCache (me.earth.earthhack.api.cache.ModuleCache)4 Caches (me.earth.earthhack.impl.modules.Caches)4 RayTraceUtil (me.earth.earthhack.impl.util.math.RayTraceUtil)4 BlockUtil (me.earth.earthhack.impl.util.minecraft.blocks.BlockUtil)4 EntityEnderCrystal (net.minecraft.entity.item.EntityEnderCrystal)4 Items (net.minecraft.init.Items)4 AxisAlignedBB (net.minecraft.util.math.AxisAlignedBB)4 Comparator (java.util.Comparator)3 Optional (java.util.Optional)3 Managers (me.earth.earthhack.impl.managers.Managers)3 PositionUtil (me.earth.earthhack.impl.util.math.position.PositionUtil)3