Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open chest fails at more than one attempt #74

Open
IParallel opened this issue Aug 11, 2024 · 3 comments
Open

Open chest fails at more than one attempt #74

IParallel opened this issue Aug 11, 2024 · 3 comments

Comments

@IParallel
Copy link

Describe the bug
The bots hangs after X times of opening a chest

To Reproduce
Steps to reproduce the behavior:

  1. Place a chest
  2. Make the bot try and open it and after one attempt or two it will hang forever
  3. See error

i added this code to test the behaviour and it always fail

public async Task<Window> OpenContainer(Block block, int timeoutMs = 10 * 1000)
{
        if (!Bot.Data.Windows.AllowedBlocksToOpen.Contains(block.Info.Type))
        {
            throw new ArgumentException("Cannot open block of type " + block.Info.Name);
        }

        openContainerTsc = new();

        var packet = new PlaceBlockPacket(
            (int)PlayerHand.MainHand,
            block.Position,
            BlockFace.Top,
            0.5f,
            0.5f,
            0.5f,
            false,
            ++Bot.SequenceId);

        _ = Bot.Client.SendPacket(packet);
        _ = playerPlugin?.SwingArm();

        var timeoutTask = Task.Delay(timeoutMs);
        var resultTask = openContainerTsc.Task; // << this hangs

        var completedTask = await Task.WhenAny(resultTask, timeoutTask);

        if (completedTask == timeoutTask)
        {
            openContainerTsc = null;
            throw new TimeoutException("Opening container timed out.");
        }

        openContainerTsc = null;
        return await resultTask;
}
@Klotzi111
Copy link
Contributor

Why did you close this? The problem still occurs, right?

@IParallel
Copy link
Author

oh I think it closed when i closed the pull request, but yes it still occurs

@IParallel IParallel reopened this Aug 18, 2024
@Klotzi111
Copy link
Contributor

Can I see more of your code? Especially the part where openContainerTsc gets completed?
So I can investigate the problem

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants