@@ -21,6 +21,7 @@ import com.lambda.config.groups.BuildConfig
2121import com.lambda.context.SafeContext
2222import com.lambda.event.EventFlow.post
2323import com.lambda.event.events.MovementEvent
24+ import com.lambda.event.events.TickEvent
2425import com.lambda.event.events.UpdateManagerEvent
2526import com.lambda.event.events.WorldEvent
2627import com.lambda.event.listener.SafeListener.Companion.listen
@@ -59,11 +60,24 @@ object PlaceManager : RequestHandler<PlaceRequest>() {
5960 ) { info(" ${it::class .simpleName} at ${it.context.expectedPos.toShortString()} timed out" ) }
6061
6162 private var rotation: RotationRequest ? = null
63+ private var validRotation = false
6264
6365 val blockedPositions
6466 get() = pendingInteractions.map { it.context.expectedPos }
6567
6668 init {
69+ listen<TickEvent .Pre > {
70+ currentRequest?.let { request ->
71+ val notSneaking = ! player.isSneaking
72+ val hotbarRequest = request.hotbarConfig.request(HotbarRequest (request.placeContext.hotbarIndex))
73+ val invalidRotation = request.buildConfig.placeSettings.rotateForPlace && ! validRotation
74+ if ((request.placeContext.sneak && notSneaking) || ! hotbarRequest.done || invalidRotation)
75+ return @listen
76+
77+ placeBlock(request, Hand .MAIN_HAND )
78+ }
79+ }
80+
6781 onRotate(priority = Int .MIN_VALUE ) {
6882 preEvent()
6983
@@ -95,18 +109,8 @@ object PlaceManager : RequestHandler<PlaceRequest>() {
95109 }
96110
97111 onRotatePost {
98- currentRequest?.let { request ->
99- val notSneaking = ! player.isSneaking
100- val hotbarRequest = request.hotbarConfig.request(HotbarRequest (request.placeContext.hotbarIndex))
101- val invalidRotation = request.buildConfig.placeSettings.rotateForPlace && rotation?.done != true
102- if ((request.placeContext.sneak && notSneaking) || ! hotbarRequest.done || invalidRotation) {
103- postEvent()
104- return @onRotatePost
105- }
106-
107- placeBlock(request, Hand .MAIN_HAND )
108- postEvent()
109- }
112+ validRotation = rotation?.done == true
113+ postEvent()
110114 }
111115
112116 listen<MovementEvent .InputUpdate > {
0 commit comments