ClientboundContainerSetSlotPacket .java

net.minecraft.network.protocol.game.ClientboundContainerSetSlotPacket (class): members: getStateId, stateId, getContainerId, containerId, getSlot, slot.

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

Implements

API Surface (6)

PacketType<ClientboundContainerSetSlotPacket> type()
void handle(final ClientGamePacketListener listener)
int getContainerId()
int getSlot()
ItemStack getItem()
int getStateId()

Fields & Constants (5)

STREAM_CODEC
containerId
stateId
slot
itemStack

Same Package (197)

Full Source

ClientboundContainerSetSlotPacket.java64 lines · Minecraft 26.3 · verbatim
1
package net.minecraft.network.protocol.game;
2
3
import net.minecraft.network.RegistryFriendlyByteBuf;
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.item.ItemStack;
8
9
public class ClientboundContainerSetSlotPacket implements Packet<ClientGamePacketListener> {
10
	public static final StreamCodec<RegistryFriendlyByteBuf, ClientboundContainerSetSlotPacket> STREAM_CODEC = Packet.codec(
11
		ClientboundContainerSetSlotPacket::write, ClientboundContainerSetSlotPacket::new
12
	);
13
	private final int containerId;
14
	private final int stateId;
15
	private final int slot;
16
	private final ItemStack itemStack;
17
18
	public ClientboundContainerSetSlotPacket(final int containerId, final int stateId, final int slot, final ItemStack itemStack) {
19
		this.containerId = containerId;
20
		this.stateId = stateId;
21
		this.slot = slot;
22
		this.itemStack = itemStack.copy();
23
	}
24
25
	private ClientboundContainerSetSlotPacket(final RegistryFriendlyByteBuf input) {
26
		this.containerId = input.readContainerId();
27
		this.stateId = input.readVarInt();
28
		this.slot = input.readShort();
29
		this.itemStack = ItemStack.OPTIONAL_STREAM_CODEC.decode(input);
30
	}
31
32
	private void write(final RegistryFriendlyByteBuf output) {
33
		output.writeContainerId(this.containerId);
34
		output.writeVarInt(this.stateId);
35
		output.writeShort(this.slot);
36
		ItemStack.OPTIONAL_STREAM_CODEC.encode(output, this.itemStack);
37
	}
38
39
	@Override
40
	public PacketType<ClientboundContainerSetSlotPacket> type() {
41
		return GamePacketTypes.CLIENTBOUND_CONTAINER_SET_SLOT;
42
	}
43
44
	public void handle(final ClientGamePacketListener listener) {
45
		listener.handleContainerSetSlot(this);
46
	}
47
48
	public int getContainerId() {
49
		return this.containerId;
50
	}
51
52
	public int getSlot() {
53
		return this.slot;
54
	}
55
56
	public ItemStack getItem() {
57
		return this.itemStack;
58
	}
59
60
	public int getStateId() {
61
		return this.stateId;
62
	}
63
}
64

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