2013-07-26 21:18:53 -07:00
|
|
|
package tconstruct.util;
|
|
|
|
|
|
|
|
|
|
import net.minecraft.block.BlockDispenser;
|
|
|
|
|
import net.minecraft.dispenser.BehaviorDefaultDispenseItem;
|
|
|
|
|
import net.minecraft.dispenser.IBlockSource;
|
|
|
|
|
import net.minecraft.entity.EntityLiving;
|
|
|
|
|
import net.minecraft.item.ItemStack;
|
|
|
|
|
import net.minecraft.util.EnumFacing;
|
2014-02-05 10:28:54 -05:00
|
|
|
import tconstruct.items.TitleIcon;
|
2013-07-26 21:18:53 -07:00
|
|
|
|
|
|
|
|
public class TDispenserBehaviorSpawnEgg extends BehaviorDefaultDispenseItem
|
|
|
|
|
{
|
|
|
|
|
/**
|
2014-02-16 14:23:50 -05:00
|
|
|
* Dispense the specified stack, play the dispense sound and spawn
|
|
|
|
|
* particles.
|
2013-07-26 21:18:53 -07:00
|
|
|
*/
|
2014-02-17 00:31:43 -05:00
|
|
|
@Override
|
2013-07-26 21:18:53 -07:00
|
|
|
public ItemStack dispenseStack (IBlockSource par1IBlockSource, ItemStack par2ItemStack)
|
|
|
|
|
{
|
2014-01-01 08:47:10 -05:00
|
|
|
EnumFacing enumfacing = BlockDispenser.func_149937_b(par1IBlockSource.getBlockMetadata());
|
2013-07-26 21:18:53 -07:00
|
|
|
double d0 = par1IBlockSource.getX() + (double) enumfacing.getFrontOffsetX();
|
|
|
|
|
double d1 = (double) ((float) par1IBlockSource.getYInt() + 0.2F);
|
|
|
|
|
double d2 = par1IBlockSource.getZ() + (double) enumfacing.getFrontOffsetZ();
|
|
|
|
|
EntityLiving entity = TitleIcon.activateSpawnEgg(par2ItemStack, par1IBlockSource.getWorld(), d0, d1, d2, 0);
|
|
|
|
|
|
|
|
|
|
if (par2ItemStack.hasDisplayName())
|
|
|
|
|
{
|
|
|
|
|
((EntityLiving) entity).setCustomNameTag(par2ItemStack.getDisplayName());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
par2ItemStack.splitStack(1);
|
|
|
|
|
return par2ItemStack;
|
|
|
|
|
}
|
|
|
|
|
}
|