Skip to content

Commit 8e40f29

Browse files
committed
Oopsie fixes
1 parent 7b15b40 commit 8e40f29

File tree

7 files changed

+23
-29
lines changed

7 files changed

+23
-29
lines changed

common/src/main/java/com/lambda/mixin/entity/LivingEntityMixin.java

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,6 @@ void onJump(CallbackInfo ci) {
4545
self.velocityDirty = true;
4646
}
4747

48-
@Inject(method = "tickMovement", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/LivingEntity;isImmobile()Z"))
49-
void onTravelH(CallbackInfo ci) {
50-
Entity self = (Entity) (Object) this;
51-
if (self != Lambda.getMc().player) return;
52-
53-
RotationManager.update();
54-
}
55-
5648
@Redirect(method = "travel", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/LivingEntity;getPitch()F"))
5749
private float hookModifyFallFlyingPitch(LivingEntity entity) {
5850
Float pitch = RotationManager.getMovementPitch();

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

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,21 +10,24 @@ abstract class RotationEvent : Event {
1010
/**
1111
* This event allows listeners to register a rotation request to be executed that tick.
1212
*
13-
* CAUTION: The listener with the lowest priority will win as it is the last to override the context.
13+
* Only one rotation can "win" each tick
14+
*
15+
* CAUTION: The listener with the LOWEST priority will win as it is the last to override the context.
1416
*
1517
* @property context The rotation context that listeners can set. Only one rotation can "win" each tick.
1618
*/
17-
class Pre : RotationEvent(), ICancellable by Cancellable() {
18-
// Only one rotation can "win" each tick
19-
var context: RotationContext? = null
20-
21-
init {
22-
// Always check if baritone wants to rotate as well
23-
RotationManager.BaritoneProcessor.baritoneContext?.let { context ->
24-
this.context = context
25-
}
26-
}
19+
class Update : RotationEvent(), ICancellable by Cancellable() {
20+
// Always check if baritone wants to rotate as well
21+
var context = RotationManager.BaritoneProcessor.baritoneContext
2722
}
2823

24+
/**
25+
* This event allows listeners to modify the yaw relative to which the movement input is going to be constructed
26+
*
27+
* @property strafeYaw The angle at which the player will move when pressing W
28+
* Changing this value will never force the anti cheat to flag you because RotationManager is designed to modify the key input instead
29+
*/
30+
class Strafe(var strafeYaw: Double) : RotationEvent()
31+
2932
class Post(val context: RotationContext) : RotationEvent()
3033
}

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

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,16 +36,14 @@ object RotationManager : Loadable {
3636
private var keepTicks = 0
3737
private var pauseTicks = 0
3838

39-
@JvmStatic
40-
fun update() =
41-
runSafe {
42-
RotationEvent.Pre().post {
39+
init {
40+
listener<TickEvent.Pre> {
41+
RotationEvent.Update().post {
4342
rotate(context)
4443
currentContext?.let { RotationEvent.Post(it).post() }
4544
}
4645
}
4746

48-
init {
4947
listener<PacketEvent.Send.Post> { event ->
5048
val packet = event.packet
5149
if (packet !is PlayerPositionLookS2CPacket) return@listener
@@ -208,7 +206,8 @@ object RotationManager : Loadable {
208206
val baritoneYaw = if (handledByBaritone) baritoneContext?.rotation?.yaw else null
209207

210208
// The yaw relative to which the movement was constructed
211-
val movementYaw = baritoneYaw ?: playerYaw
209+
val strafeEvent = RotationEvent.Strafe(baritoneYaw ?: playerYaw)
210+
val movementYaw = strafeEvent.post().strafeYaw
212211

213212
// Actual yaw used to move the player
214213
val actualYaw = currentRotation.yaw

common/src/main/kotlin/com/lambda/module/modules/player/Freecam.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ object Freecam : Module(
8282
mc.options.perspective = lastPerspective
8383
}
8484

85-
listener<RotationEvent.Pre>(Int.MAX_VALUE) {
85+
listener<RotationEvent.Update>(Int.MAX_VALUE) {
8686
if (!rotateToTarget) return@listener
8787
val target = mc.crosshairTarget?.orNull ?: return@listener
8888

common/src/main/kotlin/com/lambda/task/tasks/BreakBlock.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ class BreakBlock @Ta5kBuilder constructor(
5151
}
5252

5353
init {
54-
listener<RotationEvent.Pre> { event ->
54+
listener<RotationEvent.Update> { event ->
5555
if (!rotate) return@listener
5656
event.context = lookAtBlock(blockPos, rotationConfig, interactionConfig, sides)
5757
}

common/src/main/kotlin/com/lambda/task/tasks/OpenContainer.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ class OpenContainer<H : ScreenHandler>(
4343
}
4444
}
4545

46-
listener<RotationEvent.Pre> { event ->
46+
listener<RotationEvent.Update> { event ->
4747
if (screenHandler != null) return@listener
4848
event.context = lookAtBlock(blockPos, rotationConfig, interactionConfig, sides)
4949
}

common/src/main/kotlin/com/lambda/task/tasks/PlaceBlock.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ class PlaceBlock @Ta5kBuilder constructor(
4141
}
4242

4343
init {
44-
listener<RotationEvent.Pre> { event ->
44+
listener<RotationEvent.Update> { event ->
4545
if (!rotate) return@listener
4646
event.context = ctx.rotation
4747
}

0 commit comments

Comments
 (0)