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 anf, final BlockHitResult deh) {
        this.hand = anf;
        this.blockHit = deh;
    }
    
    @Override
    public void read(final FriendlyByteBuf mg) throws IOException {
        this.hand = mg.<InteractionHand>readEnum(InteractionHand.class);
        this.blockHit = mg.readBlockHitResult();
    }
    
    @Override
    public void write(final FriendlyByteBuf mg) throws IOException {
        mg.writeEnum(this.hand);
        mg.writeBlockHitResult(this.blockHit);
    }
    
    @Override
    public void handle(final ServerGamePacketListener qz) {
        qz.handleUseItemOn(this);
    }
    
    public InteractionHand getHand() {
        return this.hand;
    }
    
    public BlockHitResult getHitResult() {
        return this.blockHit;
    }
}
