package net.minecraft.network.protocol.game;

import net.minecraft.network.PacketListener;
import java.io.IOException;
import net.minecraft.network.FriendlyByteBuf;
import net.minecraft.network.protocol.Packet;

public class ServerboundPlayerInputPacket implements Packet<ServerGamePacketListener> {
    private float xxa;
    private float zza;
    private boolean isJumping;
    private boolean isShiftKeyDown;
    
    public ServerboundPlayerInputPacket() {
    }
    
    public ServerboundPlayerInputPacket(final float float1, final float float2, final boolean boolean3, final boolean boolean4) {
        this.xxa = float1;
        this.zza = float2;
        this.isJumping = boolean3;
        this.isShiftKeyDown = boolean4;
    }
    
    @Override
    public void read(final FriendlyByteBuf kv) throws IOException {
        this.xxa = kv.readFloat();
        this.zza = kv.readFloat();
        final byte byte3 = kv.readByte();
        this.isJumping = ((byte3 & 0x1) > 0);
        this.isShiftKeyDown = ((byte3 & 0x2) > 0);
    }
    
    @Override
    public void write(final FriendlyByteBuf kv) throws IOException {
        kv.writeFloat(this.xxa);
        kv.writeFloat(this.zza);
        byte byte3 = 0;
        if (this.isJumping) {
            byte3 |= 0x1;
        }
        if (this.isShiftKeyDown) {
            byte3 |= 0x2;
        }
        kv.writeByte(byte3);
    }
    
    @Override
    public void handle(final ServerGamePacketListener pl) {
        pl.handlePlayerInput(this);
    }
    
    public float getXxa() {
        return this.xxa;
    }
    
    public float getZza() {
        return this.zza;
    }
    
    public boolean isJumping() {
        return this.isJumping;
    }
    
    public boolean isShiftKeyDown() {
        return this.isShiftKeyDown;
    }
}
