package net.minecraft.network.protocol.game;

import net.minecraft.network.PacketListener;
import java.io.IOException;
import net.minecraft.network.FriendlyByteBuf;
import java.util.List;
import net.minecraft.world.entity.Entity;
import net.minecraft.network.protocol.Packet;

public class ClientboundSetPassengersPacket implements Packet<ClientGamePacketListener> {
    private int vehicle;
    private int[] passengers;
    
    public ClientboundSetPassengersPacket() {
    }
    
    public ClientboundSetPassengersPacket(final Entity akq) {
        this.vehicle = akq.getId();
        final List<Entity> list3 = akq.getPassengers();
        this.passengers = new int[list3.size()];
        for (int integer4 = 0; integer4 < list3.size(); ++integer4) {
            this.passengers[integer4] = list3.get(integer4).getId();
        }
    }
    
    @Override
    public void read(final FriendlyByteBuf kv) throws IOException {
        this.vehicle = kv.readVarInt();
        this.passengers = kv.readVarIntArray();
    }
    
    @Override
    public void write(final FriendlyByteBuf kv) throws IOException {
        kv.writeVarInt(this.vehicle);
        kv.writeVarIntArray(this.passengers);
    }
    
    @Override
    public void handle(final ClientGamePacketListener lw) {
        lw.handleSetEntityPassengersPacket(this);
    }
    
    public int[] getPassengers() {
        return this.passengers;
    }
    
    public int getVehicle() {
        return this.vehicle;
    }
}
