ClientboundRecipeBookAddPacket .java

net.minecraft.network.protocol.game.ClientboundRecipeBookAddPacket (record, 53 lines): members: entries, replace, Entry, handle, STREAM_CODEC, type.

net.minecraft.network.protocol.gamerecord53 linescommon1.9 KB

Implements

API Surface (5)

PacketType<ClientboundRecipeBookAddPacket> type()
void handle(final ClientGamePacketListener listener)
record Entry(RecipeDisplayEntry contents, byte flags)
boolean notification()
boolean highlight()

Fields & Constants (1)

STREAM_CODEC

Same Package (197)

Full Source

ClientboundRecipeBookAddPacket.java53 lines · Minecraft 26.3 · verbatim
1
package net.minecraft.network.protocol.game;
2
3
import java.util.List;
4
import net.minecraft.network.RegistryFriendlyByteBuf;
5
import net.minecraft.network.codec.ByteBufCodecs;
6
import net.minecraft.network.codec.StreamCodec;
7
import net.minecraft.network.protocol.Packet;
8
import net.minecraft.network.protocol.PacketType;
9
import net.minecraft.world.item.crafting.display.RecipeDisplayEntry;
10
11
public record ClientboundRecipeBookAddPacket(List<ClientboundRecipeBookAddPacket.Entry> entries, boolean replace) implements Packet<ClientGamePacketListener> {
12
	public static final StreamCodec<RegistryFriendlyByteBuf, ClientboundRecipeBookAddPacket> STREAM_CODEC = StreamCodec.composite(
13
		ClientboundRecipeBookAddPacket.Entry.STREAM_CODEC.apply(ByteBufCodecs.list()),
14
		ClientboundRecipeBookAddPacket::entries,
15
		ByteBufCodecs.BOOL,
16
		ClientboundRecipeBookAddPacket::replace,
17
		ClientboundRecipeBookAddPacket::new
18
	);
19
20
	@Override
21
	public PacketType<ClientboundRecipeBookAddPacket> type() {
22
		return GamePacketTypes.CLIENTBOUND_RECIPE_BOOK_ADD;
23
	}
24
25
	public void handle(final ClientGamePacketListener listener) {
26
		listener.handleRecipeBookAdd(this);
27
	}
28
29
	public record Entry(RecipeDisplayEntry contents, byte flags) {
30
		public static final byte FLAG_NOTIFICATION = 1;
31
		public static final byte FLAG_HIGHLIGHT = 2;
32
		public static final StreamCodec<RegistryFriendlyByteBuf, ClientboundRecipeBookAddPacket.Entry> STREAM_CODEC = StreamCodec.composite(
33
			RecipeDisplayEntry.STREAM_CODEC,
34
			ClientboundRecipeBookAddPacket.Entry::contents,
35
			ByteBufCodecs.BYTE,
36
			ClientboundRecipeBookAddPacket.Entry::flags,
37
			ClientboundRecipeBookAddPacket.Entry::new
38
		);
39
40
		public Entry(final RecipeDisplayEntry contents, final boolean notification, final boolean highlight) {
41
			this(contents, (byte)((notification ? 1 : 0) | (highlight ? 2 : 0)));
42
		}
43
44
		public boolean notification() {
45
			return (this.flags & 1) != 0;
46
		}
47
48
		public boolean highlight() {
49
			return (this.flags & 2) != 0;
50
		}
51
	}
52
}
53

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