Skip to content
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

fix chest swapping after getting an error with pitch40 #4637

Merged

Conversation

jtris
Copy link
Contributor

@jtris jtris commented Jun 12, 2024

Type of change

  • Bug fix
  • New feature

Description

When chestswap is set to 'always' and you get an error while enabling Pitch40 elytra fly ("Player must be above uppper bounds!"), the module itself remains disabled while your chestplate still gets swapped as if the module was active.

image

Now the module has a chance to call its toggle() in peace without the chestplate getting swapped again by ElytraFly's onActivate().

How Has This Been Tested?

By seeing if it still swaps the chestplate for an elytra.

image

Checklist:

  • My code follows the style guidelines of this project.
  • I have added comments to my code in more complex areas. (there are no complex areas)
  • I have tested the code in both development and production environments.

@Wide-Cat
Copy link
Collaborator

It seems that with this change the swap happens twice in one tick, which does solve the issue but it would be better to just not swap in the onActivate method if the module is disabled. I would change it to something like this instead:

@Override
public void onActivate() {
    currentMode.onActivate();
    if ((chestSwap.get() == ChestSwapMode.Always || chestSwap.get() == ChestSwapMode.WaitForGround)
        && mc.player.getEquippedStack(EquipmentSlot.CHEST).getItem() != Items.ELYTRA && isActive()) {
        Modules.get().get(ChestSwap.class).swap();
    }
}

@jtris jtris marked this pull request as draft June 12, 2024 18:35
@jtris
Copy link
Contributor Author

jtris commented Jun 12, 2024

That seems to do it, thanks for the swift feedback.

@jtris jtris marked this pull request as ready for review June 12, 2024 19:09
@Wide-Cat Wide-Cat merged commit 1c15b02 into MeteorDevelopment:master Jun 12, 2024
1 check passed
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