Skip to content

Commit 8a89f7c

Browse files
committed
onItemBreak variable
1 parent a4f8d60 commit 8a89f7c

File tree

3 files changed

+14
-8
lines changed

3 files changed

+14
-8
lines changed

common/src/main/kotlin/com/lambda/interaction/request/breaking/BreakManager.kt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,6 @@ object BreakManager : RequestHandler<BreakRequest>(), PositionBlocking {
187187
postEvent()
188188
}
189189

190-
//ToDo: Clean this up
191190
listen<WorldEvent.BlockUpdate.Server> { event ->
192191
pendingInteractions
193192
.firstOrNull { it.context.expectedPos == event.pos }
@@ -265,7 +264,7 @@ object BreakManager : RequestHandler<BreakRequest>(), PositionBlocking {
265264
rotationConfig: RotationConfig,
266265
hotbarConfig: HotbarConfig,
267266
onBreak: () -> Unit,
268-
onItemDrop: (ItemEntity) -> Unit
267+
onItemDrop: ((ItemEntity) -> Unit)?
269268
): BreakInfo? {
270269
val breakInfo = BreakInfo(requestCtx, BreakType.Primary,
271270
buildConfig.breakSettings, rotationConfig, hotbarConfig,
@@ -503,7 +502,7 @@ object BreakManager : RequestHandler<BreakRequest>(), PositionBlocking {
503502
val rotationConfig: RotationConfig,
504503
val hotbarConfig: HotbarConfig,
505504
val onBreak: () -> Unit,
506-
val onItemDrop: (ItemEntity) -> Unit
505+
val onItemDrop: ((ItemEntity) -> Unit)?
507506
) {
508507
var breaking = false
509508
var breakingTicks = 0

common/src/main/kotlin/com/lambda/interaction/request/breaking/BreakRequest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ data class BreakRequest(
3434
val hotbarConfig: HotbarConfig,
3535
val prio: Priority = 0,
3636
val onBreak: () -> Unit,
37-
val onItemDrop: (ItemEntity) -> Unit,
37+
val onItemDrop: ((ItemEntity) -> Unit)?,
3838
) : Request(prio) {
3939
override val done: Boolean
4040
get() = runSafe {

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

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,11 @@ class BuildTask @Ta5kBuilder constructor(
8080
private val dropsToCollect = mutableSetOf<ItemEntity>()
8181
// private var goodPositions = setOf<BlockPos>()
8282

83+
private val onItemDrop: ((item: ItemEntity) -> Unit)?
84+
get() = if (collectDrops) {
85+
item -> dropsToCollect.add(item)
86+
} else null
87+
8388
override fun SafeContext.onStart() {
8489
(blueprint as? PropagatingBlueprint)?.next()
8590
}
@@ -122,8 +127,9 @@ class BuildTask @Ta5kBuilder constructor(
122127
build.breakSettings.request(
123128
BreakRequest(
124129
instantResults.map { it.context }, build, rotation, hotbar,
125-
onBreak = { breaks++ }
126-
) { item -> if (collectDrops) dropsToCollect.add(item) }
130+
onBreak = { breaks++ },
131+
onItemDrop = onItemDrop
132+
)
127133
)
128134
return@onRotate
129135
}
@@ -168,8 +174,9 @@ class BuildTask @Ta5kBuilder constructor(
168174

169175
val request = BreakRequest(
170176
breakContexts, build, rotation, hotbar,
171-
onBreak = { breaks++ }
172-
) { item -> if (collectDrops) dropsToCollect.add(item) }
177+
onBreak = { breaks++ },
178+
onItemDrop = onItemDrop
179+
)
173180
build.breakSettings.request(request)
174181
return@onRotate
175182
}

0 commit comments

Comments
 (0)