package net.minecraft.network.protocol.game;

import org.apache.logging.log4j.LogManager;
import net.minecraft.network.PacketListener;
import java.io.IOException;
import net.minecraft.world.level.block.Block;
import net.minecraft.network.FriendlyByteBuf;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.core.BlockPos;
import org.apache.logging.log4j.Logger;
import net.minecraft.network.protocol.Packet;

public class ClientboundBlockBreakAckPacket implements Packet<ClientGamePacketListener> {
    private static final Logger LOGGER;
    private BlockPos pos;
    private BlockState state;
    ServerboundPlayerActionPacket.Action action;
    private boolean allGood;
    
    public ClientboundBlockBreakAckPacket() {
    }
    
    public ClientboundBlockBreakAckPacket(final BlockPos fk, final BlockState byj, final ServerboundPlayerActionPacket.Action a, final boolean boolean4, final String string) {
        this.pos = fk.immutable();
        this.state = byj;
        this.action = a;
        this.allGood = boolean4;
    }
    
    @Override
    public void read(final FriendlyByteBuf kv) throws IOException {
        this.pos = kv.readBlockPos();
        this.state = Block.BLOCK_STATE_REGISTRY.byId(kv.readVarInt());
        this.action = kv.<ServerboundPlayerActionPacket.Action>readEnum(ServerboundPlayerActionPacket.Action.class);
        this.allGood = kv.readBoolean();
    }
    
    @Override
    public void write(final FriendlyByteBuf kv) throws IOException {
        kv.writeBlockPos(this.pos);
        kv.writeVarInt(Block.getId(this.state));
        kv.writeEnum(this.action);
        kv.writeBoolean(this.allGood);
    }
    
    @Override
    public void handle(final ClientGamePacketListener lw) {
        lw.handleBlockBreakAck(this);
    }
    
    public BlockState getState() {
        return this.state;
    }
    
    public BlockPos getPos() {
        return this.pos;
    }
    
    public boolean allGood() {
        return this.allGood;
    }
    
    public ServerboundPlayerActionPacket.Action action() {
        return this.action;
    }
    
    static {
        LOGGER = LogManager.getLogger();
    }
}
