package net.minecraft.network.protocol.login;

import net.minecraft.network.PacketListener;
import java.io.IOException;
import java.util.UUID;
import net.minecraft.core.SerializableUUID;
import net.minecraft.network.FriendlyByteBuf;
import com.mojang.authlib.GameProfile;
import net.minecraft.network.protocol.Packet;

public class ClientboundGameProfilePacket implements Packet<ClientLoginPacketListener> {
    private GameProfile gameProfile;
    
    public ClientboundGameProfilePacket() {
    }
    
    public ClientboundGameProfilePacket(final GameProfile gameProfile) {
        this.gameProfile = gameProfile;
    }
    
    @Override
    public void read(final FriendlyByteBuf mg) throws IOException {
        final int[] arr3 = new int[4];
        for (int integer4 = 0; integer4 < arr3.length; ++integer4) {
            arr3[integer4] = mg.readInt();
        }
        final UUID uUID4 = SerializableUUID.uuidFromIntArray(arr3);
        final String string5 = mg.readUtf(16);
        this.gameProfile = new GameProfile(uUID4, string5);
    }
    
    @Override
    public void write(final FriendlyByteBuf mg) throws IOException {
        for (final int integer6 : SerializableUUID.uuidToIntArray(this.gameProfile.getId())) {
            mg.writeInt(integer6);
        }
        mg.writeUtf(this.gameProfile.getName());
    }
    
    @Override
    public void handle(final ClientLoginPacketListener sw) {
        sw.handleGameProfile(this);
    }
    
    public GameProfile getGameProfile() {
        return this.gameProfile;
    }
}
