package net.minecraft.world.entity.projectile;

import net.minecraft.world.entity.Entity;
import net.minecraft.world.damagesource.DamageSource;
import net.minecraft.world.entity.monster.Blaze;
import net.minecraft.world.phys.EntityHitResult;
import net.minecraft.world.phys.HitResult;
import net.minecraft.world.item.ItemStack;
import net.minecraft.core.particles.ItemParticleOption;
import net.minecraft.core.particles.ParticleTypes;
import net.minecraft.core.particles.ParticleOptions;
import net.minecraft.world.item.Items;
import net.minecraft.world.item.Item;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.level.Level;
import net.minecraft.world.entity.EntityType;

public class Snowball extends ThrowableItemProjectile {
    public Snowball(final EntityType<? extends Snowball> aku, final Level bjw) {
        super(aku, bjw);
    }
    
    public Snowball(final Level bjw, final LivingEntity akz) {
        super(EntityType.SNOWBALL, akz, bjw);
    }
    
    public Snowball(final Level bjw, final double double2, final double double3, final double double4) {
        super(EntityType.SNOWBALL, double2, double3, double4, bjw);
    }
    
    @Override
    protected Item getDefaultItem() {
        return Items.SNOWBALL;
    }
    
    private ParticleOptions getParticle() {
        final ItemStack ben2 = this.getItemRaw();
        return ben2.isEmpty() ? ParticleTypes.ITEM_SNOWBALL : new ItemParticleOption(ParticleTypes.ITEM, ben2);
    }
    
    @Override
    public void handleEntityEvent(final byte byte1) {
        if (byte1 == 3) {
            final ParticleOptions gt3 = this.getParticle();
            for (int integer4 = 0; integer4 < 8; ++integer4) {
                this.level.addParticle(gt3, this.getX(), this.getY(), this.getZ(), 0.0, 0.0, 0.0);
            }
        }
    }
    
    @Override
    protected void onHit(final HitResult cvi) {
        if (cvi.getType() == HitResult.Type.ENTITY) {
            final Entity akq3 = ((EntityHitResult)cvi).getEntity();
            final int integer4 = (akq3 instanceof Blaze) ? 3 : 0;
            akq3.hurt(DamageSource.thrown(this, this.getOwner()), (float)integer4);
        }
        if (!this.level.isClientSide) {
            this.level.broadcastEntityEvent(this, (byte)3);
            this.remove();
        }
    }
}
