Skip to content

Commit 22ecdb9

Browse files
committed
allow sneaking when it doesnt matter in build sim
1 parent 1b707f0 commit 22ecdb9

17 files changed

Lines changed: 18 additions & 56 deletions

File tree

src/main/kotlin/com/lambda/config/blocks/BuildConfig.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@ interface BuildConfig {
3131
val interactBlocks: Boolean
3232

3333
val pathing: Boolean
34-
val stayInRange: Boolean
3534
val collectDrops: Boolean
3635
val spleefEntities: Boolean
36+
val cautionDoubleBlocks: Boolean
3737
val maxPendingActions: Int
3838
val actionTimeout: Int
3939
val maxBuildDependencies: Int

src/main/kotlin/com/lambda/config/blocks/BuildSettings.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,9 @@ class BuildSettings(override val c: Config) : BuildConfig, ConfigBlock {
3535
@Group(GENERAL_GROUP) override val interactBlocks by c.setting("Interact", true, "Interact blocks")
3636

3737
@Group(GENERAL_GROUP) override val pathing by c.setting("Pathing", false, "Path to blocks")
38-
@Group(GENERAL_GROUP) override val stayInRange by c.setting("Stay In Range", false, "Stay in range of blocks")
3938
@Group(GENERAL_GROUP) override val collectDrops by c.setting("Collect All Drops", false, "Collect all drops when breaking blocks")
4039
@Group(GENERAL_GROUP) override val spleefEntities by c.setting("Spleef Entities", false, "Breaks blocks beneath entities blocking placements to get them out of the way")
40+
@Group(GENERAL_GROUP) override val cautionDoubleBlocks by c.setting("Caution Double Blocks", true, "Prevents spamming double blocks like doors, chests, etc when configured to interact more than once per tick")
4141
@Group(GENERAL_GROUP) override val maxPendingActions by c.setting("Max Pending Actions", 15, 1..30, 1, "The maximum count of pending interactions to allow before pausing future interactions")
4242
@Group(GENERAL_GROUP) override val actionTimeout by c.setting("Action Timeout", 10, 1..30, 1, "Timeout for block breaks in ticks", unit = " ticks")
4343
@Group(GENERAL_GROUP) override val maxBuildDependencies by c.setting("Max Sim Dependencies", 3, 0..10, 1, "Maximum dependency build results")

src/main/kotlin/com/lambda/interaction/construction/simulation/checks/InteractSim.kt

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ import com.lambda.interaction.material.StackSelection
3636
import com.lambda.interaction.material.StackSelection.Companion.select
3737
import com.lambda.interaction.handlers.ContainerHandler.findContainersWithMaterial
3838
import com.lambda.interaction.material.container.MaterialContainer
39-
import com.lambda.util.BlockUtils
4039
import com.lambda.util.BlockUtils.blockState
4140
import com.lambda.util.EntityUtils.getPositionsWithinHitboxXZ
4241
import com.lambda.util.PlaceDirection
@@ -110,17 +109,12 @@ class InteractSim private constructor(simInfo: InteractSimInfo)
110109
val fakePlayer = copyPlayer(player).apply {
111110
val newPos = pov - (this.eyePos - this.pos)
112111
setPos(newPos.x, newPos.y, newPos.z)
113-
if (preProcessing.info.sneak == false) {
114-
if (testBlockState.block::class in BlockUtils.interactionBlocks) return
115-
input.sneaking = false
116-
updatePose()
117-
} else {
118-
val shouldNotInteract = testBlockState.block::class in BlockUtils.interactionBlocks && preProcessing.info.placing
119-
if (shouldNotInteract || preProcessing.info.sneak == true) {
120-
input.sneaking = true
121-
updatePose()
122-
}
123-
}
112+
val prevSneak = input.sneaking
113+
val interacting = !preProcessing.info.placing
114+
val sneak = preProcessing.info.sneak
115+
if (interacting && (sneak == true || (sneak == null && prevSneak))) return
116+
input.sneaking = preProcessing.info.sneak ?: prevSneak && !interacting
117+
if (prevSneak != isSneaking) updatePose()
124118
}
125119
val pov = fakePlayer.eyePos
126120

src/main/kotlin/com/lambda/interaction/managers/breaking/BreakRequest.kt

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -84,37 +84,30 @@ data class BreakRequest private constructor(
8484
) {
8585
val request = BreakRequest(contexts, pendingInteractions, automated, nowOrNothing)
8686

87-
@BreakRequestDsl
8887
fun onStart(callback: SafeContext.(BlockPos) -> Unit) {
8988
request.onStart = callback
9089
}
9190

92-
@BreakRequestDsl
9391
fun onUpdate(callback: SafeContext.(BlockPos) -> Unit) {
9492
request.onUpdate = callback
9593
}
9694

97-
@BreakRequestDsl
9895
fun onStop(callback: SafeContext.(BlockPos) -> Unit) {
9996
request.onStop = callback
10097
}
10198

102-
@BreakRequestDsl
10399
fun onCancel(callback: SafeContext.(BlockPos) -> Unit) {
104100
request.onCancel = callback
105101
}
106102

107-
@BreakRequestDsl
108103
fun onItemDrop(callback: SafeContext.(ItemEntity) -> Unit) {
109104
request.onItemDrop = callback
110105
}
111106

112-
@BreakRequestDsl
113107
fun onReBreakStart(callback: SafeContext.(BlockPos) -> Unit) {
114108
request.onReBreakStart = callback
115109
}
116110

117-
@BreakRequestDsl
118111
fun onReBreak(callback: SafeContext.(BlockPos) -> Unit) {
119112
request.onReBreak = callback
120113
}

src/main/kotlin/com/lambda/interaction/managers/interacting/InteractRequest.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ data class InteractRequest private constructor(
6262
) {
6363
val request = InteractRequest(contexts, pendingInteractions, automated, nowOrNothing)
6464

65-
@PlaceRequestDsl
6665
fun onPlace(callback: SafeContext.(BlockPos) -> Unit) {
6766
request.onPlace = callback
6867
}

src/main/kotlin/com/lambda/interaction/managers/inventory/InventoryRequest.kt

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ class InventoryRequest private constructor(
5151
override val tickStageMask get() = inventoryConfig.tickStageMask
5252
override var done = false
5353

54+
@InvRequestDsl
5455
override fun submit(queueIfMismatchedStage: Boolean) =
5556
InventoryManager.request(this, queueIfMismatchedStage)
5657

@@ -63,12 +64,10 @@ class InventoryRequest private constructor(
6364
val actions = mutableListOf<InventoryAction>()
6465
var onComplete: (SafeContext.() -> Unit)? = null
6566

66-
@InvRequestDsl
6767
fun click(slotId: Int, button: Int, actionType: SlotActionType) {
6868
InventoryAction.Inventory { clickSlot(slotId, button, actionType) }.addToActions()
6969
}
7070

71-
@InvRequestDsl
7271
fun resyncInventory() {
7372
InventoryAction.Inventory {
7473
connection.sendPacket {
@@ -84,19 +83,16 @@ class InventoryRequest private constructor(
8483
}.addToActions()
8584
}
8685

87-
@InvRequestDsl
8886
fun pickFromInventory(slotId: Int) {
8987
InventoryAction.Inventory {
9088
clickSlot(slotId, player.inventory.selectedSlot, SlotActionType.SWAP)
9189
}.addToActions()
9290
}
9391

94-
@InvRequestDsl
9592
fun dropItemInHand(entireStack: Boolean = true) {
9693
InventoryAction.Inventory { player.dropSelectedItem(entireStack) }.addToActions()
9794
}
9895

99-
@InvRequestDsl
10096
fun swapHands() {
10197
InventoryAction.Player {
10298
val offhandStack = player.getStackInHand(Hand.OFF_HAND)
@@ -112,78 +108,61 @@ class InventoryRequest private constructor(
112108
}.addToActions()
113109
}
114110

115-
@InvRequestDsl
116111
fun clickCreativeStack(stack: ItemStack, slotId: Int) {
117112
InventoryAction.Inventory { interaction.clickCreativeStack(stack, slotId) }.addToActions()
118113
}
119114

120-
@InvRequestDsl
121115
fun pickup(slotId: Int, button: Int = 0) = click(slotId, button, SlotActionType.PICKUP)
122116

123117
// Quick move action (Shift-click)
124-
@InvRequestDsl
125118
fun quickMove(slotId: Int) = click(slotId, 0, SlotActionType.QUICK_MOVE)
126119

127-
@InvRequestDsl
128120
fun swap(slotId: Int, hotbarSlot: Int) = click(slotId, hotbarSlot, SlotActionType.SWAP)
129121

130122
// Clone action (Creative mode)
131-
@InvRequestDsl
132123
fun clone(slotId: Int) = click(slotId, 2, SlotActionType.CLONE)
133124

134125
// Throw stack or single item
135-
@InvRequestDsl
136126
fun throwStack(slotId: Int) = click(slotId, 1, SlotActionType.THROW)
137127

138-
@InvRequestDsl
139128
fun throwSingle(slotId: Int) = click(slotId, 0, SlotActionType.THROW)
140129

141130
// Quick craft action
142-
@InvRequestDsl
143131
fun quickCraftStart(slotId: Int) = click(slotId, 0, SlotActionType.QUICK_CRAFT)
144132

145-
@InvRequestDsl
146133
fun quickCraftDrag(slotId: Int) = click(slotId, 1, SlotActionType.QUICK_CRAFT)
147134

148-
@InvRequestDsl
149135
fun quickCraftEnd(slotId: Int) = click(slotId, 2, SlotActionType.QUICK_CRAFT)
150136

151137
// Pickup all items (double-click)
152-
@InvRequestDsl
153138
fun pickupAll(slotId: Int) = click(slotId, 0, SlotActionType.PICKUP_ALL)
154139

155140
// Helper function: Move items from one slot to another
156-
@InvRequestDsl
157141
fun moveSlot(fromSlotId: Int, toSlotId: Int, button: Int = 0) {
158142
pickup(fromSlotId, button)
159143
pickup(toSlotId, button)
160144
}
161145

162146
// Helper function: Split a stack into two
163-
@InvRequestDsl
164147
fun splitStack(slotId: Int, targetSlotId: Int) {
165148
pickup(slotId, 1) // Pickup half the stack
166149
pickup(targetSlotId, 0) // Place it in the target slot
167150
}
168151

169152
// Helper function: Merge stacks
170-
@InvRequestDsl
171153
fun mergeStacks(sourceSlotId: Int, targetSlotId: Int) {
172154
pickup(sourceSlotId, 0)
173155
pickup(targetSlotId, 0)
174156
}
175157

176-
@InvRequestDsl
177158
fun action(action: SafeContext.() -> Unit) {
178159
InventoryAction.Other(action).addToActions()
179160
}
180161

181-
@InvRequestDsl
182162
fun onComplete(callback: SafeContext.() -> Unit) {
183163
onComplete = callback
184164
}
185165

186-
@InvRequestDsl
187166
private fun InventoryAction.addToActions() {
188167
actions.add(this)
189168
}

src/main/kotlin/com/lambda/module/modules/combat/CrystalAura.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ object CrystalAura : Module(
151151
hideAllExcept(::buildConfig, ::rotationConfig, ::hotbarConfig, ::inventoryConfig)
152152
buildConfig.apply {
153153
hide(
154-
::pathing, ::stayInRange, ::collectDrops, ::spleefEntities,
154+
::pathing, ::collectDrops, ::spleefEntities,
155155
::maxPendingActions, ::actionTimeout, ::maxBuildDependencies, ::breakBlocks, ::interactBlocks, ::placeBlocks
156156
)
157157
}

src/main/kotlin/com/lambda/module/modules/combat/KillAura.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ object KillAura : Module(
9393
hideAllExcept(::buildConfig, ::hotbarConfig, ::rotationConfig)
9494
buildConfig.apply {
9595
hide(
96-
::pathing, ::stayInRange, ::collectDrops,
96+
::pathing, ::collectDrops,
9797
::spleefEntities, ::maxPendingActions, ::actionTimeout,
9898
::maxBuildDependencies, ::blockReach
9999
)

src/main/kotlin/com/lambda/module/modules/combat/PlayerTrap.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@ object PlayerTrap : Module(
6060
buildConfig.apply {
6161
editTypedSettings(
6262
::pathing,
63-
::stayInRange,
6463
::spleefEntities,
6564
::collectDrops
6665
) { defaultValue(false); hide() }

src/main/kotlin/com/lambda/module/modules/combat/Surround.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ object Surround : Module(
5050
buildConfig.apply {
5151
editTypedSettings(
5252
::pathing,
53-
::stayInRange,
5453
::spleefEntities,
5554
::collectDrops
5655
) { defaultValue(false); hide() }

0 commit comments

Comments
 (0)