package net.minecraft.world.entity.projectile;

import net.minecraft.nbt.CompoundTag;
import net.minecraft.world.effect.MobEffectInstance;
import net.minecraft.world.effect.MobEffects;
import net.minecraft.world.level.ItemLike;
import net.minecraft.world.item.Items;
import net.minecraft.world.item.ItemStack;
import net.minecraft.core.particles.ParticleOptions;
import net.minecraft.core.particles.ParticleTypes;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.level.Level;
import net.minecraft.world.entity.EntityType;

public class SpectralArrow extends AbstractArrow {
    private int duration;
    
    public SpectralArrow(final EntityType<? extends SpectralArrow> aku, final Level bjw) {
        super(aku, bjw);
        this.duration = 200;
    }
    
    public SpectralArrow(final Level bjw, final LivingEntity akz) {
        super(EntityType.SPECTRAL_ARROW, akz, bjw);
        this.duration = 200;
    }
    
    public SpectralArrow(final Level bjw, final double double2, final double double3, final double double4) {
        super(EntityType.SPECTRAL_ARROW, double2, double3, double4, bjw);
        this.duration = 200;
    }
    
    @Override
    public void tick() {
        super.tick();
        if (this.level.isClientSide && !this.inGround) {
            this.level.addParticle(ParticleTypes.INSTANT_EFFECT, this.getX(), this.getY(), this.getZ(), 0.0, 0.0, 0.0);
        }
    }
    
    @Override
    protected ItemStack getPickupItem() {
        return new ItemStack(Items.SPECTRAL_ARROW);
    }
    
    @Override
    protected void doPostHurtEffects(final LivingEntity akz) {
        super.doPostHurtEffects(akz);
        final MobEffectInstance akk3 = new MobEffectInstance(MobEffects.GLOWING, this.duration, 0);
        akz.addEffect(akk3);
    }
    
    @Override
    public void readAdditionalSaveData(final CompoundTag jt) {
        super.readAdditionalSaveData(jt);
        if (jt.contains("Duration")) {
            this.duration = jt.getInt("Duration");
        }
    }
    
    @Override
    public void addAdditionalSaveData(final CompoundTag jt) {
        super.addAdditionalSaveData(jt);
        jt.putInt("Duration", this.duration);
    }
}
