Skip to content

Commit d105b4d

Browse files
committed
separate interact setting
1 parent 19975c8 commit d105b4d

11 files changed

Lines changed: 28 additions & 28 deletions

File tree

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import com.lambda.util.NamedEnum
2424

2525
interface BuildConfig : ISettingGroup {
2626
val breakBlocks: Boolean
27+
val placeBlocks: Boolean
2728
val interactBlocks: Boolean
2829

2930
val pathing: Boolean

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ class BuildSettings(
3737
}
3838

3939
override val breakBlocks by c.setting("${prefix}Break", true, "Break blocks", visibility = visibility).group(*baseGroup, Group.General).index()
40-
override val interactBlocks by c.setting("${prefix}Place / Interact", true, "Interact blocks", visibility = visibility).group(*baseGroup, Group.General).index()
40+
override val placeBlocks by c.setting("${prefix}Place", true, "Place blocks", visibility = visibility).group(*baseGroup, Group.General).index()
41+
override val interactBlocks by c.setting("${prefix}Interact", true, "Interact blocks", visibility = visibility).group(*baseGroup, Group.General).index()
4142

4243
override val pathing by c.setting("${prefix}Pathing", false, "Path to blocks", visibility = visibility).group(*baseGroup, Group.General).index()
4344
override val stayInRange by c.setting("${prefix}Stay In Range", false, "Stay in range of blocks", visibility = visibility).group(*baseGroup, Group.General).index()

src/main/kotlin/com/lambda/interaction/construction/simulation/context/BreakContext.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ package com.lambda.interaction.construction.simulation.context
1919

2020
import com.lambda.context.Automated
2121
import com.lambda.graphics.mc.RenderBuilder
22-
import com.lambda.graphics.mc.renderer.TickedRenderer
2322
import com.lambda.interaction.managers.rotating.RotationRequest
2423
import com.lambda.interaction.material.StackSelection
2524
import com.lambda.threading.runSafe
@@ -65,4 +64,6 @@ data class BreakContext(
6564
colors(baseColor, sideColor)
6665
}
6766
}
67+
68+
override fun canUse() = buildConfig.breakBlocks
6869
}

src/main/kotlin/com/lambda/interaction/construction/simulation/context/BuildContext.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,6 @@ abstract class BuildContext : Drawable, Automated {
4343
open val sortDistance by lazy {
4444
runSafe { player.eyePos.distanceTo(hitResult.pos) } ?: Double.MAX_VALUE
4545
}
46+
47+
abstract fun canUse(): Boolean
4648
}

src/main/kotlin/com/lambda/interaction/construction/simulation/context/InteractContext.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,7 @@ package com.lambda.interaction.construction.simulation.context
1919

