Fix weird terminal behavior when inserting multiple equivalent stacks

This commit is contained in:
Shadowfacts 2021-03-03 23:16:31 -05:00
parent 8dbccc541e
commit 385e36918f
Signed by: shadowfacts
GPG Key ID: 94A5AB95422746E5
1 changed files with 4 additions and 4 deletions

View File

@ -29,10 +29,10 @@ interface NetworkStackDispatcher<Insertion: NetworkStackDispatcher.PendingInsert
}
fun handleCapacity(packet: CapacityPacket) {
val insertion = pendingInsertions.firstOrNull {
ItemStackUtil.areEqualIgnoreAmounts(packet.stack, it.stack)
}
if (insertion != null) {
pendingInsertions.firstOrNull { insertion ->
ItemStackUtil.areEqualIgnoreAmounts(packet.stack, insertion.stack) &&
insertion.results.none { it.second.ipAddress == packet.source }
}?.also { insertion ->
insertion.results.add(packet.capacity to packet.stackReceiver)
if (insertion.isFinishable(this)) {
val remaining = finishInsertion(insertion)