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 tt, final boolean boolean3) {
        this.id = integer;
        if (boolean3) {
            this.packedItems = tt.getAll();
            tt.clearDirty();
        }
        else {
            this.packedItems = tt.packDirty();
        }
    }
    
    @Override
    public void read(final FriendlyByteBuf mg) throws IOException {
        this.id = mg.readVarInt();
        this.packedItems = SynchedEntityData.unpack(mg);
    }
    
    @Override
    public void write(final FriendlyByteBuf mg) throws IOException {
        mg.writeVarInt(this.id);
        SynchedEntityData.pack(this.packedItems, mg);
    }
    
    @Override
    public void handle(final ClientGamePacketListener nl) {
        nl.handleSetEntityData(this);
    }
    
    public List<SynchedEntityData.DataItem<?>> getUnpackedData() {
        return this.packedItems;
    }
    
    public int getId() {
        return this.id;
    }
}
