Skip to content

Commit e9d244c

Browse files
committed
Merge branch 'master' into feature/combat
2 parents 31c2ff8 + a2de9ce commit e9d244c

File tree

16 files changed

+75
-75
lines changed

16 files changed

+75
-75
lines changed

common/src/main/kotlin/com/lambda/event/events/RotationEvent.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ package com.lambda.event.events
2020
import com.lambda.event.Event
2121
import com.lambda.event.callback.Cancellable
2222
import com.lambda.event.callback.ICancellable
23-
import com.lambda.interaction.rotation.RotationContext
23+
import com.lambda.interaction.rotation.RotationRequest
2424
import net.minecraft.client.input.Input
2525

2626
sealed class RotationEvent {
@@ -31,9 +31,9 @@ sealed class RotationEvent {
3131
*
3232
* CAUTION: The listener with the LOWEST priority will win as it is the last to override the context
3333
*
34-
* @property context The rotation context that listeners can set. Only one rotation can "win" each tick
34+
* @property request The rotation context that listeners can set. Only one rotation can "win" each tick
3535
*/
36-
data class Update(var context: RotationContext?) : ICancellable by Cancellable()
36+
data class Update(var request: RotationRequest?) : ICancellable by Cancellable()
3737

3838
/**
3939
* This event allows listeners to modify the yaw relative to which the movement input is going to be constructed
@@ -43,5 +43,5 @@ sealed class RotationEvent {
4343
*/
4444
data class StrafeInput(var strafeYaw: Double, val input: Input) : Event
4545

46-
data class Post(val context: RotationContext) : Event
46+
data class Post(val request: RotationRequest) : Event
4747
}

common/src/main/kotlin/com/lambda/interaction/RotationManager.kt

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ import com.lambda.interaction.rotation.Rotation
3131
import com.lambda.interaction.rotation.Rotation.Companion.angleDifference
3232
import com.lambda.interaction.rotation.Rotation.Companion.fixSensitivity
3333
import com.lambda.interaction.rotation.Rotation.Companion.slerp
34-
import com.lambda.interaction.rotation.RotationContext
34+
import com.lambda.interaction.rotation.RotationRequest
3535
import com.lambda.interaction.rotation.RotationMode
3636
import com.lambda.module.modules.client.Baritone
3737
import com.lambda.threading.runGameScheduled
@@ -52,7 +52,7 @@ object RotationManager : Loadable {
5252
var currentRotation = Rotation.ZERO
5353
private var prevRotation = Rotation.ZERO
5454

55-
var currentContext: RotationContext? = null
55+
var currentContext: RotationRequest? = null
5656

5757
private var keepTicks = 0
5858
private var pauseTicks = 0
@@ -66,18 +66,18 @@ object RotationManager : Loadable {
6666
block: RequestRotationBuilder.() -> Unit,
6767
) {
6868
val builder = RequestRotationBuilder().apply(block)
69-
var requested: RotationContext? = null
69+
var requested: RotationRequest? = null
7070

7171
listen<RotationEvent.Update>(priority, alwaysListen) { event ->
72-
builder.onUpdate?.invoke(this, event.context)?.let { context ->
72+
builder.onUpdate?.invoke(this, event.request)?.let { context ->
7373
if (!context.config.rotate) return@let
74-
event.context = context
74+
event.request = context
7575
requested = context
7676
}
7777
}
7878

7979
listen<RotationEvent.Post> { event ->
80-
val context = event.context
80+
val context = event.request
8181
if (!context.config.rotate) return@listen
8282
if (context != requested) return@listen
8383
if (!context.isValid) return@listen
@@ -89,24 +89,24 @@ object RotationManager : Loadable {
8989
annotation class RotationDsl
9090

9191
class RequestRotationBuilder {
92-
var onUpdate: (SafeContext.(lastContext: RotationContext?) -> RotationContext?)? = null
93-
var onReceive: (SafeContext.(context: RotationContext) -> Unit)? = null
92+
var onUpdate: (SafeContext.(lastContext: RotationRequest?) -> RotationRequest?)? = null
93+
var onReceive: (SafeContext.(context: RotationRequest) -> Unit)? = null
9494

9595
@RotationDsl
96-
fun request(block: SafeContext.(lastContext: RotationContext?) -> RotationContext?) {
96+
fun request(block: SafeContext.(lastContext: RotationRequest?) -> RotationRequest?) {
9797
onUpdate = block
9898
}
9999

100100
@RotationDsl
101-
fun finished(block: SafeContext.(context: RotationContext) -> Unit) {
101+
fun finished(block: SafeContext.(context: RotationRequest) -> Unit) {
102102
onReceive = block
103103
}
104104
}
105105

106106
@JvmStatic
107107
fun update() = runSafe {
108108
RotationEvent.Update(BaritoneProcessor.poolContext()).post {
109-
rotate(context)
109+
rotate(request)
110110

111111
currentContext?.let {
112112
RotationEvent.Post(it).post()
@@ -129,7 +129,7 @@ object RotationManager : Loadable {
129129
}
130130
}
131131

132-
private fun rotate(newContext: RotationContext?) = runSafe {
132+
private fun rotate(newContext: RotationRequest?) = runSafe {
133133
prevRotation = currentRotation
134134

135135
keepTicks--
@@ -225,9 +225,9 @@ object RotationManager : Loadable {
225225
}
226226

227227
object BaritoneProcessor {
228-
private var baritoneContext: RotationContext? = null
228+
private var baritoneContext: RotationRequest? = null
229229

230-
fun poolContext(): RotationContext? {
230+
fun poolContext(): RotationRequest? {
231231
val ctx = baritoneContext
232232
baritoneContext = null
233233
return ctx
@@ -242,7 +242,7 @@ object RotationManager : Loadable {
242242

243243
@JvmStatic
244244
fun handleBaritoneRotation(yaw: Float, pitch: Float) {
245-
baritoneContext = RotationContext(Rotation(yaw, pitch), Baritone.rotation.apply {
245+
baritoneContext = RotationRequest(Rotation(yaw, pitch), Baritone.rotation.apply {
246246
if (rotationMode != RotationMode.SILENT) return@apply
247247
rotationMode = RotationMode.SYNC
248248
})

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

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

2020
import com.lambda.context.SafeContext
21-
import com.lambda.interaction.rotation.RotationContext
21+
import com.lambda.interaction.rotation.RotationRequest
2222
import com.lambda.util.world.raycast.RayCastUtils.distanceTo
2323
import net.minecraft.block.BlockState
2424
import net.minecraft.util.Hand
@@ -30,7 +30,7 @@ import net.minecraft.util.math.Vec3d
3030
data class BreakContext(
3131
override val pov: Vec3d,
3232
override val result: BlockHitResult,
33-
override val rotation: RotationContext,
33+
override val rotation: RotationRequest,
3434
override val checkedState: BlockState,
3535
override var hand: Hand,
3636
val instantBreak: Boolean,

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

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

2020
import com.lambda.interaction.construction.result.Drawable
21-
import com.lambda.interaction.rotation.RotationContext
21+
import com.lambda.interaction.rotation.RotationRequest
2222
import net.minecraft.block.BlockState
2323
import net.minecraft.util.Hand
2424
import net.minecraft.util.hit.BlockHitResult
@@ -33,7 +33,7 @@ interface BuildContext : Comparable<BuildContext>, Drawable {
3333
val expectedPos: BlockPos
3434
val checkedState: BlockState
3535
val hand: Hand
36-
val rotation: RotationContext
36+
val rotation: RotationRequest
3737

3838
override fun compareTo(other: BuildContext): Int {
3939
return compareBy<BuildContext> {

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import com.lambda.context.SafeContext
2121
import com.lambda.graphics.renderer.esp.DirectionMask
2222
import com.lambda.graphics.renderer.esp.DirectionMask.exclude
2323
import com.lambda.interaction.construction.verify.TargetState
24-
import com.lambda.interaction.rotation.RotationContext
24+
import com.lambda.interaction.rotation.RotationRequest
2525
import com.lambda.threading.runSafe
2626
import com.lambda.util.BlockUtils
2727
import com.lambda.util.Communication.warn
@@ -36,7 +36,7 @@ import java.awt.Color
3636
data class PlaceContext(
3737
override val pov: Vec3d,
3838
override val result: BlockHitResult,
39-
override val rotation: RotationContext,
39+
override val rotation: RotationRequest,
4040
override val distance: Double,
4141
override val expectedState: BlockState,
4242
override val checkedState: BlockState,

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ import com.lambda.interaction.construction.verify.TargetState
3030
import com.lambda.interaction.material.container.ContainerManager.findBestAvailableTool
3131
import com.lambda.interaction.rotation.Rotation.Companion.rotation
3232
import com.lambda.interaction.rotation.Rotation.Companion.rotationTo
33-
import com.lambda.interaction.rotation.RotationContext
33+
import com.lambda.interaction.rotation.RotationRequest
3434
import com.lambda.interaction.visibilty.VisibilityChecker.getVisibleSurfaces
3535
import com.lambda.interaction.visibilty.VisibilityChecker.optimum
3636
import com.lambda.interaction.visibilty.VisibilityChecker.scanSurfaces
@@ -195,7 +195,7 @@ object BuildSimulator {
195195
validHits.keys.optimum?.let { optimum ->
196196
validHits.minByOrNull { optimum distSq it.key }?.let { closest ->
197197
val optimumRotation = eye.rotationTo(closest.key)
198-
RotationContext(optimumRotation, rotation, closest.value, verify)
198+
RotationRequest(optimumRotation, rotation, closest.value, verify)
199199
}
200200
}?.let { rotation ->
201201
val optimalStack = target.getStack(world, pos)
@@ -209,7 +209,7 @@ object BuildSimulator {
209209
val usageContext = ItemUsageContext(
210210
fakePlayer,
211211
Hand.MAIN_HAND,
212-
rotation.hitResult?.blockResult,
212+
rotation.checkedResult?.blockResult,
213213
)
214214
val cachePos = CachedBlockPosition(
215215
usageContext.world,
@@ -269,7 +269,7 @@ object BuildSimulator {
269269
return@forEach
270270
}
271271

272-
val blockHit = rotation.hitResult?.blockResult ?: return@forEach
272+
val blockHit = rotation.checkedResult?.blockResult ?: return@forEach
273273
val hitBlock = blockHit.blockPos.blockState(world).block
274274
val shouldSneak = hitBlock in BlockUtils.interactionBlacklist
275275

@@ -382,11 +382,11 @@ object BuildSimulator {
382382
/* the player is buried inside the block */
383383
if (boxes.any { it.contains(eye) }) {
384384
currentCast?.blockResult?.let { blockHit ->
385-
val rotationContext = RotationContext(currentRotation, rotation, currentCast, verify)
385+
val rotationRequest = RotationRequest(currentRotation, rotation, currentCast, verify)
386386
val breakContext = BreakContext(
387387
eye,
388388
blockHit,
389-
rotationContext,
389+
rotationRequest,
390390
state,
391391
player.activeHand,
392392
instantBreakable(state, pos)
@@ -430,10 +430,10 @@ object BuildSimulator {
430430
validHits.keys.optimum?.let { optimum ->
431431
validHits.minByOrNull { optimum distSq it.key }?.let { closest ->
432432
val optimumRotation = eye.rotationTo(closest.key)
433-
RotationContext(optimumRotation, rotation, closest.value, verify)
433+
RotationRequest(optimumRotation, rotation, closest.value, verify)
434434
}
435435
}?.let { bestRotation ->
436-
val blockHit = bestRotation.hitResult?.blockResult ?: return@let
436+
val blockHit = bestRotation.checkedResult?.blockResult ?: return@let
437437

438438
val breakContext = BreakContext(
439439
eye,

common/src/main/kotlin/com/lambda/interaction/rotation/RotationContext.kt renamed to common/src/main/kotlin/com/lambda/interaction/rotation/RotationRequest.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@ import com.lambda.threading.runSafe
2323
import com.lambda.util.world.raycast.RayCastUtils.orMiss
2424
import net.minecraft.util.hit.HitResult
2525

26-
data class RotationContext(
26+
data class RotationRequest(
2727
val rotation: Rotation,
2828
val config: RotationConfig,
29-
val hitResult: HitResult? = null,
29+
val checkedResult: HitResult? = null,
3030
val verify: HitResult.() -> Boolean = { true },
3131
) {
3232
val isValid: Boolean get() = runSafe {

common/src/main/kotlin/com/lambda/interaction/visibilty/VisibilityChecker.kt

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import com.lambda.interaction.RotationManager
2424
import com.lambda.interaction.construction.verify.ScanMode
2525
import com.lambda.interaction.construction.verify.SurfaceScan
2626
import com.lambda.interaction.rotation.Rotation.Companion.rotationTo
27-
import com.lambda.interaction.rotation.RotationContext
27+
import com.lambda.interaction.rotation.RotationRequest
2828
import com.lambda.module.modules.client.TaskFlowModule
2929
import com.lambda.util.BlockUtils.blockState
3030
import com.lambda.util.extension.component6
@@ -52,7 +52,7 @@ object VisibilityChecker {
5252
* @param rotationConfig Specifies the rotation configuration settings.
5353
* @param interactionConfig Specifies interaction settings, such as range and resolution.
5454
* @param entity The entity to be looked at.
55-
* @return A [RotationContext] if a valid rotation was found; otherwise, null.
55+
* @return A [RotationRequest] if a valid rotation was found; otherwise, null.
5656
*/
5757
fun SafeContext.lookAtEntity(
5858
rotationConfig: RotationConfig,
@@ -70,14 +70,14 @@ object VisibilityChecker {
7070
* @param rotationConfig Specifies rotation configuration settings.
7171
* @param interactionConfig Specifies interaction settings, such as range and resolution.
7272
* @param sides Specifies the set of block sides to consider for targeting.
73-
* @return A [RotationContext] if a valid rotation was found; otherwise, null.
73+
* @return A [RotationRequest] if a valid rotation was found; otherwise, null.
7474
*/
7575
fun SafeContext.lookAtBlock(
7676
blockPos: BlockPos,
7777
rotationConfig: RotationConfig = TaskFlowModule.rotation,
7878
interactionConfig: InteractionConfig = TaskFlowModule.interact,
7979
sides: Set<Direction> = Direction.entries.toSet(),
80-
): RotationContext? {
80+
): RotationRequest? {
8181
val state = blockPos.blockState(world)
8282
val voxelShape = state.getOutlineShape(world, blockPos)
8383
val boundingBoxes = voxelShape.boundingBoxes.map { it.offset(blockPos) }
@@ -96,7 +96,7 @@ object VisibilityChecker {
9696
* @param reach The maximum reach distance for the interaction.
9797
* @param eye The player's eye position.
9898
* @param verify A lambda to verify if a [HitResult] meets the desired criteria.
99-
* @return A [RotationContext] if a valid rotation was found; otherwise, null.
99+
* @return A [RotationRequest] if a valid rotation was found; otherwise, null.
100100
*/
101101
fun SafeContext.findRotation(
102102
boxes: List<Box>,
@@ -106,12 +106,12 @@ object VisibilityChecker {
106106
reach: Double = interact.reach,
107107
eye: Vec3d = player.getCameraPosVec(1f),
108108
verify: HitResult.() -> Boolean,
109-
): RotationContext? {
109+
): RotationRequest? {
110110
val currentRotation = RotationManager.currentRotation
111111
val currentCast = currentRotation.rayCast(reach, eye)
112112

113113
if (boxes.any { it.contains(eye) }) {
114-
return RotationContext(currentRotation, rotationConfig, currentCast, verify)
114+
return RotationRequest(currentRotation, rotationConfig, currentCast, verify)
115115
}
116116

117117
val validHits = mutableMapOf<Vec3d, HitResult>()
@@ -140,7 +140,7 @@ object VisibilityChecker {
140140
validHits.keys.optimum?.let { optimum ->
141141
validHits.minByOrNull { optimum distSq it.key }?.let { closest ->
142142
val optimumRotation = eye.rotationTo(closest.key)
143-
return RotationContext(optimumRotation, rotationConfig, closest.value, verify)
143+
return RotationRequest(optimumRotation, rotationConfig, closest.value, verify)
144144
}
145145
}
146146

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ import com.lambda.interaction.RotationManager.rotate
3030
import com.lambda.interaction.rotation.Rotation
3131
import com.lambda.interaction.rotation.Rotation.Companion.dist
3232
import com.lambda.interaction.rotation.Rotation.Companion.rotationTo
33-
import com.lambda.interaction.rotation.RotationContext
33+
import com.lambda.interaction.rotation.RotationRequest
3434
import com.lambda.interaction.visibilty.VisibilityChecker.scanSurfaces
3535
import com.lambda.interaction.visibilty.VisibilityChecker.visibleSides
3636
import com.lambda.module.Module
@@ -149,7 +149,7 @@ object KillAura : Module(
149149
onDisable(::reset)
150150
}
151151

152-
private fun SafeContext.buildRotation(target: LivingEntity): RotationContext? {
152+
private fun SafeContext.buildRotation(target: LivingEntity): RotationRequest? {
153153
val currentRotation = RotationManager.currentRotation
154154

155155
val prediction = buildPlayerPrediction()
@@ -178,7 +178,7 @@ object KillAura : Module(
178178

179179
// Do not rotate if the eyes are inside the target's AABB
180180
if (box.contains(eye)) {
181-
return RotationContext(currentRotation, rotation)
181+
return RotationRequest(currentRotation, rotation)
182182
}
183183

184184
// Rotation stabilizer
@@ -249,7 +249,7 @@ object KillAura : Module(
249249
}
250250

251251
val predictOffset = target.moveDiff * targetPredict
252-
return RotationContext(eye.rotationTo(vec + predictOffset), rotation)
252+
return RotationRequest(eye.rotationTo(vec + predictOffset), rotation)
253253
}
254254

255255
private fun SafeContext.runAttack(target: LivingEntity) {

common/src/main/kotlin/com/lambda/module/modules/movement/Speed.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import com.lambda.event.events.MovementEvent
2424
import com.lambda.event.listener.SafeListener.Companion.listen
2525
import com.lambda.interaction.RotationManager.rotate
2626
import com.lambda.interaction.rotation.Rotation
27-
import com.lambda.interaction.rotation.RotationContext
27+
import com.lambda.interaction.rotation.RotationRequest
2828
import com.lambda.interaction.rotation.RotationMode
2929
import com.lambda.module.Module
3030
import com.lambda.module.tag.ModuleTag
@@ -160,7 +160,7 @@ object Speed : Module(
160160
val moveYaw = calcMoveYaw(yaw, input.roundedForward, input.roundedStrafing)
161161
val rotation = Rotation(moveYaw, lastContext?.rotation?.pitch ?: player.pitch.toDouble())
162162

163-
RotationContext(rotation, rotationConfig)
163+
RotationRequest(rotation, rotationConfig)
164164
}
165165
}
166166

0 commit comments

Comments
 (0)