package common.item.block;

import common.block.tech.BlockTNT;
import common.color.TextColor;
import common.entity.item.EntityTnt;
import common.entity.types.EntityLiving;
import common.init.SoundEvent;
import common.item.ItemStack;
import common.tileentity.TileEntity;
import common.util.BlockPos;
import common.util.Facing;
import common.util.Vec3;
import common.world.World;

public class ItemTNT extends ItemBlock {
	private final int power;
	
	public ItemTNT(BlockTNT block) {
		super(block);
		this.power = block.getExplosionPower();
		this.setColor(TextColor.RED);
	}

	public ItemStack dispenseStack(World world, TileEntity source, Vec3 position, BlockPos blockpos, Facing facing, ItemStack stack) {
        blockpos = blockpos.offset(facing);
        EntityTnt entitytntprimed = new EntityTnt(world, (double)blockpos.getX() + 0.5D, (double)blockpos.getY(), (double)blockpos.getZ() + 0.5D, (EntityLiving)null, this.power);
        world.spawnEntityInWorld(entitytntprimed);
        world.playSoundAtEntity(entitytntprimed, SoundEvent.FUSE, 1.0F);
        --stack.size;
        return stack;
	}
}
