package net.minecraft.network.protocol.game;

import net.minecraft.network.PacketListener;
import java.io.IOException;
import net.minecraft.network.FriendlyByteBuf;
import net.minecraft.world.entity.player.Abilities;
import net.minecraft.network.protocol.Packet;

public class ServerboundPlayerAbilitiesPacket implements Packet<ServerGamePacketListener> {
    private boolean isFlying;
    
    public ServerboundPlayerAbilitiesPacket() {
    }
    
    public ServerboundPlayerAbilitiesPacket(final Abilities bdz) {
        this.isFlying = bdz.flying;
    }
    
    @Override
    public void read(final FriendlyByteBuf mg) throws IOException {
        final byte byte3 = mg.readByte();
        this.isFlying = ((byte3 & 0x2) != 0x0);
    }
    
    @Override
    public void write(final FriendlyByteBuf mg) throws IOException {
        byte byte3 = 0;
        if (this.isFlying) {
            byte3 |= 0x2;
        }
        mg.writeByte(byte3);
    }
    
    @Override
    public void handle(final ServerGamePacketListener qz) {
        qz.handlePlayerAbilities(this);
    }
    
    public boolean isFlying() {
        return this.isFlying;
    }
}
