Skip to content

Conversation

@KMatias123
Copy link
Contributor

Previously BetterFirework tried to fly without an Elytra. This fixes the issue.

init {
private var activateButton by setting("Activate Key", Bind(0, 0, Mouse.Middle.ordinal), "Button to activate Firework")
.onPress {
mc.player?.isElytraEquipped()?.let { equipped ->
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You don't have to use mc as player is part of the safe context.

return false
}

fun ClientPlayerEntity.hasFireworks(minimum: Int = 1): Boolean {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can instead use this

    val ClientPlayerEntity.hasFireworks: Boolean
        get() = selectStack { isItem(Items.FIREWORK_ROCKET) }
            .filterStacks(inventory.mainStacks)
            .isNotEmpty()

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was thinking that this could be useful in the future development of the module. That is why I added the minimum required fireworks, this could be moved to StackSelection.kt with an Item argument though. What do you think?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was thinking that this could be useful in the future development of the module. That is why I added the minimum required fireworks, this could be moved to StackSelection.kt with an Item argument though. What do you think?

There is already an argument in selectStack that specifies the minimum stack size. It is currently set to at least 1


private var takeoffState = TakeoffState.None

fun ClientPlayerEntity.isElytraEquipped(): Boolean {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We prefer using getters instead of functions that only returns a value
Here's how that would look like:

    val ClientPlayerEntity.hasElytraEquipped: Boolean
        get() = inventory.equipment.get(EquipmentSlot.CHEST).item == Items.ELYTRA

Comment on lines 54 to 60
player.isElytraEquipped.let { equipped ->
if (!equipped) {
warn("You need to equip an elytra to use this module!")
return@onPress
}
}
player.hasFireworks.let { hasFireworks ->
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can inline those checks now that you're not checking for null :3

@KMatias123 KMatias123 requested a review from emyfops January 27, 2026 15:45
@emyfops emyfops merged commit c84570f into lambda-client:1.21.11 Jan 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants