Skip to content

Commit f533cd9

Browse files
committed
Fix Meteor compatibility
1 parent 9ead12d commit f533cd9

File tree

5 files changed

+30
-31
lines changed

5 files changed

+30
-31
lines changed

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package com.lambda.mixin.entity;
22

33
import com.lambda.Lambda;
4+
import com.lambda.event.EventFlow;
5+
import com.lambda.event.events.EntityEvent;
46
import com.lambda.interaction.RotationManager;
57
import com.lambda.util.math.Vec2d;
68
import net.minecraft.entity.Entity;
@@ -9,7 +11,9 @@
911
import org.spongepowered.asm.mixin.Mixin;
1012
import org.spongepowered.asm.mixin.Shadow;
1113
import org.spongepowered.asm.mixin.injection.At;
14+
import org.spongepowered.asm.mixin.injection.Inject;
1215
import org.spongepowered.asm.mixin.injection.Redirect;
16+
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
1317

1418
@Mixin(Entity.class)
1519
public abstract class EntityMixin {
@@ -61,4 +65,9 @@ float fixDirectionPitch2(Entity entity) {
6165

6266
return (float) rot.getY();
6367
}
68+
69+
@Inject(method = "changeLookDirection", at = @At("HEAD"), cancellable = true)
70+
private void changeLookDirection(double cursorDeltaX, double cursorDeltaY, CallbackInfo ci) {
71+
if (EventFlow.post(new EntityEvent.ChangeLookDirection(cursorDeltaX, cursorDeltaY)).isCanceled()) ci.cancel();
72+
}
6473
}

common/src/main/java/com/lambda/mixin/input/MouseMixin.java

Lines changed: 0 additions & 21 deletions
This file was deleted.
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package com.lambda.event.events
2+
3+
import com.lambda.event.Event
4+
import com.lambda.event.callback.Cancellable
5+
import com.lambda.event.callback.ICancellable
6+
7+
abstract class EntityEvent : Event {
8+
class ChangeLookDirection(
9+
val deltaYaw: Double,
10+
val deltaPitch: Double,
11+
) : EntityEvent(), ICancellable by Cancellable()
12+
}

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

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,7 @@ package com.lambda.module.modules.player
33
import baritone.utils.PlayerMovementInput
44
import com.lambda.Lambda.mc
55
import com.lambda.config.groups.RotationSettings
6-
import com.lambda.event.events.ConnectionEvent
7-
import com.lambda.event.events.MovementEvent
8-
import com.lambda.event.events.RenderEvent
9-
import com.lambda.event.events.RotationEvent
6+
import com.lambda.event.events.*
107
import com.lambda.event.listener.SafeListener.Companion.listener
118
import com.lambda.interaction.rotation.Rotation
129
import com.lambda.interaction.rotation.Rotation.Companion.rotationTo
@@ -59,11 +56,6 @@ object Freecam : Module(
5956
}
6057
}
6158

62-
@JvmStatic
63-
fun updateRotation(deltaYaw: Double, deltaPitch: Double) {
64-
rotation = rotation.withDelta(deltaYaw * SENSITIVITY_FACTOR, deltaPitch * SENSITIVITY_FACTOR)
65-
}
66-
6759
/**
6860
* @see net.minecraft.entity.Entity.changeLookDirection
6961
*/
@@ -90,6 +82,14 @@ object Freecam : Module(
9082
it.context = RotationContext(rotation, rotationConfig)
9183
}
9284

85+
listener<EntityEvent.ChangeLookDirection> {
86+
rotation = rotation.withDelta(
87+
it.deltaYaw * SENSITIVITY_FACTOR,
88+
it.deltaPitch * SENSITIVITY_FACTOR
89+
)
90+
it.cancel()
91+
}
92+
9393
listener<MovementEvent.InputUpdate> { event ->
9494
// Don't block baritone from working
9595
if (event.input !is PlayerMovementInput) {

common/src/main/resources/lambda.mixins.common.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
"entity.PlayerEntityMixin",
1616
"input.KeyBindingMixin",
1717
"input.KeyboardMixin",
18-
"input.MouseMixin",
1918
"items.BarrierBlockMixin",
2019
"items.TridentMixin",
2120
"render.BlockRenderManagerMixin",

0 commit comments

Comments
 (0)