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

fix(PacketQueueManager): bad flush on event flush #4784

Merged
merged 1 commit into from
Dec 2, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
*/
package net.ccbluex.liquidbounce.utils.client

import com.google.common.collect.Queues
import net.ccbluex.liquidbounce.event.EventListener
import net.ccbluex.liquidbounce.event.EventManager
import net.ccbluex.liquidbounce.event.events.*
Expand Down Expand Up @@ -56,7 +57,7 @@ import java.util.concurrent.ConcurrentLinkedQueue
*/
object PacketQueueManager : EventListener {

val packetQueue = ConcurrentLinkedQueue<PacketSnapshot>()
val packetQueue: ConcurrentLinkedQueue<PacketSnapshot> = Queues.newConcurrentLinkedQueue()
val positions
get() = packetQueue
.map { snapshot -> snapshot.packet }
Expand Down Expand Up @@ -184,7 +185,7 @@ object PacketQueueManager : EventListener {
}
}

fun flush(flushWhen: (PacketSnapshot) -> Boolean) = mc.renderTaskQueue.add(Runnable {
fun flush(flushWhen: (PacketSnapshot) -> Boolean) {
packetQueue.removeIf { snapshot ->
if (flushWhen(snapshot)) {
flushSnapshot(snapshot)
Expand All @@ -193,9 +194,9 @@ object PacketQueueManager : EventListener {
false
}
}
})
}

fun flush(count: Int) = mc.renderTaskQueue.add(Runnable {
fun flush(count: Int) {
// Take all packets until the counter of move packets reaches count and send them
var counter = 0

Expand All @@ -213,7 +214,7 @@ object PacketQueueManager : EventListener {
break
}
}
})
}

fun cancel() {
positions.firstOrNull().let { pos ->
Expand Down
Loading