34 lines
1.3 KiB
Java
34 lines
1.3 KiB
Java
package net.minecraft.network.protocol.game;
|
|
|
|
import net.minecraft.network.RegistryFriendlyByteBuf;
|
|
import net.minecraft.network.codec.ByteBufCodecs;
|
|
import net.minecraft.network.codec.StreamCodec;
|
|
import net.minecraft.network.protocol.Packet;
|
|
import net.minecraft.network.protocol.PacketType;
|
|
import net.minecraft.world.item.ItemStack;
|
|
|
|
public record ServerboundSetCreativeModeSlotPacket(short slotNum, ItemStack itemStack) implements Packet<ServerGamePacketListener> {
|
|
public static final StreamCodec<RegistryFriendlyByteBuf, ServerboundSetCreativeModeSlotPacket> STREAM_CODEC = StreamCodec.composite(
|
|
ByteBufCodecs.SHORT,
|
|
ServerboundSetCreativeModeSlotPacket::slotNum,
|
|
ItemStack.validatedStreamCodec(ItemStack.OPTIONAL_STREAM_CODEC),
|
|
ServerboundSetCreativeModeSlotPacket::itemStack,
|
|
ServerboundSetCreativeModeSlotPacket::new
|
|
);
|
|
|
|
public ServerboundSetCreativeModeSlotPacket(int slotNum, ItemStack itemStack) {
|
|
this((short)slotNum, itemStack);
|
|
}
|
|
|
|
@Override
|
|
public PacketType<ServerboundSetCreativeModeSlotPacket> type() {
|
|
return GamePacketTypes.SERVERBOUND_SET_CREATIVE_MODE_SLOT;
|
|
}
|
|
|
|
/**
|
|
* Passes this Packet on to the NetHandler for processing.
|
|
*/
|
|
public void handle(ServerGamePacketListener handler) {
|
|
handler.handleSetCreativeModeSlot(this);
|
|
}
|
|
}
|