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.Entity;
import net.minecraft.network.protocol.Packet;

public class ServerboundPlayerCommandPacket implements Packet<ServerGamePacketListener> {
    private int id;
    private Action action;
    private int data;
    
    public ServerboundPlayerCommandPacket() {
    }
    
    public ServerboundPlayerCommandPacket(final Entity akq, final Action a) {
        this(akq, a, 0);
    }
    
    public ServerboundPlayerCommandPacket(final Entity akq, final Action a, final int integer) {
        this.id = akq.getId();
        this.action = a;
        this.data = integer;
    }
    
    @Override
    public void read(final FriendlyByteBuf kv) throws IOException {
        this.id = kv.readVarInt();
        this.action = kv.<Action>readEnum(Action.class);
        this.data = kv.readVarInt();
    }
    
    @Override
    public void write(final FriendlyByteBuf kv) throws IOException {
        kv.writeVarInt(this.id);
        kv.writeEnum(this.action);
        kv.writeVarInt(this.data);
    }
    
    @Override
    public void handle(final ServerGamePacketListener pl) {
        pl.handlePlayerCommand(this);
    }
    
    public Action getAction() {
        return this.action;
    }
    
    public int getData() {
        return this.data;
    }
    
    public enum Action {
        PRESS_SHIFT_KEY, 
        RELEASE_SHIFT_KEY, 
        STOP_SLEEPING, 
        START_SPRINTING, 
        STOP_SPRINTING, 
        START_RIDING_JUMP, 
        STOP_RIDING_JUMP, 
        OPEN_INVENTORY, 
        START_FALL_FLYING;
    }
}
