ServerboundCustomPayloadPacket .java

net.minecraft.network.protocol.common.ServerboundCustomPayloadPacket (record, 30 lines): members: payload, MAX_PAYLOAD_SIZE, handle, STREAM_CODEC, type.

net.minecraft.network.protocol.commonrecord30 linescommon1.3 KB

Implements

API Surface (2)

PacketType<ServerboundCustomPayloadPacket> type()
void handle(final ServerCommonPacketListener listener)

Fields & Constants (2)

MAX_PAYLOAD_SIZE
STREAM_CODEC

Full Source

ServerboundCustomPayloadPacket.java30 lines · Minecraft 26.3 · verbatim
1
package net.minecraft.network.protocol.common;
2
3
import com.google.common.collect.Lists;
4
import net.minecraft.network.FriendlyByteBuf;
5
import net.minecraft.network.codec.StreamCodec;
6
import net.minecraft.network.protocol.Packet;
7
import net.minecraft.network.protocol.PacketType;
8
import net.minecraft.network.protocol.common.custom.BrandPayload;
9
import net.minecraft.network.protocol.common.custom.CustomPacketPayload;
10
import net.minecraft.network.protocol.common.custom.DiscardedPayload;
11
import net.minecraft.util.Util;
12
13
public record ServerboundCustomPayloadPacket(CustomPacketPayload payload) implements Packet<ServerCommonPacketListener> {
14
	private static final int MAX_PAYLOAD_SIZE = 32767;
15
	public static final StreamCodec<FriendlyByteBuf, ServerboundCustomPayloadPacket> STREAM_CODEC = CustomPacketPayload.<FriendlyByteBuf>codec(
16
			id -> DiscardedPayload.codec(id, 32767),
17
			Util.make(Lists.newArrayList(new CustomPacketPayload.TypeAndCodec<>(BrandPayload.TYPE, BrandPayload.STREAM_CODEC)), types -> {})
18
		)
19
		.map(ServerboundCustomPayloadPacket::new, ServerboundCustomPayloadPacket::payload);
20
21
	@Override
22
	public PacketType<ServerboundCustomPayloadPacket> type() {
23
		return CommonPacketTypes.SERVERBOUND_CUSTOM_PAYLOAD;
24
	}
25
26
	public void handle(final ServerCommonPacketListener listener) {
27
		listener.handleCustomPayload(this);
28
	}
29
}
30

Decompiled Minecraft 26.3 source of ServerboundCustomPayloadPacket (net/minecraft/network/protocol/common/ServerboundCustomPayloadPacket.java) with Mojang official mappings, stored verbatim on the site.