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 uh) {
        this.tab = uh;
    }
    
    @Override
    public void handle(final ClientGamePacketListener nl) {
        nl.handleSelectAdvancementsTab(this);
    }
    
    @Override
    public void read(final FriendlyByteBuf mg) throws IOException {
        if (mg.readBoolean()) {
            this.tab = mg.readResourceLocation();
        }
    }
    
    @Override
    public void write(final FriendlyByteBuf mg) throws IOException {
        mg.writeBoolean(this.tab != null);
        if (this.tab != null) {
            mg.writeResourceLocation(this.tab);
        }
    }
    
    @Nullable
    public ResourceLocation getTab() {
        return this.tab;
    }
}
