package net.minecraft.network.protocol.game;

import net.minecraft.network.PacketListener;
import java.io.IOException;
import net.minecraft.network.FriendlyByteBuf;
import net.minecraft.network.syncher.SynchedEntityData;
import java.util.List;
import net.minecraft.network.protocol.Packet;

public class ClientboundSetEntityDataPacket implements Packet<ClientGamePacketListener> {
    private int id;
    private List<SynchedEntityData.DataItem<?>> packedItems;
    
    public ClientboundSetEntityDataPacket() {
    }
    
    public ClientboundSetEntityDataPacket(final int integer, final SynchedEntityData se, final boolean boolean3) {
        this.id = integer;
        if (boolean3) {
            this.packedItems = se.getAll();
            se.clearDirty();
        }
        else {
            this.packedItems = se.packDirty();
        }
    }
    
    @Override
    public void read(final FriendlyByteBuf kv) throws IOException {
        this.id = kv.readVarInt();
        this.packedItems = SynchedEntityData.unpack(kv);
    }
    
    @Override
    public void write(final FriendlyByteBuf kv) throws IOException {
        kv.writeVarInt(this.id);
        SynchedEntityData.pack(this.packedItems, kv);
    }
    
    @Override
    public void handle(final ClientGamePacketListener lw) {
        lw.handleSetEntityData(this);
    }
    
    public List<SynchedEntityData.DataItem<?>> getUnpackedData() {
        return this.packedItems;
    }
    
    public int getId() {
        return this.id;
    }
}
