001package net.minecraft.dispenser; 002 003import net.minecraft.block.BlockDispenser; 004import net.minecraft.entity.Entity; 005import net.minecraft.entity.IProjectile; 006import net.minecraft.item.ItemStack; 007import net.minecraft.util.EnumFacing; 008import net.minecraft.world.World; 009 010public abstract class BehaviorProjectileDispense extends BehaviorDefaultDispenseItem 011{ 012 /** 013 * Dispense the specified stack, play the dispense sound and spawn particles. 014 */ 015 public ItemStack dispenseStack(IBlockSource par1IBlockSource, ItemStack par2ItemStack) 016 { 017 World world = par1IBlockSource.getWorld(); 018 IPosition iposition = BlockDispenser.getIPositionFromBlockSource(par1IBlockSource); 019 EnumFacing enumfacing = BlockDispenser.getFacing(par1IBlockSource.getBlockMetadata()); 020 IProjectile iprojectile = this.getProjectileEntity(world, iposition); 021 iprojectile.setThrowableHeading((double)enumfacing.getFrontOffsetX(), (double)((float)enumfacing.getFrontOffsetY() + 0.1F), (double)enumfacing.getFrontOffsetZ(), this.func_82500_b(), this.func_82498_a()); 022 world.spawnEntityInWorld((Entity)iprojectile); 023 par2ItemStack.splitStack(1); 024 return par2ItemStack; 025 } 026 027 /** 028 * Play the dispense sound from the specified block. 029 */ 030 protected void playDispenseSound(IBlockSource par1IBlockSource) 031 { 032 par1IBlockSource.getWorld().playAuxSFX(1002, par1IBlockSource.getXInt(), par1IBlockSource.getYInt(), par1IBlockSource.getZInt(), 0); 033 } 034 035 /** 036 * Return the projectile entity spawned by this dispense behavior. 037 */ 038 protected abstract IProjectile getProjectileEntity(World world, IPosition iposition); 039 040 protected float func_82498_a() 041 { 042 return 6.0F; 043 } 044 045 protected float func_82500_b() 046 { 047 return 1.1F; 048 } 049}