Skip to content

Commit b5bc2b4

Browse files
committed
RequestConfig refactor and submitting from the request itself rather than the configs as theyre not coupled outside the request anymore
1 parent ae73453 commit b5bc2b4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+249
-276
lines changed

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,18 @@ package com.lambda.config.groups
2020
import com.lambda.config.Configurable
2121
import com.lambda.event.events.TickEvent
2222
import com.lambda.interaction.request.breaking.BreakConfig
23+
import com.lambda.interaction.request.breaking.BreakConfig.AnimationMode
24+
import com.lambda.interaction.request.breaking.BreakConfig.BreakConfirmationMode
25+
import com.lambda.interaction.request.breaking.BreakConfig.BreakMode
26+
import com.lambda.interaction.request.breaking.BreakConfig.SortMode
27+
import com.lambda.interaction.request.breaking.BreakConfig.SwingMode
2328
import com.lambda.util.BlockUtils.allSigns
2429
import java.awt.Color
2530

2631
class BreakSettings(
2732
c: Configurable,
2833
vis: () -> Boolean = { true }
29-
) : BreakConfig() {
34+
) : BreakConfig {
3035
val page by c.setting("Break Page", Page.General, visibility = vis)
3136
override val breakMode by c.setting("Break Mode", BreakMode.Packet) { vis() && page == Page.General }
3237
override val sorter by c.setting("Sorter", SortMode.Closest, "The order in which breaks are performed") { vis() && page == Page.General }

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import com.lambda.interaction.request.hotbar.HotbarConfig
2424
class HotbarSettings(
2525
c: Configurable,
2626
vis: () -> Boolean = { true }
27-
) : HotbarConfig() {
27+
) : HotbarConfig {
2828
override val keepTicks by c.setting("Keep Ticks", 3, 0..20, 1, "The number of ticks to keep the current hotbar selection active", " ticks", visibility = vis)
2929
override val swapDelay by c.setting("Swap Delay", 0, 0..3, 1, "The number of ticks delay before allowing another hotbar selection swap", " ticks", visibility = vis)
3030
override val swapsPerTick by c.setting("Swaps Per Tick", 3, 1..10, 1, "The number of hotbar selection swaps that can take place each tick") { swapDelay <= 0 && vis() }

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,12 @@
1818
package com.lambda.config.groups
1919

2020
import com.lambda.config.Configurable
21+
import com.lambda.interaction.request.interacting.InteractConfig
2122

2223
class InteractSettings(
2324
c: Configurable,
2425
vis: () -> Boolean = { true }
25-
) : InteractConfig() {
26+
) : InteractConfig {
2627
override val rotate by c.setting("Rotate For Interact", true, "Rotates the player to look at the block when interacting", visibility = vis)
2728
override val swingHand by c.setting("Swing On Interact", true, "Swings the players hand after interacting", visibility = vis)
2829
override val interactSwingType by c.setting("Interact Swing Type", BuildConfig.SwingType.Vanilla, "The style of swing") { vis() && swingHand }

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

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -17,54 +17,47 @@
1717

1818
package com.lambda.config.groups
1919

20-
import com.lambda.interaction.request.RequestConfig
21-
import com.lambda.interaction.request.interacting.InteractionManager
22-
import com.lambda.interaction.request.interacting.InteractionRequest
2320
import com.lambda.interaction.request.rotating.visibilty.PointSelection
2421

25-
abstract class InteractionConfig : RequestConfig<InteractionRequest>() {
22+
interface InteractionConfig {
2623
/**
2724
* Maximum entity interaction distance
2825
*/
29-
abstract val attackReach: Double
26+
val attackReach: Double
3027

3128
/**
3229
* Maximum block interaction distance
3330
*/
34-
abstract val interactReach: Double
31+
val interactReach: Double
3532

3633
/**
3734
* Maximum possible interaction distance
3835
*
3936
* Equals to `max(attackReach, placeReach)` if both are present. Equals to one of them otherwise
4037
*/
41-
abstract val scanReach: Double
38+
val scanReach: Double
4239

4340
/**
4441
* Whether to include the environment to the ray cast context.
4542
*
4643
* if false: skips walls for entities, skips entities for blocks.
4744
*/
48-
abstract val strictRayCast: Boolean
45+
val strictRayCast: Boolean
4946

5047
/**
5148
* Whether to check if an AABB side is visible.
5249
*/
53-
abstract val checkSideVisibility: Boolean
50+
val checkSideVisibility: Boolean
5451

5552
/**
5653
* Grid divisions count per surface of the hit box.
5754
*/
58-
abstract val resolution: Int
55+
val resolution: Int
5956

6057
/**
6158
* The way to select the best point.
6259
*/
63-
abstract val pointSelection: PointSelection
64-
65-
override fun requestInternal(request: InteractionRequest, queueIfClosed: Boolean) {
66-
InteractionManager.request(request, queueIfClosed)
67-
}
60+
val pointSelection: PointSelection
6861

6962
enum class InteractConfirmationMode {
7063
None,

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class InteractionSettings(
2626
c: Configurable,
2727
private val usage: InteractionMask,
2828
vis: () -> Boolean = { true },
29-
) : InteractionConfig() {
29+
) : InteractionConfig {
3030
// Reach
3131
private val useDefaultReach by c.setting("Default Reach", true, "Whether to use vanilla interaction ranges", visibility = vis)
3232
private val attackReachSetting = if (usage.entity) c.setting("Attack Reach", DEFAULT_ATTACK_REACH, 1.0..10.0, 0.01, "Maximum entity interaction distance") { vis() && !useDefaultReach } else null
@@ -40,7 +40,7 @@ class InteractionSettings(
4040
return if (useDefaultReach) DEFAULT_ATTACK_REACH else attackReachSetting!!.value
4141
}
4242

43-
override val interactReach: Double get() {
43+
override val interactReach: Double get() {
4444
check(usage.block) {
4545
"Given interaction config has no place reach implementation"
4646
}

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,14 @@
1818
package com.lambda.config.groups
1919

2020
import com.lambda.config.Configurable
21+
import com.lambda.interaction.request.inventory.InventoryConfig
22+
import com.lambda.interaction.request.inventory.InventoryConfig.Priority
2123
import com.lambda.util.item.ItemUtils
2224

2325
class InventorySettings(
2426
c: Configurable,
25-
vis: () -> Boolean = { true },
26-
) : InventoryConfig() {
27+
vis: () -> Boolean = { true }
28+
) : InventoryConfig {
2729
val page by c.setting("Inventory Page", Page.Container, "The page to open when the module is enabled", vis)
2830

2931
override val disposables by c.setting("Disposables", ItemUtils.defaultDisposables, "Items that will be included when checking for a free slot / are allowed to be droped when inventory is full") { vis() && page == Page.Container}

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,13 @@ package com.lambda.config.groups
2020
import com.lambda.config.Configurable
2121
import com.lambda.event.events.TickEvent
2222
import com.lambda.interaction.request.placing.PlaceConfig
23+
import com.lambda.interaction.request.placing.PlaceConfig.AirPlaceMode
24+
import com.lambda.interaction.request.placing.PlaceConfig.PlaceConfirmationMode
2325

2426
class PlaceSettings(
2527
c: Configurable,
2628
vis: () -> Boolean = { true }
27-
) : PlaceConfig() {
29+
) : PlaceConfig {
2830
override val rotateForPlace by c.setting("Rotate For Place", true, "Rotate towards block while placing", visibility = vis)
2931
override val airPlace by c.setting("Air Place", AirPlaceMode.None, "Allows for placing blocks without adjacent faces", visibility = vis)
3032
override val axisRotateSetting by c.setting("Axis Rotate", true, "Overrides the Rotate For Place setting and rotates the player on each axis to air place rotational blocks") { vis() && airPlace.isEnabled() }

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ import kotlin.random.Random
3030
class RotationSettings(
3131
c: Configurable,
3232
vis: () -> Boolean = { true }
33-
) : RotationConfig() {
33+
) : RotationConfig {
3434
override var rotationMode by c.setting("Mode", RotationMode.Sync, "SILENT - server-side rotation, SYNC - server-side rotation; client-side movement, LOCK - Lock camera, NONE - No rotation", visibility = vis)
3535

3636
/** How many ticks to keep the rotation before resetting */
@@ -66,4 +66,4 @@ class RotationSettings(
6666

6767
return sqrt(-2.0 * ln(u1)) * cos(2.0 * PI * u2)
6868
}
69-
}
69+
}

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

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,10 @@ data class BreakContext(
7676
withState(cachedState, blockPos, sideColor, result.side)
7777
}
7878

79-
fun requestDependencies(breakRequest: BreakRequest, minKeepTicks: Int = 0): Boolean {
80-
val request = HotbarRequest(hotbarIndex, breakRequest.hotbar, breakRequest.hotbar.keepTicks.coerceAtLeast(minKeepTicks))
81-
return request.config.request(request, false).done
82-
}
83-
}
79+
fun requestDependencies(breakRequest: BreakRequest, minKeepTicks: Int = 0): Boolean =
80+
HotbarRequest(
81+
hotbarIndex,
82+
breakRequest.hotbar,
83+
breakRequest.hotbar.keepTicks.coerceAtLeast(minKeepTicks)
84+
).submit(false).done
85+
}

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

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import com.lambda.graphics.renderer.esp.DirectionMask
2222
import com.lambda.graphics.renderer.esp.DirectionMask.exclude
2323
import com.lambda.interaction.request.hotbar.HotbarManager
2424
import com.lambda.interaction.request.hotbar.HotbarRequest
25-
import com.lambda.interaction.request.interacting.InteractionRequest
25+
import com.lambda.interaction.request.interacting.InteractRequest
2626
import com.lambda.interaction.request.rotating.RotationRequest
2727
import com.lambda.util.BlockUtils
2828
import com.lambda.util.BlockUtils.blockState
@@ -65,11 +65,9 @@ class InteractionContext(
6565
withState(blockState(result.blockPos), result.blockPos, sideColor, result.side)
6666
}
6767

68-
fun requestDependencies(request: InteractionRequest): Boolean {
69-
val hotbarRequest = request.hotbar.request(HotbarRequest(hotbarIndex, request.hotbar), false)
70-
val validRotation = if (request.config.rotate) {
71-
request.rotation.request(rotation, false).done
72-
} else true
68+
fun requestDependencies(request: InteractRequest): Boolean {
69+
val hotbarRequest = HotbarRequest(hotbarIndex, request.hotbar).submit(false)
70+
val validRotation = if (request.rotate) rotation.submit(false).done else true
7371
return hotbarRequest.done && validRotation
7472
}
7573
}

0 commit comments

Comments
 (0)