Protocol slots (1)
| ID | dec | State | Direction | Registry |
|---|
| 0x5A | 90 | PLAY | Clientbound | GamePacketTypes.CLIENTBOUND_SET_BORDER_CENTER: "set_border_center" |
Packet ids are positional: the id is the index of the addPacket call in the protocol builder (see ProtocolInfoBuilder.listPackets). Ids change between game versions.
Wire fields (1)
| Field | Type |
|---|
border | WorldBorder |
Stream codec
static final StreamCodec<FriendlyByteBuf, ClientboundSetBorderCenterPacket> STREAM_CODEC = Packet.codec( ClientboundSetBorderCenterPacket::write, ClientboundSetBorderCenterPacket::new );
Modern packets serialize through StreamCodecs instead of read/write methods.
Handling
Resolved on the ClientGamePacketListener packet-listener interface by void handleSetBorderCenter(ClientboundSetBorderCenterPacket clientboundsetbordercenterpacket). The implementation in the game is ClientPacketListener.
Full Source
| 1 | package net.minecraft.network.protocol.game;
|
| 2 |
|
| 3 | import net.minecraft.network.FriendlyByteBuf;
|
| 4 | import net.minecraft.network.codec.StreamCodec;
|
| 5 | import net.minecraft.network.protocol.Packet;
|
| 6 | import net.minecraft.network.protocol.PacketType;
|
| 7 | import net.minecraft.world.level.border.WorldBorder;
|
| 8 |
|
| 9 | public class ClientboundSetBorderCenterPacket implements Packet<ClientGamePacketListener> {
|
| 10 | public static final StreamCodec<FriendlyByteBuf, ClientboundSetBorderCenterPacket> STREAM_CODEC = Packet.codec(
|
| 11 | ClientboundSetBorderCenterPacket::write, ClientboundSetBorderCenterPacket::new
|
| 12 | );
|
| 13 | private final double newCenterX;
|
| 14 | private final double newCenterZ;
|
| 15 |
|
| 16 | public ClientboundSetBorderCenterPacket(final WorldBorder border) {
|
| 17 | this.newCenterX = border.getCenterX();
|
| 18 | this.newCenterZ = border.getCenterZ();
|
| 19 | }
|
| 20 |
|
| 21 | private ClientboundSetBorderCenterPacket(final FriendlyByteBuf input) {
|
| 22 | this.newCenterX = input.readDouble();
|
| 23 | this.newCenterZ = input.readDouble();
|
| 24 | }
|
| 25 |
|
| 26 | private void write(final FriendlyByteBuf output) {
|
| 27 | output.writeDouble(this.newCenterX);
|
| 28 | output.writeDouble(this.newCenterZ);
|
| 29 | }
|
| 30 |
|
| 31 | @Override
|
| 32 | public PacketType<ClientboundSetBorderCenterPacket> type() {
|
| 33 | return GamePacketTypes.CLIENTBOUND_SET_BORDER_CENTER;
|
| 34 | }
|
| 35 |
|
| 36 | public void handle(final ClientGamePacketListener listener) {
|
| 37 | listener.handleSetBorderCenter(this);
|
| 38 | }
|
| 39 |
|
| 40 | public double getNewCenterZ() {
|
| 41 | return this.newCenterZ;
|
| 42 | }
|
| 43 |
|
| 44 | public double getNewCenterX() {
|
| 45 | return this.newCenterX;
|
| 46 | }
|
| 47 | }
|
| 48 |
|