@@ -67,6 +67,7 @@ class BuildTask @Ta5kBuilder constructor(
6767 build.maxPendingInteractions, build.interactionTimeout * 50L
6868 ) { info(" ${it::class .simpleName} at ${it.expectedPos.toShortString()} timed out" ) }
6969 private var currentInteraction: BuildContext ? = null
70+ private val instantBreaks = mutableSetOf<BreakContext >()
7071
7172 private var placements = 0
7273 private var breaks = 0
@@ -79,9 +80,14 @@ class BuildTask @Ta5kBuilder constructor(
7980 init {
8081 listen<TickEvent .Pre > {
8182 currentInteraction?.let { context ->
82- if (context.shouldRotate(build) && ! context.rotation.megaDone()) return @listen
83+ if (context.shouldRotate(build) && ! context.rotation.done) return @let
8384 context.interact(interact.swingHand)
8485 }
86+ instantBreaks.forEach { context ->
87+ context.interact(interact.swingHand)
88+ pendingInteractions.add(context)
89+ }
90+ instantBreaks.clear()
8591 }
8692
8793 listen<TickEvent .Post > {
@@ -91,7 +97,9 @@ class BuildTask @Ta5kBuilder constructor(
9197 failure(" Structure is empty" )
9298 return @listen
9399 }
100+ }
94101
102+ onRotate {
95103// val sim = blueprint.simulation(interact, rotation, inventory)
96104// BlockPos.iterateOutwards(player.blockPos, 5, 5, 5).forEach { pos ->
97105// sim.simulate(pos.toFastVec())
@@ -109,50 +117,33 @@ class BuildTask @Ta5kBuilder constructor(
109117 .sorted()
110118 .take(build.breaksPerTick)
111119
112- instantResults.forEach {
113- it.context.interact(interact.swingHand)
114- pendingInteractions.add(it.context)
115- }
120+ instantBreaks.addAll(instantResults.map { it.context })
116121
117- if (instantResults.isNotEmpty()) return @listen
122+ if (instantResults.isNotEmpty()) return @onRotate
118123 }
119124
120125 val resultsWithoutPending = results.filterNot { result ->
121126 result.blockPos in pendingInteractions.map { it.expectedPos }
122127 }
123- val bestResult = resultsWithoutPending.minOrNull() ? : return @listen
128+ val bestResult = resultsWithoutPending.minOrNull() ? : return @onRotate
124129 when (bestResult) {
125130 is BuildResult .Done ,
126131 is BuildResult .Ignored ,
127132 is BuildResult .Unbreakable ,
128133 is BuildResult .Restricted ,
129134 is BuildResult .NoPermission -> {
130- if (pendingInteractions.isNotEmpty()) return @listen
135+ if (pendingInteractions.isNotEmpty()) return @onRotate
131136 if (blueprint is PropagatingBlueprint ) {
132137 blueprint.next()
133- return @listen
138+ return @onRotate
134139 }
135140 if (finishOnDone) success()
136141 }
137142
138143 is BuildResult .NotVisible ,
139144 is PlaceResult .NoIntegrity -> {
140- if (! build.pathing) return @listen
141- // ToDo:
142- // Solve the problem that baritone stops pathing when it thinks it is in a valid goal
143- // but the player position does not perfectly match the simulated position
144- // hacky fix for now is to walk "closer" but it wont work in every situation
145- val interaction = object : InteractionConfig {
146- override val attackReach = 3.0
147- override val interactReach = interact.interactReach - 1
148- override val scanReach = interact.scanReach
149- override val strictRayCast = interact.strictRayCast
150- override val checkSideVisibility = interact.checkSideVisibility
151- override val resolution = interact.resolution
152- override val pointSelection = interact.pointSelection
153- override val swingHand = interact.swingHand
154- }
155- val goal = BuildGoal (blueprint.simulation(interaction, rotation, inventory, build))
145+ if (! build.pathing) return @onRotate
146+ val goal = BuildGoal (blueprint.simulation(interact, rotation, inventory, build), player.blockPos)
156147 BaritoneUtils .setGoalAndPath(goal)
157148 }
158149
@@ -161,7 +152,7 @@ class BuildTask @Ta5kBuilder constructor(
161152 }
162153
163154 is BuildResult .Contextual -> {
164- if (pendingInteractions.size >= build.maxPendingInteractions) return @listen
155+ if (pendingInteractions.size >= build.maxPendingInteractions) return @onRotate
165156
166157 currentInteraction = bestResult.context
167158 }
@@ -172,9 +163,7 @@ class BuildTask @Ta5kBuilder constructor(
172163 bestResult.resolve().execute(this @BuildTask)
173164 }
174165 }
175- }
176166
177- onRotate {
178167 if (! build.rotateForPlace) return @onRotate
179168 val rotateTo = currentInteraction?.rotation ? : return @onRotate
180169
0 commit comments