46 lines
1.4 KiB
Java
46 lines
1.4 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;
|
|
import net.minecraft.resources.ResourceLocation;
|
|
import net.minecraft.world.item.crafting.RecipeHolder;
|
|
|
|
public class ServerboundRecipeBookSeenRecipePacket implements Packet<ServerGamePacketListener> {
|
|
public static final StreamCodec<FriendlyByteBuf, ServerboundRecipeBookSeenRecipePacket> STREAM_CODEC = Packet.codec(
|
|
ServerboundRecipeBookSeenRecipePacket::write, ServerboundRecipeBookSeenRecipePacket::new
|
|
);
|
|
private final ResourceLocation recipe;
|
|
|
|
public ServerboundRecipeBookSeenRecipePacket(RecipeHolder<?> recipe) {
|
|
this.recipe = recipe.id();
|
|
}
|
|
|
|
private ServerboundRecipeBookSeenRecipePacket(FriendlyByteBuf buffer) {
|
|
this.recipe = buffer.readResourceLocation();
|
|
}
|
|
|
|
/**
|
|
* Writes the raw packet data to the data stream.
|
|
*/
|
|
private void write(FriendlyByteBuf buffer) {
|
|
buffer.writeResourceLocation(this.recipe);
|
|
}
|
|
|
|
@Override
|
|
public PacketType<ServerboundRecipeBookSeenRecipePacket> type() {
|
|
return GamePacketTypes.SERVERBOUND_RECIPE_BOOK_SEEN_RECIPE;
|
|
}
|
|
|
|
/**
|
|
* Passes this Packet on to the NetHandler for processing.
|
|
*/
|
|
public void handle(ServerGamePacketListener handler) {
|
|
handler.handleRecipeBookSeenRecipePacket(this);
|
|
}
|
|
|
|
public ResourceLocation getRecipe() {
|
|
return this.recipe;
|
|
}
|
|
}
|