package net.minecraft.network.protocol.game;

import net.minecraft.network.PacketListener;
import java.io.IOException;
import net.minecraft.network.FriendlyByteBuf;
import javax.annotation.Nullable;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.network.protocol.Packet;

public class ClientboundSelectAdvancementsTabPacket implements Packet<ClientGamePacketListener> {
    @Nullable
    private ResourceLocation tab;
    
    public ClientboundSelectAdvancementsTabPacket() {
    }
    
    public ClientboundSelectAdvancementsTabPacket(@Nullable final ResourceLocation sm) {
        this.tab = sm;
    }
    
    @Override
    public void handle(final ClientGamePacketListener lw) {
        lw.handleSelectAdvancementsTab(this);
    }
    
    @Override
    public void read(final FriendlyByteBuf kv) throws IOException {
        if (kv.readBoolean()) {
            this.tab = kv.readResourceLocation();
        }
    }
    
    @Override
    public void write(final FriendlyByteBuf kv) throws IOException {
        kv.writeBoolean(this.tab != null);
        if (this.tab != null) {
            kv.writeResourceLocation(this.tab);
        }
    }
    
    @Nullable
    public ResourceLocation getTab() {
        return this.tab;
    }
}
