package net.minecraft.network.protocol.game;

import net.minecraft.network.PacketListener;
import java.io.IOException;
import net.minecraft.network.FriendlyByteBuf;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.item.ItemStack;
import net.minecraft.network.protocol.Packet;

public class ServerboundEditBookPacket implements Packet<ServerGamePacketListener> {
    private ItemStack book;
    private boolean signing;
    private InteractionHand hand;
    
    public ServerboundEditBookPacket() {
    }
    
    public ServerboundEditBookPacket(final ItemStack ben, final boolean boolean2, final InteractionHand ajk) {
        this.book = ben.copy();
        this.signing = boolean2;
        this.hand = ajk;
    }
    
    @Override
    public void read(final FriendlyByteBuf kv) throws IOException {
        this.book = kv.readItem();
        this.signing = kv.readBoolean();
        this.hand = kv.<InteractionHand>readEnum(InteractionHand.class);
    }
    
    @Override
    public void write(final FriendlyByteBuf kv) throws IOException {
        kv.writeItem(this.book);
        kv.writeBoolean(this.signing);
        kv.writeEnum(this.hand);
    }
    
    @Override
    public void handle(final ServerGamePacketListener pl) {
        pl.handleEditBook(this);
    }
    
    public ItemStack getBook() {
        return this.book;
    }
    
    public boolean isSigning() {
        return this.signing;
    }
    
    public InteractionHand getHand() {
        return this.hand;
    }
}
