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 aom) {
        this.vehicle = aom.getId();
        final List<Entity> list3 = aom.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 mg) throws IOException {
        this.vehicle = mg.readVarInt();
        this.passengers = mg.readVarIntArray();
    }
    
    @Override
    public void write(final FriendlyByteBuf mg) throws IOException {
        mg.writeVarInt(this.vehicle);
        mg.writeVarIntArray(this.passengers);
    }
    
    @Override
    public void handle(final ClientGamePacketListener nl) {
        nl.handleSetEntityPassengersPacket(this);
    }
    
    public int[] getPassengers() {
        return this.passengers;
    }
    
    public int getVehicle() {
        return this.vehicle;
    }
}
