Skip to content

Commit 9fc5ebe

Browse files
committed
Pathing strategies and more options
1 parent 857ea42 commit 9fc5ebe

File tree

14 files changed

+98
-112
lines changed

14 files changed

+98
-112
lines changed

common/src/main/kotlin/com/lambda/config/groups/BuildConfig.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,13 @@ package com.lambda.config.groups
33
interface BuildConfig {
44
val breakCoolDown: Int
55
val placeCooldown: Int
6+
val placeConfirmation: Boolean
7+
val breakConfirmation: Boolean
68
val collectDrops: Boolean
79
val breakWeakBlocks: Boolean
810
val pathing: Boolean
911
val breaksPerTick: Int
1012
val rotateForBreak: Boolean
13+
val rotateForPlace: Boolean
1114
val swingHand: Boolean
1215
}

common/src/main/kotlin/com/lambda/config/groups/BuildSettings.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,13 @@ class BuildSettings(
88
) : BuildConfig {
99
override val breakCoolDown by c.setting("Break Cooldown", 0, 0..1000, 1, "Delay between breaking blocks", " ms", vis)
1010
override val placeCooldown by c.setting("Place Cooldown", 0, 0..1000, 1, "Delay between placing blocks", " ms", vis)
11+
override val placeConfirmation by c.setting("Place Confirmation", false, "Wait for block placement confirmation", vis)
12+
override val breakConfirmation by c.setting("Break Confirmation", false, "Wait for block break confirmation", vis)
1113
override val collectDrops by c.setting("Collect All Drops", false, "Collect all drops when breaking blocks", vis)
1214
override val breakWeakBlocks by c.setting("Break Weak Blocks", false, "Break blocks that dont have structural integrity (e.g: grass)", vis)
1315
override val pathing by c.setting("Pathing", true, "Path to blocks", vis)
1416
override val breaksPerTick by c.setting("Instant Breaks Per Tick", 10, 1..30, 1, "Maximum instant block breaks per tick", "", vis)
1517
override val rotateForBreak by c.setting("Rotate For Break", false, "Rotate towards block while breaking", vis)
18+
override val rotateForPlace by c.setting("Rotate For Place", true, "Rotate towards block while placing", vis)
1619
override val swingHand by c.setting("Swing Hand", true, "Swing hand on interactions", vis)
1720
}

common/src/main/kotlin/com/lambda/interaction/construction/result/BreakResult.kt

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -117,14 +117,9 @@ sealed class BreakResult : BuildResult() {
117117
data class PlayerOnTop(
118118
override val blockPos: BlockPos,
119119
val blockState: BlockState
120-
) : Navigable, Resolvable, BreakResult() {
120+
) : Navigable, BreakResult() {
121121
override val rank = Rank.BREAK_PLAYER_ON_TOP
122122

123-
override val resolve get() =
124-
moveToGoalUntil(GoalInverted(GoalBlock(blockPos))) {
125-
val pBox = player.boundingBox
126-
val aabb = Box(pBox.minX, pBox.minY - 1.0E-6, pBox.minZ, pBox.maxX, pBox.minY, pBox.maxZ)
127-
world.findSupportingBlockPos(player, aabb).orElse(null) != blockPos
128-
}
123+
override val goal = GoalInverted(GoalBlock(blockPos))
129124
}
130125
}

common/src/main/kotlin/com/lambda/interaction/construction/result/BuildResult.kt

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,13 @@
11
package com.lambda.interaction.construction.result
22

