Skip to content

Commit f744366

Browse files
committed
moved build logic back to on rotate in build task
1 parent fbe4662 commit f744366

File tree

3 files changed

+16
-15
lines changed

3 files changed

+16
-15
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ object BreakManager : RequestHandler<BreakRequest>() {
9191
) = listen<UpdateManagerEvent.Break.Post>(0, alwaysListen) { block() }
9292

9393
init {
94-
listen<TickEvent.Pre>(Int.MIN_VALUE) {
94+
listen<TickEvent.Pre>(priority = Int.MIN_VALUE) {
9595
if (isOnBreakCooldown()) {
9696
blockBreakingCooldown--
9797
return@listen
@@ -169,7 +169,7 @@ object BreakManager : RequestHandler<BreakRequest>() {
169169
requestRotate()
170170
}
171171

172-
onRotatePost {
172+
onRotatePost(priority = Int.MIN_VALUE) {
173173
validRotation = rotation?.done ?: true
174174
postEvent()
175175
}

common/src/main/kotlin/com/lambda/interaction/request/placing/PlaceManager.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ object PlaceManager : RequestHandler<PlaceRequest>() {
6868
get() = pendingInteractions.map { it.context.expectedPos }
6969

7070
init {
71-
listen<TickEvent.Pre> {
71+
listen<TickEvent.Pre>(priority = Int.MIN_VALUE) {
7272
currentRequest?.let { request ->
7373
val notSneaking = !player.isSneaking
7474
val hotbarRequest = request.hotbarConfig.request(HotbarRequest(request.placeContext.hotbarIndex))
@@ -110,7 +110,7 @@ object PlaceManager : RequestHandler<PlaceRequest>() {
110110
}
111111
}
112112

113-
onRotatePost {
113+
onRotatePost(priority = Int.MIN_VALUE) {
114114
validRotation = rotation?.done ?: true
115115
postEvent()
116116
}

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

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ import com.lambda.interaction.material.transfer.TransactionExecutor.Companion.tr
4242
import com.lambda.interaction.request.breaking.BreakRequest
4343
import com.lambda.interaction.request.hotbar.HotbarConfig
4444
import com.lambda.interaction.request.placing.PlaceRequest
45+
import com.lambda.interaction.request.rotation.RotationManager.onRotate
4546
import com.lambda.module.modules.client.TaskFlowModule
4647
import com.lambda.task.Task
4748
import com.lambda.util.BaritoneUtils
@@ -90,15 +91,15 @@ class BuildTask @Ta5kBuilder constructor(
9091
}
9192

9293
init {
93-
listen<TickEvent.Pre> {
94-
if (collectDrops()) return@listen
94+
onRotate {
95+
if (collectDrops()) return@onRotate
9596

9697
// ToDo: Simulate for each pair player positions that work
9798
val results = blueprint.simulate(player.eyePos, interact, rotation, inventory, build)
9899

99100
TaskFlowModule.drawables = results.filterIsInstance<Drawable>()
100101
.plus(pendingInteractions.toList())
101-
// .plus(sim.goodPositions())
102+
// .plus(sim.goodPositions())
102103

103104
if (build.breakSettings.breaksPerTick > 1) {
104105
val instantResults = results.filterIsInstance<BreakResult.Break>()
@@ -113,31 +114,31 @@ class BuildTask @Ta5kBuilder constructor(
113114
onBreak = { breaks++ }
114115
) { item -> if (collectDrops) dropsToCollect.add(item) }
115116
)
116-
return@listen
117+
return@onRotate
117118
}
118119
}
119120

120121
val resultsNotBlocked = results.filterNot { result ->
121122
result.blockPos in pendingInteractions.map { it.expectedPos }
122123
}.sorted()
123-
val bestResult = resultsNotBlocked.firstOrNull() ?: return@listen
124+
val bestResult = resultsNotBlocked.firstOrNull() ?: return@onRotate
124125
when (bestResult) {
125126
is BuildResult.Done,
126127
is BuildResult.Ignored,
127128
is BuildResult.Unbreakable,
128129
is BuildResult.Restricted,
129130
is BuildResult.NoPermission -> {
130-
if (pendingInteractions.isNotEmpty()) return@listen
131+
if (pendingInteractions.isNotEmpty()) return@onRotate
131132
if (blueprint is PropagatingBlueprint) {
132133
blueprint.next()
133-
return@listen
134+
return@onRotate
134135
}
135136
if (finishOnDone) success()
136137
}
137138

138139
is BuildResult.NotVisible,
139140
is PlaceResult.NoIntegrity -> {
140-
if (!build.pathing) return@listen
141+
if (!build.pathing) return@onRotate
141142
val sim = blueprint.simulation(interact, rotation, inventory, build)
142143
val goal = BuildGoal(sim, player.blockPos)
143144
BaritoneUtils.setGoalAndPath(goal)
@@ -148,17 +149,17 @@ class BuildTask @Ta5kBuilder constructor(
148149
}
149150

150151
is BuildResult.Contextual -> {
151-
if (pendingInteractions.size >= build.maxPendingInteractions) return@listen
152+
if (pendingInteractions.size >= build.maxPendingInteractions) return@onRotate
152153
val breakContexts = resultsNotBlocked.filterIsInstance<BreakResult.Break>().map { it.context }
153154
if (breakContexts.isNotEmpty()) {
154155
val request = BreakRequest(
155156
breakContexts, build, rotation, hotbar,
156157
onBreak = { breaks++ },
157158
) { item -> if (collectDrops) dropsToCollect.add(item) }
158159
build.breakSettings.request(request)
159-
return@listen
160+
return@onRotate
160161
}
161-
if (bestResult !is PlaceResult.Place) return@listen
162+
if (bestResult !is PlaceResult.Place) return@onRotate
162163
build.placeSettings.request(
163164
PlaceRequest(bestResult.context, build, rotation, hotbar, interact) { placements++ }
164165
)

0 commit comments

Comments
 (0)