Skip to content

Commit f492c5a

Browse files
committed
fixed config variable in Request
1 parent 943d942 commit f492c5a

File tree

10 files changed

+22
-21
lines changed

10 files changed

+22
-21
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,6 @@ data class BreakContext(
6767

6868
fun requestDependencies(breakRequest: BreakRequest, minKeepTicks: Int = 0): Boolean {
6969
val request = HotbarRequest(hotbarIndex, breakRequest.hotbar, breakRequest.hotbar.keepTicks.coerceAtLeast(minKeepTicks))
70-
return request.hotbar.request(request, false).done
70+
return request.config.request(request, false).done
7171
}
7272
}

common/src/main/kotlin/com/lambda/interaction/construction/context/InteractionContext.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ class InteractionContext(
6767

6868
fun requestDependencies(request: InteractionRequest): Boolean {
6969
val hotbarRequest = request.hotbar.request(HotbarRequest(hotbarIndex, request.hotbar), false)
70-
val validRotation = if (request.interact.rotate) {
70+
val validRotation = if (request.config.rotate) {
7171
request.rotation.request(rotation, false).done
7272
} else true
7373
return hotbarRequest.done && validRotation

common/src/main/kotlin/com/lambda/interaction/request/Request.kt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,8 @@
1717

1818
package com.lambda.interaction.request
1919

20-
abstract class Request(
21-
val config: RequestConfig<*>
22-
) {
20+
abstract class Request {
21+
abstract val config: RequestConfig<*>
2322
var fresh = true
2423

2524
abstract val done: Boolean

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@ data class BreakRequest(
4242
val inventory: InventoryConfig,
4343
val interact: InteractionConfig,
4444
val build: BuildConfig
45-
) : Request(build.breaking) {
45+
) : Request() {
46+
override val config = build.breaking
4647
var onStart: ((BlockPos) -> Unit)? = null
4748
var onUpdate: ((BlockPos) -> Unit)? = null
4849
var onStop: ((BlockPos) -> Unit)? = null

common/src/main/kotlin/com/lambda/interaction/request/hotbar/HotbarManager.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ object HotbarManager : RequestHandler<HotbarRequest>(
7575
}
7676

7777
override fun SafeContext.handleRequest(request: HotbarRequest) {
78-
val config = request.hotbar
78+
val config = request.config
7979
maxSwapsThisTick = config.swapsPerTick
8080
swapDelay = swapDelay.coerceAtMost(config.swapDelay)
8181

@@ -114,7 +114,7 @@ object HotbarManager : RequestHandler<HotbarRequest>(
114114
private fun SafeContext.checkResetSwap() {
115115
activeRequest?.let { activeInfo ->
116116
val canStopSwap = swapsThisTick < maxSwapsThisTick
117-
if (activeInfo.keepTicks <= 0 && tickStage in activeInfo.hotbar.sequenceStageMask && canStopSwap) {
117+
if (activeInfo.keepTicks <= 0 && tickStage in activeInfo.config.sequenceStageMask && canStopSwap) {
118118
activeRequest = null
119119
interaction.syncSelectedSlot()
120120
}

common/src/main/kotlin/com/lambda/interaction/request/hotbar/HotbarRequest.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@ import com.lambda.interaction.request.Request
2121

2222
class HotbarRequest(
2323
val slot: Int,
24-
val hotbar: HotbarConfig,
25-
var keepTicks: Int = hotbar.keepTicks,
26-
var swapPause: Int = hotbar.swapPause
27-
) : Request(hotbar) {
24+
override val config: HotbarConfig,
25+
var keepTicks: Int = config.keepTicks,
26+
var swapPause: Int = config.swapPause
27+
) : Request() {
2828
var activeRequestAge = 0
2929
var swapPauseAge = 0
3030

common/src/main/kotlin/com/lambda/interaction/request/interacting/InteractionManager.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,15 +87,15 @@ object InteractionManager : RequestHandler<InteractionRequest>(
8787
val iterator = potentialInteractions.iterator()
8888
while (iterator.hasNext()) {
8989
if (interactionsThisTick + 1 > maxInteractionsThisTick) break
90-
val interact = request.interact
90+
val config = request.config
9191
val ctx = iterator.next()
9292

9393
if (!ctx.requestDependencies(request)) return
9494

95-
if (interact.interactConfirmationMode == InteractionConfig.InteractConfirmationMode.None) {
96-
InteractionInfo(ctx, request.pendingInteractionsList, interact).startPending()
95+
if (config.interactConfirmationMode == InteractionConfig.InteractConfirmationMode.None) {
96+
InteractionInfo(ctx, request.pendingInteractionsList, config).startPending()
9797
}
98-
if (interact.interactConfirmationMode != InteractionConfig.InteractConfirmationMode.AwaitThenInteract) {
98+
if (config.interactConfirmationMode != InteractionConfig.InteractConfirmationMode.AwaitThenInteract) {
9999
interaction.interactBlock(player, Hand.MAIN_HAND, ctx.result)
100100
} else {
101101
interaction.sendSequencedPacket(world) { sequence ->

common/src/main/kotlin/com/lambda/interaction/request/interacting/InteractionRequest.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,11 @@ data class InteractionRequest(
3232
val contexts: Collection<InteractionContext>,
3333
val onInteract: ((BlockPos) -> Unit)?,
3434
val pendingInteractionsList: MutableCollection<BuildContext>,
35-
val interact: InteractionConfig,
35+
override val config: InteractionConfig,
3636
val build: BuildConfig,
3737
val hotbar: HotbarConfig,
3838
val rotation: RotationConfig
39-
) : Request(interact) {
39+
) : Request() {
4040
override val done: Boolean
4141
get() = contexts.all { mc.world?.getBlockState(it.blockPos)?.matches(it.expectedState) == true }
4242
}

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ data class PlaceRequest(
3434
val hotbar: HotbarConfig,
3535
val pendingInteractions: MutableCollection<BuildContext>,
3636
val onPlace: () -> Unit
37-
) : Request(build.placing) {
37+
) : Request() {
38+
override val config = build.placing
3839
override val done: Boolean
3940
get() = runSafe {
4041
contexts.all { it.expectedState.matches(blockState(it.blockPos)) }

common/src/main/kotlin/com/lambda/interaction/request/rotating/RotationRequest.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,12 @@ import com.lambda.threading.runSafe
2424
data class RotationRequest(
2525
val target: RotationTarget,
2626
val mode: RotationMode,
27-
val rot: RotationConfig,
27+
override val config: RotationConfig,
2828
var keepTicks: Int = 3,
2929
var decayTicks: Int = 0,
3030
val turnSpeed: () -> Double = { 180.0 },
3131
val speedMultiplier: Double = 1.0
32-
) : Request(rot) {
32+
) : Request() {
3333
var age = 0
3434

3535
constructor(

0 commit comments

Comments
 (0)