package net.minecraft.network.protocol.game;

import net.minecraft.network.PacketListener;
import java.io.IOException;
import net.minecraft.core.Registry;
import net.minecraft.network.FriendlyByteBuf;
import net.minecraft.world.level.block.Block;
import net.minecraft.core.BlockPos;
import net.minecraft.network.protocol.Packet;

public class ClientboundBlockEventPacket implements Packet<ClientGamePacketListener> {
    private BlockPos pos;
    private int b0;
    private int b1;
    private Block block;
    
    public ClientboundBlockEventPacket() {
    }
    
    public ClientboundBlockEventPacket(final BlockPos fk, final Block bph, final int integer3, final int integer4) {
        this.pos = fk;
        this.block = bph;
        this.b0 = integer3;
        this.b1 = integer4;
    }
    
    @Override
    public void read(final FriendlyByteBuf kv) throws IOException {
        this.pos = kv.readBlockPos();
        this.b0 = kv.readUnsignedByte();
        this.b1 = kv.readUnsignedByte();
        this.block = Registry.BLOCK.byId(kv.readVarInt());
    }
    
    @Override
    public void write(final FriendlyByteBuf kv) throws IOException {
        kv.writeBlockPos(this.pos);
        kv.writeByte(this.b0);
        kv.writeByte(this.b1);
        kv.writeVarInt(Registry.BLOCK.getId(this.block));
    }
    
    @Override
    public void handle(final ClientGamePacketListener lw) {
        lw.handleBlockEvent(this);
    }
    
    public BlockPos getPos() {
        return this.pos;
    }
    
    public int getB0() {
        return this.b0;
    }
    
    public int getB1() {
        return this.b1;
    }
    
    public Block getBlock() {
        return this.block;
    }
}
