Skip to content

Fixed flight abilities toggling when receiving an abilities packet #5154

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

Merged
merged 2 commits into from
Apr 7, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import net.minecraft.block.AbstractBlock;
import net.minecraft.entity.Entity;
import net.minecraft.network.packet.c2s.play.PlayerMoveC2SPacket;
import net.minecraft.network.packet.s2c.play.PlayerAbilitiesS2CPacket;
import net.minecraft.server.network.ServerPlayNetworkHandler;
import net.minecraft.util.math.Vec3d;

Expand Down Expand Up @@ -227,6 +228,16 @@ private void onSendPacket(PacketEvent.Send event) {
}
}

@EventHandler
private void onReceivePacket(PacketEvent.Receive event) {
if (!(event.packet instanceof PlayerAbilitiesS2CPacket packet) || mode.get() != Mode.Abilities) return;
event.cancel(); // Cancel packet, so fly won't be toggled

mc.player.getAbilities().invulnerable = packet.isInvulnerable();
mc.player.getAbilities().creativeMode = packet.isCreativeMode();
mc.player.getAbilities().setWalkSpeed(packet.getWalkSpeed());
}

private boolean shouldFlyDown(double currentY, double lastY) {
if (currentY >= lastY) {
return true;
Expand Down