Compare commits

..

2 Commits

2 changed files with 8 additions and 8 deletions

View File

@ -161,11 +161,12 @@ class TerminalBlockEntity: DeviceBlockEntity(PhyBlockEntities.TERMINAL),
private fun finishPendingRequests() { private fun finishPendingRequests() {
if (world!!.isClient) return if (world!!.isClient) return
if (pendingRequests.isEmpty()) return
val finishable = pendingRequests.filter { it.isFinishable(counter) } for (request in pendingRequests) {
finishable.forEach(::stackLocateRequestCompleted) if (request.isFinishable(counter)) {
pendingRequests.removeAll(finishable) stackLocateRequestCompleted(request)
}
}
} }
fun addObserver() { fun addObserver() {

View File

@ -72,10 +72,9 @@ interface NetworkStackDispatcher<Insertion: NetworkStackDispatcher.PendingInsert
fun <Self, Insertion: NetworkStackDispatcher.PendingInsertion<Insertion>> Self.finishTimedOutPendingInsertions() where Self: BlockEntity, Self: NetworkStackDispatcher<Insertion> { fun <Self, Insertion: NetworkStackDispatcher.PendingInsertion<Insertion>> Self.finishTimedOutPendingInsertions() where Self: BlockEntity, Self: NetworkStackDispatcher<Insertion> {
if (world!!.isClient) return if (world!!.isClient) return
if (pendingInsertions.isEmpty()) return
val finishable = pendingInsertions.filter { it.isFinishable(this) } pendingInsertions
finishable.forEach(::finishInsertion) .filter { it.isFinishable(this) }
pendingInsertions.removeAll(finishable) .forEach(::finishInsertion)
// todo: if a timed-out insertion can't be finished, we should probably retry after some time (exponential backoff?) // todo: if a timed-out insertion can't be finished, we should probably retry after some time (exponential backoff?)
} }