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 fl, final ItemStack ben) {
        final Level bjw4 = fl.getLevel();
        final Position fz5 = DispenserBlock.getDispensePosition(fl);
        final Direction fp6 = fl.getBlockState().<Direction>getValue((Property<Direction>)DispenserBlock.FACING);
        final Projectile ayy7 = this.getProjectile(bjw4, fz5, ben);
        ayy7.shoot(fp6.getStepX(), fp6.getStepY() + 0.1f, fp6.getStepZ(), this.getPower(), this.getUncertainty());
        bjw4.addFreshEntity((Entity)ayy7);
        ben.shrink(1);
        return ben;
    }
    
    @Override
    protected void playSound(final BlockSource fl) {
        fl.getLevel().levelEvent(1002, fl.getPos(), 0);
    }
    
    protected abstract Projectile getProjectile(final Level bjw, final Position fz, final ItemStack ben);
    
    protected float getUncertainty() {
        return 6.0f;
    }
    
    protected float getPower() {
        return 1.1f;
    }
}
