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 aoe) {
        this.entityId = integer;
        this.effect = aoe;
    }
    
    @Override
    public void read(final FriendlyByteBuf mg) throws IOException {
        this.entityId = mg.readVarInt();
        this.effect = MobEffect.byId(mg.readUnsignedByte());
    }
    
    @Override
    public void write(final FriendlyByteBuf mg) throws IOException {
        mg.writeVarInt(this.entityId);
        mg.writeByte(MobEffect.getId(this.effect));
    }
    
    @Override
    public void handle(final ClientGamePacketListener nl) {
        nl.handleRemoveMobEffect(this);
    }
    
    @Nullable
    public Entity getEntity(final Level bqb) {
        return bqb.getEntity(this.entityId);
    }
    
    @Nullable
    public MobEffect getEffect() {
        return this.effect;
    }
}