2020
import com.lambda.context.Automated
2121
import com.lambda.graphics.mc.RenderBuilder
22-
import com.lambda.graphics.mc.renderer.TickedRenderer
2322
import com.lambda.interaction.construction.simulation.processing.PreProcessingInfo
24-
import com.lambda.interaction.managers.hotbar.HotbarRequest
2523
import com.lambda.interaction.managers.interacting.InteractRequest
2624
import com.lambda.interaction.managers.rotating.RotationRequest
2725
import net.minecraft.block.BlockState
@@ -65,4 +63,7 @@ data class InteractContext(
6563
} else true
6664
return validRotation
6765
}
66+
67+
override fun canUse() =
68+
(buildConfig.interactBlocks && !preProcessingInfo.placing) || (buildConfig.placeBlocks && preProcessingInfo.placing)
6869
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ object BreakManager : Manager<BreakRequest>(
298298
* @see processRequest
299299
*/
300300
override fun AutomatedSafeContext.handleRequest(request: BreakRequest) {
301-
if (!request.buildConfig.breakBlocks || activeRequest != null || request.contexts.isEmpty()) return
301+
if (activeRequest != null || request.contexts.isEmpty()) return
302302
if (InteractManager.activeThisTick) return
303303

304304
activeRequest = request

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

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ import com.lambda.interaction.managers.breaking.BreakManager
3535
import com.lambda.interaction.managers.hotbar.HotbarRequest
3636
import com.lambda.interaction.managers.interacting.InteractConfig.AirPlaceMode
3737
import com.lambda.interaction.managers.interacting.InteractManager.activeRequest
38-
import com.lambda.interaction.managers.interacting.InteractManager.maxPlacementsThisTick
3938
import com.lambda.interaction.managers.interacting.InteractManager.populateFrom
4039
import com.lambda.interaction.managers.interacting.InteractManager.processRequest
4140
import com.lambda.interaction.managers.interacting.InteractedBlockHandler.pendingActions
@@ -73,10 +72,8 @@ object InteractManager : Manager<InteractRequest>(
7372
private var potentialInteractions = mutableListOf<InteractContext>()
7473

7574
private var interactCooldown = 0
76-
private var placementsThisTick = 0
77-
private var maxPlacementsThisTick = 0
78-
79-
private var airPlacedThisTick = false
75+
private var interactionsThisTick = 0
76+
private var maxInteractionsThisTick = 0
8077

8178
private var shouldSneak = false
8279
private val ClientPlayerEntity.validSneak get() = isSneaking == shouldSneak
@@ -89,8 +86,7 @@ object InteractManager : Manager<InteractRequest>(
8986

9087
listen<TickEvent.Post>({ Int.MIN_VALUE }) {
9188
activeRequest = null
92-
airPlacedThisTick = false
93-
placementsThisTick = 0
89+
interactionsThisTick = 0
9490
potentialInteractions.clear()
9591
if (interactCooldown > 0) {
9692
interactCooldown--
@@ -118,7 +114,7 @@ object InteractManager : Manager<InteractRequest>(
118114
* @see processRequest
119115
*/
120116
override fun AutomatedSafeContext.handleRequest(request: InteractRequest) {
121-
if (!request.buildConfig.interactBlocks || activeRequest != null || request.contexts.isEmpty()) return
117+
if (activeRequest != null || request.contexts.isEmpty()) return
122118
if (BreakManager.activeThisTick) return
123119

124120
activeRequest = request
@@ -127,14 +123,14 @@ object InteractManager : Manager<InteractRequest>(
127123
activeRequest = null
128124
potentialInteractions = mutableListOf()
129125
}
130-
if (placementsThisTick > 0) activeThisTick = true
126+
if (interactionsThisTick > 0) activeThisTick = true
131127
}
132128

133129
/**
134130
* Returns immediately if [BreakManager] or [InteractManager] have been active this tick.
135131
* Otherwise, for fresh requests, [populateFrom] is called to fill the [potentialInteractions] collection.
136132
* It then attempts to perform as many placements as possible from the [potentialInteractions] collection within
137-
* the [maxPlacementsThisTick] limit.
133+
* the [maxInteractionsThisTick] limit.
138134
*
139135
* @see populateFrom
140136
*/
@@ -188,7 +184,6 @@ object InteractManager : Manager<InteractRequest>(
188184

189185
if (actionResult.isAccepted) {
190186
PacketLimitHandler.sentPackets(1, PacketType.Interaction)
191-
airPlacedThisTick = true
192187
if (interactConfig.swing) {
193188
swingHand(interactConfig.swingType, Hand.MAIN_HAND)
194189

@@ -201,15 +196,15 @@ object InteractManager : Manager<InteractRequest>(
201196
}
202197
val interactDelay = ctx.interactConfig.interactDelay
203198
interactCooldown = if (interactDelay == 0) 0 else interactDelay + 1
204-
placementsThisTick++
199+
interactionsThisTick++
205200
iterator.remove()
206201
}
207202
return InteractResult.Finished
208203
}
209204

210205
private fun Automated.canInteractThisTick() =
211206
interactCooldown <= 0 &&
212-
placementsThisTick < maxPlacementsThisTick &&
207+
interactionsThisTick < maxInteractionsThisTick &&
213208
PacketLimitHandler.canSendPackets(1, PacketType.Interaction)
214209

215210
/**
@@ -226,7 +221,7 @@ object InteractManager : Manager<InteractRequest>(
226221
.take(buildConfig.maxPendingActions - request.pendingInteractions.size.coerceAtLeast(0))
227222
.toMutableList()
228223

229-
maxPlacementsThisTick = interactConfig.interactionsPerTick
224+
maxInteractionsThisTick = interactConfig.interactionsPerTick
230225
}
231226

232227
/**

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ object CrystalAura : Module(
148148
buildConfig.apply {
149149
hide(
150150
::pathing, ::stayInRange, ::collectDrops, ::spleefEntities,
151-
::maxPendingActions, ::actionTimeout, ::maxBuildDependencies, ::breakBlocks, ::interactBlocks
151+
::maxPendingActions, ::actionTimeout, ::maxBuildDependencies, ::breakBlocks, ::interactBlocks, ::placeBlocks
152152
)
153153
}
154154
}

src/main/kotlin/com/lambda/module/modules/player/FastBreak.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@ object FastBreak : Module(
5050
::blockReach,
5151
::entityReach,
5252
::breakBlocks,
53-
::interactBlocks
53+
::interactBlocks,
54+
::placeBlocks
5455
)
5556
::maxBuildDependencies.edit { defaultValue(0) }
5657
editTyped(

src/main/kotlin/com/lambda/module/modules/player/PacketMine.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,8 @@ object PacketMine : Module(
111111
::collectDrops,
112112
::entityReach,
113113
::breakBlocks,
114-
::interactBlocks
114+
::interactBlocks,
115+
::placeBlocks
115116
)
116117
::maxBuildDependencies.edit { defaultValue(0) }
117118
}

0 commit comments

Comments
 (0)