Skip to content

Commit 9b18907

Browse files
committed
clean up break handling in the build task
1 parent 199e42a commit 9b18907

File tree

1 file changed

+11
-15
lines changed

1 file changed

+11
-15
lines changed

common/src/main/kotlin/com/lambda/task/tasks/BuildTask.kt

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ import com.lambda.interaction.construction.blueprint.Blueprint.Companion.toStruc
3030
import com.lambda.interaction.construction.blueprint.PropagatingBlueprint
3131
import com.lambda.interaction.construction.blueprint.StaticBlueprint.Companion.toBlueprint
3232
import com.lambda.interaction.construction.blueprint.TickingBlueprint
33+
import com.lambda.interaction.construction.context.BreakContext
3334
import com.lambda.interaction.construction.context.BuildContext
3435
import com.lambda.interaction.construction.result.BreakResult
3536
import com.lambda.interaction.construction.result.BuildResult
@@ -139,32 +140,27 @@ class BuildTask @Ta5kBuilder constructor(
139140
if (atMaxPendingInteractions) return@listen
140141
when (bestResult) {
141142
is BreakResult.Break -> {
142-
val breakResults = resultsNotBlocked
143-
.filterIsInstance<BreakResult.Break>()
143+
val breakResults = resultsNotBlocked.filterIsInstance<BreakResult.Break>()
144+
val requestContexts = arrayListOf<BreakContext>()
144145

145146
if (build.breakSettings.instantBreaksPerTick > 1) {
146147
val takeCount = build.breakSettings
147148
.instantBreaksPerTick
148149
.coerceAtMost(emptyPendingInteractionSlots)
149-
val instantBreakResults = breakResults
150+
breakResults
150151
.filter { it.context.instantBreak }
151152
.take(takeCount)
153+
.let { instantBreakResults ->
154+
requestContexts.addAll(instantBreakResults.map { it.context })
155+
}
156+
}
152157

153-
if (instantBreakResults.isNotEmpty()) {
154-
build.breakSettings.request(
155-
BreakRequest(
156-
instantBreakResults.map { it.context }, build, rotation, interact, inventory, hotbar,
157-
pendingInteractionsList = pendingInteractions,
158-
onBreak = { breaks++ },
159-
onItemDrop = onItemDrop
160-
)
161-
)
162-
return@listen
163-
}
158+
if (requestContexts.isEmpty()) {
159+
requestContexts.addAll(breakResults.map { it.context })
164160
}
165161

166162
val request = BreakRequest(
167-
breakResults.map { it.context }, build, rotation, interact, inventory, hotbar,
163+
requestContexts, build, rotation, interact, inventory, hotbar,
168164
pendingInteractionsList = pendingInteractions,
169165
onBreak = { breaks++ },
170166
onItemDrop = onItemDrop

0 commit comments

Comments
 (0)