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

[BUG] Sequences break when waiting for ticks on the first execution #1731

Closed
superblaubeere27 opened this issue Dec 23, 2023 · 2 comments · Fixed by #2013
Closed

[BUG] Sequences break when waiting for ticks on the first execution #1731

superblaubeere27 opened this issue Dec 23, 2023 · 2 comments · Fixed by #2013
Labels
🐛 bug Something isn't working 👷 development build development build issue 🌑 nextgen
Milestone

Comments

@superblaubeere27
Copy link
Contributor

superblaubeere27 commented Dec 23, 2023

LiquidBounce Branch

Nextgen

LiquidBounce Build/Version

latest

Operating System

macOS, Linux, Windows 7, Windows 8, Windows 8.1, Windows 10, Windows 11

Minecraft Version

1.20.X

Describe the bug

If a subroutine waits for n ticks on the first execution, it will only wait until the next tick.

someSequence {
    // This code would run immediately

    waitTicks(5)

    // This code runs after only one tick (<- BUG)

    waitTicks(5)

    // This code runs after five ticks (Correct)
}

Steps to reproduce

This unit test found the bug:

    @Test
    fun testWaitTicksBug() {
        var nTimesRan = 0

        val seq = CommonTestSequence(sequenceManager) {
            nTimesRan += 1

            waitTicks(5)

            nTimesRan += 1
        }

        for (i in 0 until 5) {
            assertEquals(1, nTimesRan)

            seq.onTick()
        }

        assertEquals(2, nTimesRan)
    }

Client Log

-

Screenshots

No response

@github-actions github-actions bot added 🌑 nextgen 🐛 bug Something isn't working 👷 development build development build issue labels Dec 23, 2023
@superblaubeere27 superblaubeere27 changed the title [BUG] Sequence break when waiting for ticks on the first execution [BUG] Sequences break when waiting for ticks on the first execution Dec 23, 2023
@superblaubeere27 superblaubeere27 added this to the 1.0.0 milestone Dec 23, 2023
@Ell1ott
Copy link
Contributor

Ell1ott commented Dec 23, 2023

You can fix it by using sync() before you wait for the first time. This is not optimally tho

@superblaubeere27
Copy link
Contributor Author

You can fix it by using sync() before you wait for the first time. This is not optimally tho

I already have a real fix for it, dw. The bug is caused by the ordering of the constructor and fields not being ideal.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 bug Something isn't working 👷 development build development build issue 🌑 nextgen
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants