minecraft-src/net/minecraft/network/protocol/game/ServerboundContainerSlotStateChangedPacket.java
2025-07-04 01:41:11 +03:00

34 lines
1.2 KiB
Java

package net.minecraft.network.protocol.game;
import net.minecraft.network.FriendlyByteBuf;
import net.minecraft.network.codec.StreamCodec;
import net.minecraft.network.protocol.Packet;
import net.minecraft.network.protocol.PacketType;
public record ServerboundContainerSlotStateChangedPacket(int slotId, int containerId, boolean newState) implements Packet<ServerGamePacketListener> {
public static final StreamCodec<FriendlyByteBuf, ServerboundContainerSlotStateChangedPacket> STREAM_CODEC = Packet.codec(
ServerboundContainerSlotStateChangedPacket::write, ServerboundContainerSlotStateChangedPacket::new
);
private ServerboundContainerSlotStateChangedPacket(FriendlyByteBuf buffer) {
this(buffer.readVarInt(), buffer.readVarInt(), buffer.readBoolean());
}
private void write(FriendlyByteBuf buffer) {
buffer.writeVarInt(this.slotId);
buffer.writeVarInt(this.containerId);
buffer.writeBoolean(this.newState);
}
@Override
public PacketType<ServerboundContainerSlotStateChangedPacket> type() {
return GamePacketTypes.SERVERBOUND_CONTAINER_SLOT_STATE_CHANGED;
}
/**
* Passes this Packet on to the PacketListener for processing.
*/
public void handle(ServerGamePacketListener handler) {
handler.handleContainerSlotStateChanged(this);
}
}