package net.minecraft.core.dispenser;

import net.minecraft.world.entity.projectile.Projectile;
import net.minecraft.core.Position;
import net.minecraft.world.level.Level;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.level.block.state.properties.Property;
import net.minecraft.core.Direction;
import net.minecraft.world.level.block.DispenserBlock;
import net.minecraft.world.item.ItemStack;
import net.minecraft.core.BlockSource;

public abstract class AbstractProjectileDispenseBehavior extends DefaultDispenseItemBehavior {
    public ItemStack execute(final BlockSource fv, final ItemStack bki) {
        final Level bqb4 = fv.getLevel();
        final Position gj5 = DispenserBlock.getDispensePosition(fv);
        final Direction fz6 = fv.getBlockState().<Direction>getValue((Property<Direction>)DispenserBlock.FACING);
        final Projectile bes7 = this.getProjectile(bqb4, gj5, bki);
        bes7.shoot(fz6.getStepX(), fz6.getStepY() + 0.1f, fz6.getStepZ(), this.getPower(), this.getUncertainty());
        bqb4.addFreshEntity(bes7);
        bki.shrink(1);
        return bki;
    }
    
    @Override
    protected void playSound(final BlockSource fv) {
        fv.getLevel().levelEvent(1002, fv.getPos(), 0);
    }
    
    protected abstract Projectile getProjectile(final Level bqb, final Position gj, final ItemStack bki);
    
    protected float getUncertainty() {
        return 6.0f;
    }
    
    protected float getPower() {
        return 1.1f;
    }
}
