@@ -24,6 +24,7 @@ import com.lambda.config.settings.complex.Bind
2424import com.lambda.context.SafeContext
2525import com.lambda.event.events.KeyboardEvent
2626import com.lambda.event.events.MouseEvent
27+ import com.lambda.event.events.PlayerEvent
2728import com.lambda.event.events.TickEvent
2829import com.lambda.event.listener.SafeListener.Companion.listen
2930import com.lambda.interaction.material.StackSelection.Companion.selectStack
@@ -54,6 +55,7 @@ object BetterFirework : Module(
5455 tag = ModuleTag .MOVEMENT ,
5556) {
5657 private var activateButton by setting(" Activate Key" , Bind (0 , 0 , Mouse .Middle .ordinal), " Button to activate Firework" ).group(Group .General )
58+ private var midFlightActivationKey by setting(" Mid-Flight Activation Key" , Bind (0 , 0 , KeyCode .Unbound .code), " Firework use key for mid flight activation" ).group(Group .General )
5759 private var middleClickCancel by setting(" Middle Click Cancel" , false , description = " Cancel pick block action on middle mouse click" ) { activateButton.key != KeyCode .Unbound .code }.group(Group .General )
5860 private var fireworkInteract by setting(" Right Click Fly" , true , " Automatically start flying when right clicking fireworks" )
5961 private var fireworkInteractCancel by setting(" Right Click Cancel" , false , " Cancel block interactions while holding fireworks" ) { fireworkInteract }
@@ -104,7 +106,10 @@ object BetterFirework : Module(
104106 }
105107 }
106108 listen<MouseEvent .Click > {
107- if (it.isPressed && it.satisfies(activateButton)) {
109+ if (! it.isPressed) {
110+ return @listen
111+ }
112+ if (it.satisfies(activateButton)) {
108113 if (activateButton.mouse == mc.options.pickItemKey.boundKey.code) {
109114 return @listen
110115 }
@@ -120,22 +125,35 @@ object BetterFirework : Module(
120125 }
121126 }
122127 }
128+ if (it.satisfies(midFlightActivationKey)) {
129+ runSafe {
130+ if (player.isGliding)
131+ takeoffState = TakeoffState .StartFlying
132+ }
133+ }
123134 }
124135 listen<KeyboardEvent .Press > {
125- if (it.isPressed && it.satisfies(activateButton)) {
126- if (activateButton.key == mc.options.pickItemKey.boundKey.code) {
127- return @listen
136+ if (! it.isPressed) {
137+ return @listen
138+ }
139+ if (it.satisfies(activateButton)) {
140+ if (activateButton.key != mc.options.pickItemKey.boundKey.code) {
141+ runSafe {
142+ if (takeoffState == TakeoffState .None ) {
143+ if (player.canOpenElytra || player.isGliding) {
144+ // If already gliding use another firework
145+ takeoffState = TakeoffState .StartFlying
146+ } else if (player.canTakeoff) {
147+ takeoffState = TakeoffState .Jumping
148+ }
149+ }
150+ }
128151 }
152+ }
153+ if (it.satisfies(midFlightActivationKey)) {
129154 runSafe {
130- if (takeoffState != TakeoffState .None ) {
131- return @listen // Prevent using multiple times
132- }
133- if (player.canOpenElytra || player.isGliding) {
134- // If already gliding use another firework
155+ if (player.isGliding)
135156 takeoffState = TakeoffState .StartFlying
136- } else if (player.canTakeoff) {
137- takeoffState = TakeoffState .Jumping
138- }
139157 }
140158 }
141159 }
0 commit comments