@@ -61,15 +61,15 @@ object HotbarManager : RequestHandler<HotbarRequest>(
6161 listen<TickEvent .Post >(priority = Int .MIN_VALUE ) {
6262 swapsThisTick = 0
6363 if (swapDelay > 0 ) swapDelay--
64- val slotInfo = activeRequest ? : return @listen
64+ val activeInfo = activeRequest ? : return @listen
6565
66- slotInfo.swapPauseAge++
67- slotInfo.activeRequestAge++
68- slotInfo.keepTicks--
69-
70- if (slotInfo.keepTicks <= 0 ) {
66+ if (activeInfo.keepTicks <= 0 ) {
7167 activeRequest = null
7268 }
69+
70+ activeInfo.swapPauseAge++
71+ activeInfo.activeRequestAge++
72+ activeInfo.keepTicks--
7373 }
7474
7575 listen<InventoryEvent .HotbarSlot .Update >(priority = Int .MIN_VALUE ) {
@@ -80,11 +80,17 @@ object HotbarManager : RequestHandler<HotbarRequest>(
8080 }
8181
8282 override fun SafeContext.handleRequest (request : HotbarRequest ) {
83- val hotbar = request.hotbar
84- maxSwapsThisTick = hotbar.swapsPerTick
85- swapDelay = swapDelay.coerceAtMost(hotbar.swapDelay)
83+ activeRequest?.let { activeInfo ->
84+ if (activeInfo.keepTicks <= 0 ) {
85+ activeRequest = null
86+ }
87+ }
88+
89+ val config = request.hotbar
90+ maxSwapsThisTick = config.swapsPerTick
91+ swapDelay = swapDelay.coerceAtMost(config.swapDelay)
8692
87- if (tickStage !in hotbar .sequenceStageMask) return
93+ if (tickStage !in config .sequenceStageMask) return
8894
8995 if (request.slot != activeRequest?.slot) {
9096 if (swapsThisTick + 1 > maxSwapsThisTick || swapDelay > 0 ) return
@@ -94,7 +100,7 @@ object HotbarManager : RequestHandler<HotbarRequest>(
94100 }
95101
96102 swapsThisTick++
97- swapDelay = hotbar .swapDelay
103+ swapDelay = config .swapDelay
98104 } else activeRequest?.let { current ->
99105 request.swapPauseAge = current.swapPauseAge
100106 if (current.swappedThisTick && current.keeping) return
@@ -106,10 +112,12 @@ object HotbarManager : RequestHandler<HotbarRequest>(
106112 }
107113
108114 private fun SafeContext.checkResetSwap () {
109- activeRequest?.let { active ->
110- if (active.keepTicks <= 0 ) {
115+ activeRequest?.let { activeInfo ->
116+ if (activeInfo.keepTicks <= 0 ) {
117+ if (tickStage in activeInfo.hotbar.sequenceStageMask) {
118+ interaction.syncSelectedSlot()
119+ }
111120 activeRequest = null
112- interaction.syncSelectedSlot()
113121 }
114122 }
115123 }
0 commit comments