@@ -165,24 +165,22 @@ object BetterFirework : Module(
165165 @JvmStatic
166166 fun onInteract () =
167167 runSafe {
168- if (! fireworkInteract) return false
169- if (player.inventory.selectedStack?.item != Items .FIREWORK_ROCKET ) {
170- return false
171- }
172- if (player.isGliding) {
173- return false // No need to do special magic if we are already holding fireworks and flying
174- }
175- if (mc.crosshairTarget != null && mc.crosshairTarget!! .type != HitResult .Type .MISS && ! fireworkInteractCancel) {
176- return false
177- }
178- mc.itemUseCooldown + = 4
179- val cancelInteract = player.canTakeoff || fireworkInteractCancel
180- if (player.canTakeoff) {
181- takeoffState = TakeoffState .Jumping
182- } else if (player.canOpenElytra) {
183- takeoffState = TakeoffState .StartFlying
168+ when {
169+ ! fireworkInteract -> false
170+ player.inventory.selectedStack?.item != Items .FIREWORK_ROCKET -> false
171+ player.isGliding -> false // No need to do special magic if we are already holding fireworks and flying
172+ mc.crosshairTarget != null && mc.crosshairTarget!! .type != HitResult .Type .MISS && ! fireworkInteractCancel -> false
173+ else -> {
174+ mc.itemUseCooldown + = 4
175+ val cancelInteract = player.canTakeoff || fireworkInteractCancel
176+ if (player.canTakeoff) {
177+ takeoffState = TakeoffState .Jumping
178+ } else if (player.canOpenElytra) {
179+ takeoffState = TakeoffState .StartFlying
180+ }
181+ cancelInteract
182+ }
184183 }
185- return cancelInteract
186184 } ? : false
187185
188186 /* *
@@ -191,22 +189,20 @@ object BetterFirework : Module(
191189 @JvmStatic
192190 fun onPick () =
193191 runSafe {
194- if (mc.crosshairTarget?.type == HitResult .Type .BLOCK && ! middleClickCancel) {
195- return false
196- }
197- if (! activateButton.isMouseBind || activateButton.mouse != mc.options.pickItemKey.boundKey.code) {
198- return false
199- }
200- if (takeoffState != TakeoffState .None ) {
201- return false // Prevent using multiple times
202- }
203- if (player.canOpenElytra || player.isGliding) {
204- // If already gliding use another firework
205- takeoffState = TakeoffState .StartFlying
206- } else if (player.canTakeoff) {
207- takeoffState = TakeoffState .Jumping
192+ when {
193+ mc.crosshairTarget?.type == HitResult .Type .BLOCK && ! middleClickCancel -> false
194+ ! activateButton.isMouseBind || activateButton.mouse != mc.options.pickItemKey.boundKey.code -> false
195+ takeoffState != TakeoffState .None -> false // Prevent using multiple times
196+ else -> {
197+ if (player.canOpenElytra || player.isGliding) {
198+ // If already gliding use another firework
199+ takeoffState = TakeoffState .StartFlying
200+ } else if (player.canTakeoff) {
201+ takeoffState = TakeoffState .Jumping
202+ }
203+ middleClickCancel
204+ }
208205 }
209- return middleClickCancel
210206 } ? : false
211207
212208 fun SafeContext.sendSwing () {
@@ -226,12 +222,12 @@ object BetterFirework : Module(
226222
227223 stack.bestItemMatch(player.hotbar)
228224 ?.let {
229- HotbarManager .request(HotbarRequest (player.hotbar.indexOf(it), this @BetterFirework, keepTicks = 0 ))
230- .done
231- . let {
232- interaction.interactItem(player, Hand .MAIN_HAND )
233- sendSwing()
234- }
225+ val request = HotbarManager .request(HotbarRequest (player.hotbar.indexOf(it), this @BetterFirework, keepTicks = 0 ))
226+ .submit(queueIfClosed = false )
227+ if (request.done) {
228+ interaction.interactItem(player, Hand .MAIN_HAND )
229+ sendSwing()
230+ }
235231 return
236232 }
237233
@@ -245,12 +241,12 @@ object BetterFirework : Module(
245241 inventoryRequest {
246242 swap(swapSlotId, hotbarSlotToSwapWith)
247243 action {
248- HotbarManager .request(HotbarRequest (hotbarSlotToSwapWith, this @BetterFirework, keepTicks = 0 , nowOrNothing = true ))
249- .done
250- . let {
251- interaction.interactItem(player, Hand .MAIN_HAND )
252- sendSwing()
253- }
244+ val request = HotbarManager .request(HotbarRequest (hotbarSlotToSwapWith, this @BetterFirework, keepTicks = 0 , nowOrNothing = true ))
245+ .submit(queueIfClosed = false )
246+ if (request.done) {
247+ interaction.interactItem(player, Hand .MAIN_HAND )
248+ sendSwing()
249+ }
254250 }
255251 swap(swapSlotId, hotbarSlotToSwapWith)
256252 }.submit()
0 commit comments