-
Notifications
You must be signed in to change notification settings - Fork 19
FIX: Prevents betterfirework from trying to start flying without an elytra or a firework. Shows a warning message to the user instead. #227
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
| init { | ||
| private var activateButton by setting("Activate Key", Bind(0, 0, Mouse.Middle.ordinal), "Button to activate Firework") | ||
| .onPress { | ||
| mc.player?.isElytraEquipped()?.let { equipped -> |
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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()There was a problem hiding this comment.
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 was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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| player.isElytraEquipped.let { equipped -> | ||
| if (!equipped) { | ||
| warn("You need to equip an elytra to use this module!") | ||
| return@onPress | ||
| } | ||
| } | ||
| player.hasFireworks.let { hasFireworks -> |
There was a problem hiding this comment.
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
Previously BetterFirework tried to fly without an Elytra. This fixes the issue.