package net.minecraft.network.protocol.game;

import net.minecraft.network.PacketListener;
import javax.annotation.Nullable;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.level.Level;
import java.io.IOException;
import net.minecraft.network.FriendlyByteBuf;
import net.minecraft.world.effect.MobEffect;
import net.minecraft.network.protocol.Packet;

public class ClientboundRemoveMobEffectPacket implements Packet<ClientGamePacketListener> {
    private int entityId;
    private MobEffect effect;
    
    public ClientboundRemoveMobEffectPacket() {
    }
    
    public ClientboundRemoveMobEffectPacket(final int integer, final MobEffect aki) {
        this.entityId = integer;
        this.effect = aki;
    }
    
    @Override
    public void read(final FriendlyByteBuf kv) throws IOException {
        this.entityId = kv.readVarInt();
        this.effect = MobEffect.byId(kv.readUnsignedByte());
    }
    
    @Override
    public void write(final FriendlyByteBuf kv) throws IOException {
        kv.writeVarInt(this.entityId);
        kv.writeByte(MobEffect.getId(this.effect));
    }
    
    @Override
    public void handle(final ClientGamePacketListener lw) {
        lw.handleRemoveMobEffect(this);
    }
    
    @Nullable
    public Entity getEntity(final Level bjw) {
        return bjw.getEntity(this.entityId);
    }
    
    @Nullable
    public MobEffect getEffect() {
        return this.effect;
    }
}
