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.phys.BlockHitResult;
import net.minecraft.network.protocol.Packet;

public class ServerboundUseItemOnPacket implements Packet<ServerGamePacketListener> {
    private BlockHitResult blockHit;
    private InteractionHand hand;
    
    public ServerboundUseItemOnPacket() {
    }
    
    public ServerboundUseItemOnPacket(final InteractionHand ajk, final BlockHitResult cvg) {
        this.hand = ajk;
        this.blockHit = cvg;
    }
    
    @Override
    public void read(final FriendlyByteBuf kv) throws IOException {
        this.hand = kv.<InteractionHand>readEnum(InteractionHand.class);
        this.blockHit = kv.readBlockHitResult();
    }
    
    @Override
    public void write(final FriendlyByteBuf kv) throws IOException {
        kv.writeEnum(this.hand);
        kv.writeBlockHitResult(this.blockHit);
    }
    
    @Override
    public void handle(final ServerGamePacketListener pl) {
        pl.handleUseItemOn(this);
    }
    
    public InteractionHand getHand() {
        return this.hand;
    }
    
    public BlockHitResult getHitResult() {
        return this.blockHit;
    }
}
