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 aom, final Action a) {
        this(aom, a, 0);
    }
    
    public ServerboundPlayerCommandPacket(final Entity aom, final Action a, final int integer) {
        this.id = aom.getId();
        this.action = a;
        this.data = integer;
    }
    
    @Override
    public void read(final FriendlyByteBuf mg) throws IOException {
        this.id = mg.readVarInt();
        this.action = mg.<Action>readEnum(Action.class);
        this.data = mg.readVarInt();
    }
    
    @Override
    public void write(final FriendlyByteBuf mg) throws IOException {
        mg.writeVarInt(this.id);
        mg.writeEnum(this.action);
        mg.writeVarInt(this.data);
    }
    
    @Override
    public void handle(final ServerGamePacketListener qz) {
        qz.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;
    }
}
