@@ -22,6 +22,8 @@ import com.lambda.context.SafeContext
2222import com.lambda.event.EventFlow.post
2323import com.lambda.event.events.ConnectionEvent
2424import com.lambda.event.events.PacketEvent
25+ import com.lambda.event.events.PlayerEvent
26+ import com.lambda.event.events.RenderEvent
2527import com.lambda.event.events.TickEvent
2628import com.lambda.event.events.UpdateManagerEvent
2729import com.lambda.event.listener.SafeListener.Companion.listen
@@ -37,9 +39,11 @@ import com.lambda.util.extension.rotation
3739import com.lambda.util.math.MathUtils.toRadian
3840import com.lambda.util.math.Vec2d
3941import com.lambda.util.math.lerp
42+ import com.lambda.util.world.raycast.RayCastUtils.orMiss
4043import net.minecraft.client.input.Input
4144import net.minecraft.network.packet.s2c.play.PlayerPositionLookS2CPacket
4245import net.minecraft.util.PlayerInput
46+ import net.minecraft.util.hit.EntityHitResult
4347import net.minecraft.util.math.Vec2f
4448import kotlin.math.PI
4549import kotlin.math.atan2
@@ -79,6 +83,29 @@ object RotationManager : RequestHandler<RotationRequest>(
7983 changedThisTick = false
8084 }
8185
86+ listen<RenderEvent .UpdateTarget > {
87+ if (activeRequest == null ) return @listen
88+ it.cancel()
89+
90+ val eye = player.eyePos
91+ val entityHit = player.rotation.rayCast(player.entityInteractionRange, eye).orMiss
92+ mc.targetedEntity = (entityHit as ? EntityHitResult )?.entity
93+ val blockHit = player.rotation.rayCast(player.blockInteractionRange, eye).orMiss
94+ mc.crosshairTarget = blockHit
95+ }
96+
97+ listen<PlayerEvent .Interact .Block > {
98+ activeRotation = player.rotation
99+ }
100+
101+ listen<PlayerEvent .Interact .Entity > {
102+ activeRotation = player.rotation
103+ }
104+
105+ listen<PlayerEvent .Interact .Item > {
106+ activeRotation = player.rotation
107+ }
108+
82109 listen<PacketEvent .Receive .Post >(priority = Int .MIN_VALUE ) { event ->
83110 val packet = event.packet
84111 if (packet !is PlayerPositionLookS2CPacket ) return @listen
0 commit comments