/* * Decompiled with CFR 0.152. * * Could not load the following classes: * org.jspecify.annotations.Nullable */ package net.minecraft.network.protocol.game; import java.util.Objects; import net.minecraft.network.FriendlyByteBuf; import net.minecraft.network.codec.StreamCodec; import net.minecraft.network.protocol.Packet; import net.minecraft.network.protocol.PacketType; import net.minecraft.network.protocol.game.ClientGamePacketListener; import net.minecraft.network.protocol.game.GamePacketTypes; import net.minecraft.world.scores.DisplaySlot; import net.minecraft.world.scores.Objective; import org.jspecify.annotations.Nullable; public class ClientboundSetDisplayObjectivePacket implements Packet { public static final StreamCodec STREAM_CODEC = Packet.codec(ClientboundSetDisplayObjectivePacket::write, ClientboundSetDisplayObjectivePacket::new); private final DisplaySlot slot; private final String objectiveName; public ClientboundSetDisplayObjectivePacket(DisplaySlot slot, @Nullable Objective objective) { this.slot = slot; this.objectiveName = objective == null ? "" : objective.getName(); } private ClientboundSetDisplayObjectivePacket(FriendlyByteBuf input) { this.slot = input.readById(DisplaySlot.BY_ID); this.objectiveName = input.readUtf(); } private void write(FriendlyByteBuf output) { output.writeById(DisplaySlot::id, this.slot); output.writeUtf(this.objectiveName); } @Override public PacketType type() { return GamePacketTypes.CLIENTBOUND_SET_DISPLAY_OBJECTIVE; } @Override public void handle(ClientGamePacketListener listener) { listener.handleSetDisplayObjective(this); } public DisplaySlot getSlot() { return this.slot; } public @Nullable String getObjectiveName() { return Objects.equals(this.objectiveName, "") ? null : this.objectiveName; } }