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 fu, final Block bvr, final int integer3, final int integer4) {
        this.pos = fu;
        this.block = bvr;
        this.b0 = integer3;
        this.b1 = integer4;
    }
    
    @Override
    public void read(final FriendlyByteBuf mg) throws IOException {
        this.pos = mg.readBlockPos();
        this.b0 = mg.readUnsignedByte();
        this.b1 = mg.readUnsignedByte();
        this.block = Registry.BLOCK.byId(mg.readVarInt());
    }
    
    @Override
    public void write(final FriendlyByteBuf mg) throws IOException {
        mg.writeBlockPos(this.pos);
        mg.writeByte(this.b0);
        mg.writeByte(this.b1);
        mg.writeVarInt(Registry.BLOCK.getId(this.block));
    }
    
    @Override
    public void handle(final ClientGamePacketListener nl) {
        nl.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;
    }
}