3+
import baritone.api.pathing.goals.GoalBlock
4+
import baritone.api.pathing.goals.GoalNear
35
import baritone.process.BuilderProcess.GoalPlace
46
import com.lambda.interaction.construction.context.BuildContext
57
import com.lambda.interaction.material.ContainerManager.transfer
68
import com.lambda.interaction.material.StackSelection.Companion.select
79
import com.lambda.interaction.material.container.MainHandContainer
8-
import com.lambda.task.Task
9-
import com.lambda.task.Task.Companion.emptyTask
1010
import com.lambda.task.Task.Companion.failTask
11-
import com.lambda.task.tasks.GoalTask.Companion.moveNearBlock
12-
import com.lambda.task.tasks.GoalTask.Companion.moveToGoal
13-
import com.lambda.task.tasks.GoalTask.Companion.moveUntilLoaded
1411
import net.minecraft.block.BlockState
1512
import net.minecraft.item.Item
1613
import net.minecraft.item.ItemStack
@@ -45,10 +42,10 @@ abstract class BuildResult : ComparableResult<Rank> {
4542
*/
4643
data class ChunkNotLoaded(
4744
override val blockPos: BlockPos
48-
) : Navigable, Resolvable, BuildResult() {
45+
) : Navigable, BuildResult() {
4946
override val rank = Rank.CHUNK_NOT_LOADED
5047

51-
override val resolve get() = moveUntilLoaded(blockPos)
48+
override val goal = GoalBlock(blockPos)
5249

5350
override fun compareTo(other: ComparableResult<Rank>): Int {
5451
return when (other) {
@@ -112,12 +109,10 @@ abstract class BuildResult : ComparableResult<Rank> {
112109
val hitPos: BlockPos,
113110
val side: Direction,
114111
val distance: Double
115-
) : Navigable, Resolvable, BuildResult() {
112+
) : Navigable, BuildResult() {
116113
override val rank = Rank.NOT_VISIBLE
117114

118-
override val resolve get() = moveToGoal {
119-
GoalPlace(blockPos)
120-
}
115+
override val goal = GoalPlace(blockPos)
121116

122117
override fun compareTo(other: ComparableResult<Rank>): Int {
123118
return when (other) {
@@ -186,14 +181,14 @@ abstract class BuildResult : ComparableResult<Rank> {
186181
val hitVec: Vec3d,
187182
val reach: Double,
188183
val side: Direction,
189-
) : Navigable, Resolvable, BuildResult() {
184+
) : Navigable, BuildResult() {
190185
override val rank = Rank.OUT_OF_REACH
191186

192187
val distance: Double by lazy {
193188
startVec.distanceTo(hitVec)
194189
}
195190

196-
override val resolve get() = moveNearBlock(blockPos, 2)
191+
override val goal = GoalNear(blockPos, 2)
197192

198193
override fun compareTo(other: ComparableResult<Rank>): Int {
199194
return when (other) {
Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
11
package com.lambda.interaction.construction.result
22

3-
interface Navigable
3+
import baritone.api.pathing.goals.Goal
4+
5+
interface Navigable {
6+
val goal: Goal
7+
}

common/src/main/kotlin/com/lambda/interaction/construction/result/PlaceResult.kt

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.lambda.interaction.construction.result
22

3+
import baritone.api.pathing.goals.Goal
34
import baritone.api.pathing.goals.GoalBlock
45
import baritone.api.pathing.goals.GoalInverted
56
import com.lambda.interaction.construction.context.PlaceContext
@@ -59,12 +60,10 @@ sealed class PlaceResult : BuildResult() {
5960

6061
data class BlockedByPlayer(
6162
override val blockPos: BlockPos
62-
) : Navigable, Resolvable, PlaceResult() {
63+
) : Navigable, PlaceResult() {
6364
override val rank = Rank.PLACE_BLOCKED_BY_PLAYER
6465

65-
override val resolve get() = moveToGoalUntil(GoalInverted(GoalBlock(blockPos))) {
66-
!world.canCollide(player, Box(blockPos))
67-
}
66+
override val goal = GoalInverted(GoalBlock(blockPos))
6867
}
6968

7069
/**
@@ -74,13 +73,10 @@ sealed class PlaceResult : BuildResult() {
7473
data class CantReplace(
7574
override val blockPos: BlockPos,
7675
val simulated: ItemPlacementContext
77-
) : Navigable, Resolvable, PlaceResult() {
76+
) : Resolvable, PlaceResult() {
7877
override val rank = Rank.PLACE_CANT_REPLACE
7978

80-
// override val resolve = breakBlock(simulated.blockPos)
81-
override val resolve get() = moveToGoalUntil(GoalInverted(GoalBlock(blockPos))) {
82-
!world.canCollide(player, Box(blockPos))
83-
}
79+
override val resolve = breakBlock(blockPos)
8480
}
8581

8682
/**
@@ -123,6 +119,6 @@ sealed class PlaceResult : BuildResult() {
123119
) : Resolvable, PlaceResult() {
124120
override val rank = Rank.PLACE_NOT_ITEM_BLOCK
125121

126-
override val resolve get() = Task.emptyTask() // ToDo: analyze interaction with non-block items
122+
override val resolve get() = TODO("Not expected")
127123
}
128124
}

common/src/main/kotlin/com/lambda/interaction/construction/result/Rank.kt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,17 @@ enum class Rank {
1010
NOT_VISIBLE,
1111
OUT_OF_REACH,
1212
BREAK_NOT_EXPOSED,
13-
OUT_OF_WORLD,
1413
CHUNK_NOT_LOADED,
15-
PLACE_NO_INTEGRITY,
1614
PLACE_CANT_REPLACE,
17-
PLACE_NOT_ITEM_BLOCK,
18-
BREAK_SUBMERGE,
19-
BREAK_IS_BLOCKED_BY_LIQUID,
2015
BREAK_PLAYER_ON_TOP,
16+
PLACE_NOT_ITEM_BLOCK,
2117

2218
// not solvable
19+
OUT_OF_WORLD,
2320
BREAK_RESTRICTED,
21+
PLACE_NO_INTEGRITY,
22+
BREAK_SUBMERGE,
23+
BREAK_IS_BLOCKED_BY_LIQUID,
2424
UNBREAKABLE,
2525
BREAK_NO_PERMISSION,
2626
PLACE_SCAFFOLD_EXCEEDED,

common/src/main/kotlin/com/lambda/interaction/construction/simulation/BuildSimulator.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,10 +126,10 @@ object BuildSimulator {
126126
acc.add(BuildResult.OutOfReach(pos, eye, hitPos.vecOf(hitSide), interact.reach, hitSide))
127127
return@forEach
128128
}
129+
129130
val verify: HitResult.() -> Boolean = {
130131
blockResult?.blockPos == hitPos && blockResult?.side == hitSide
131132
}
132-
133133
val validHits = mutableMapOf<Vec3d, HitResult>()
134134
val reachSq = interact.reach.pow(2)
135135

@@ -251,7 +251,7 @@ object BuildSimulator {
251251

252252
val currentHandStack = player.getStackInHand(Hand.MAIN_HAND)
253253
if (target is TargetState.Stack && !target.itemStack.equal(currentHandStack)) {
254-
acc.add(BuildResult.WrongStack(pos, placeContext, target.itemStack))
254+
acc.add(BuildResult.WrongStack(pos, placeContext, target.copy))
255255
return@forEach
256256
}
257257

common/src/main/kotlin/com/lambda/module/modules/client/TaskFlow.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,10 @@ object TaskFlow : Module(
1414
defaultTags = setOf(ModuleTag.CLIENT, ModuleTag.AUTOMATION)
1515
) {
1616
enum class Page {
17-
TASKS, BUILD, ROTATION, INTERACTION
17+
BUILD, ROTATION, INTERACTION, TASKS
1818
}
1919

2020
private val page by setting("Page", Page.BUILD)
21-
val taskCooldown by setting("Task Cooldown", 0, 0..10000, 10, " ms") {
22-
page == Page.TASKS
23-
}
2421
val build = BuildSettings(this) {
2522
page == Page.BUILD
2623
}
@@ -30,6 +27,9 @@ object TaskFlow : Module(
3027
val interact = InteractionSettings(this) {
3128
page == Page.INTERACTION
3229
}
30+
val taskCooldown by setting("Task Cooldown", 0, 0..10000, 10, unit = " ms") {
31+
page == Page.TASKS
32+
}
3333
// val disposables by setting("Disposables", ItemUtils.defaultDisposables)
3434
val ignoredBlocks = mutableSetOf<Block>().apply { addAll(allSigns) }
3535
}

common/src/main/kotlin/com/lambda/module/modules/player/HighwayTools.kt

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,13 @@
11
package com.lambda.module.modules.player
22

3-
import baritone.api.pathing.goals.GoalNear
43
import com.lambda.interaction.construction.StaticBlueprint.Companion.toBlueprint
54
import com.lambda.interaction.construction.verify.TargetState
65
import com.lambda.module.Module
76
import com.lambda.module.tag.ModuleTag
87
import com.lambda.task.Task
98
import com.lambda.task.tasks.BuildStructure.Companion.buildStructure
109
import com.lambda.util.BaritoneUtils
11-
import com.lambda.util.BaritoneUtils.primary
1210
import com.lambda.util.Communication.info
13-
import com.lambda.util.KeyCode
1411
import com.lambda.util.player.MovementUtils.octant
1512
import com.lambda.util.primitives.extension.Structure
1613
import com.lambda.util.world.StructureUtils.generateDirectionalTube
@@ -67,11 +64,9 @@ object HighwayTools : Module(
6764
structure += slice.map { it.key.add(currentPos) to it.value }
6865
}
6966

70-
buildStructure {
67+
runningTask = buildStructure {
7168
structure.toBlueprint()
7269
}.apply {
73-
runningTask = this
74-
primary.customGoalProcess.setGoalAndPath(GoalNear(currentPos, sliceSize))
7570
onSuccess { _, _ ->
7671
if (distanceMoved < distance || distance < 0) {
7772
buildSlice()

0 commit comments

Comments
 (0)