ServerboundContainerClickPacket .java

net.minecraft.network.protocol.game.ServerboundContainerClickPacket (record): members: containerId, stateId, slotNum, buttonNum, containerInput, handle.

net.minecraft.network.protocol.gamerecord52 linescommon2.1 KB

Implements

API Surface (2)

PacketType<ServerboundContainerClickPacket> type()
void handle(final ServerGamePacketListener listener)

Fields & Constants (3)

MAX_SLOT_COUNT
SLOTS_STREAM_CODEC
STREAM_CODEC

Same Package (197)

Full Source

ServerboundContainerClickPacket.java52 lines · Minecraft 26.3 · verbatim
1
package net.minecraft.network.protocol.game;
2
3
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
4
import it.unimi.dsi.fastutil.ints.Int2ObjectMaps;
5
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
6
import net.minecraft.network.HashedStack;
7
import net.minecraft.network.RegistryFriendlyByteBuf;
8
import net.minecraft.network.codec.ByteBufCodecs;
9
import net.minecraft.network.codec.StreamCodec;
10
import net.minecraft.network.protocol.Packet;
11
import net.minecraft.network.protocol.PacketType;
12
import net.minecraft.world.inventory.ContainerInput;
13
14
public record ServerboundContainerClickPacket(
15
	int containerId, int stateId, short slotNum, byte buttonNum, ContainerInput containerInput, Int2ObjectMap<HashedStack> changedSlots, HashedStack carriedItem
16
) implements Packet<ServerGamePacketListener> {
17
	private static final int MAX_SLOT_COUNT = 128;
18
	private static final StreamCodec<RegistryFriendlyByteBuf, Int2ObjectMap<HashedStack>> SLOTS_STREAM_CODEC = ByteBufCodecs.map(
19
		Int2ObjectOpenHashMap::new, ByteBufCodecs.SHORT.map(Short::intValue, Integer::shortValue), HashedStack.STREAM_CODEC, 128
20
	);
21
	public static final StreamCodec<RegistryFriendlyByteBuf, ServerboundContainerClickPacket> STREAM_CODEC = StreamCodec.composite(
22
		ByteBufCodecs.CONTAINER_ID,
23
		ServerboundContainerClickPacket::containerId,
24
		ByteBufCodecs.VAR_INT,
25
		ServerboundContainerClickPacket::stateId,
26
		ByteBufCodecs.SHORT,
27
		ServerboundContainerClickPacket::slotNum,
28
		ByteBufCodecs.BYTE,
29
		ServerboundContainerClickPacket::buttonNum,
30
		ContainerInput.STREAM_CODEC,
31
		ServerboundContainerClickPacket::containerInput,
32
		SLOTS_STREAM_CODEC,
33
		ServerboundContainerClickPacket::changedSlots,
34
		HashedStack.STREAM_CODEC,
35
		ServerboundContainerClickPacket::carriedItem,
36
		ServerboundContainerClickPacket::new
37
	);
38
39
	public ServerboundContainerClickPacket {
40
		changedSlots = Int2ObjectMaps.unmodifiable(changedSlots);
41
	}
42
43
	@Override
44
	public PacketType<ServerboundContainerClickPacket> type() {
45
		return GamePacketTypes.SERVERBOUND_CONTAINER_CLICK;
46
	}
47
48
	public void handle(final ServerGamePacketListener listener) {
49
		listener.handleContainerClick(this);
50
	}
51
}
52

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