Java Code Examples for net.minecraft.init.Items.FLINT_AND_STEEL

The following are Jave code examples for showing how to use FLINT_AND_STEEL of the net.minecraft.init.Items class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: Halloween   File: EntityCreeperween.java   View Source Code Vote up 6 votes
@Override
protected boolean processInteract(EntityPlayer player, EnumHand hand)
{
	ItemStack stack = player.getHeldItem(hand);
	if (!stack.isEmpty() && stack.getItem() == Items.FLINT_AND_STEEL)
	{
		this.world.playSound(player, this.posX, this.posY, this.posZ, SoundEvents.ITEM_FLINTANDSTEEL_USE, this.getSoundCategory(), 1.0F, this.rand.nextFloat() * 0.4F + 0.8F);
		player.swingArm(hand);

		if (!this.world.isRemote)
		{
			this.ignite();
			stack.damageItem(1, player);
			return true;
		}
	}
	return super.processInteract(player, hand);
}
 
Example 2
Project: Backmemed   File: EntityCreeper.java   View Source Code Vote up 6 votes
protected boolean processInteract(EntityPlayer player, EnumHand hand)
{
    ItemStack itemstack = player.getHeldItem(hand);

    if (itemstack.getItem() == Items.FLINT_AND_STEEL)
    {
        this.world.playSound(player, this.posX, this.posY, this.posZ, SoundEvents.ITEM_FLINTANDSTEEL_USE, this.getSoundCategory(), 1.0F, this.rand.nextFloat() * 0.4F + 0.8F);
        player.swingArm(hand);

        if (!this.world.isRemote)
        {
            this.ignite();
            itemstack.damageItem(1, player);
            return true;
        }
    }

    return super.processInteract(player, hand);
}
 
Example 3
Project: Backmemed   File: BlockTNT.java   View Source Code Vote up 6 votes
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, EnumFacing heldItem, float side, float hitX, float hitY)
{
    ItemStack itemstack = playerIn.getHeldItem(hand);

    if (!itemstack.func_190926_b() && (itemstack.getItem() == Items.FLINT_AND_STEEL || itemstack.getItem() == Items.FIRE_CHARGE))
    {
        this.explode(worldIn, pos, state.withProperty(EXPLODE, Boolean.valueOf(true)), playerIn);
        worldIn.setBlockState(pos, Blocks.AIR.getDefaultState(), 11);

        if (itemstack.getItem() == Items.FLINT_AND_STEEL)
        {
            itemstack.damageItem(1, playerIn);
        }
        else if (!playerIn.capabilities.isCreativeMode)
        {
            itemstack.func_190918_g(1);
        }

        return true;
    }
    else
    {
        return super.onBlockActivated(worldIn, pos, state, playerIn, hand, heldItem, side, hitX, hitY);
    }
}
 
Example 4
Project: CustomWorldGen   File: EntityCreeper.java   View Source Code Vote up 6 votes
protected boolean processInteract(EntityPlayer player, EnumHand hand, @Nullable ItemStack stack)
{
    if (stack != null && stack.getItem() == Items.FLINT_AND_STEEL)
    {
        this.worldObj.playSound(player, this.posX, this.posY, this.posZ, SoundEvents.ITEM_FLINTANDSTEEL_USE, this.getSoundCategory(), 1.0F, this.rand.nextFloat() * 0.4F + 0.8F);
        player.swingArm(hand);

        if (!this.worldObj.isRemote)
        {
            this.ignite();
            stack.damageItem(1, player);
            return true;
        }
    }

    return super.processInteract(player, hand, stack);
}
 
Example 5
Project: CustomWorldGen   File: BlockTNT.java   View Source Code Vote up 6 votes
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, @Nullable ItemStack heldItem, EnumFacing side, float hitX, float hitY, float hitZ)
{
    if (heldItem != null && (heldItem.getItem() == Items.FLINT_AND_STEEL || heldItem.getItem() == Items.FIRE_CHARGE))
    {
        this.explode(worldIn, pos, state.withProperty(EXPLODE, Boolean.valueOf(true)), playerIn);
        worldIn.setBlockState(pos, Blocks.AIR.getDefaultState(), 11);

        if (heldItem.getItem() == Items.FLINT_AND_STEEL)
        {
            heldItem.damageItem(1, playerIn);
        }
        else if (!playerIn.capabilities.isCreativeMode)
        {
            --heldItem.stackSize;
        }

        return true;
    }
    else
    {
        return super.onBlockActivated(worldIn, pos, state, playerIn, hand, heldItem, side, hitX, hitY, hitZ);
    }
}
 
Example 6
Project: Bewitchment   File: BlockCandle.java   View Source Code Vote up 5 votes
@Override
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) {
	final TileCandle candle = (TileCandle) worldIn.getTileEntity(pos);
	if (candle != null) {
		ItemStack heldItem = playerIn.getHeldItem(hand);
		if (!heldItem.isEmpty() && heldItem.getItem() == Items.FLINT_AND_STEEL) {
			heldItem.damageItem(1, playerIn);
			candle.litCandle();
		} else {
			candle.unLitCandle();
		}
	}
	return true;
}
 
Example 7
Project: Torched   File: ItemRenderTorchGun.java   View Source Code Vote up 5 votes
public ItemRenderTorchGun()
{
    torchGunModel = new ModelTorchGun();
    rand = new Random();
    flintSteel = new ItemStack(Items.FLINT_AND_STEEL);
    powder = new ItemStack(Items.BLAZE_POWDER);
    torch = new ItemStack(Blocks.TORCH);
}
 
Example 8
Project: Torched   File: EntityTorchFirework.java   View Source Code Vote up 4 votes
@Override
public boolean processInitialInteract(EntityPlayer player, EnumHand hand)
{
    if(!world.isRemote && !activating)
    {
        ItemStack is = player.getHeldItem(hand);
        if(is.getItem() == Item.getItemFromBlock(Blocks.TORCH) && getTorches() < 512)
        {
            addTorches(1);
            if(!player.capabilities.isCreativeMode)
            {
                is.shrink(1);
                if(is.isEmpty())
                {
                    player.inventory.mainInventory.set(player.inventory.currentItem, ItemStack.EMPTY);
                }
            }
            player.swingArm(hand);
            return true;
        }
        else if(is.getItem() == Items.GUNPOWDER && getGP() < 512)
        {
            addGP(1);
            if(!player.capabilities.isCreativeMode)
            {
                is.shrink(1);
                if(is.isEmpty())
                {
                    player.inventory.mainInventory.set(player.inventory.currentItem, ItemStack.EMPTY);
                }
            }
            player.swingArm(hand);
            return true;
        }
        else if(is.getItem() == Items.FLINT_AND_STEEL)
        {
            activating = true;
            if(!player.capabilities.isCreativeMode)
            {
                is.setItemDamage(is.getItemDamage() + 1);
            }
            initiator = player;
            player.swingArm(hand);
            return true;
        }
        else if(is.getItem() == Items.GOLD_NUGGET && getSplits() < 16)
        {
            addSplit();
            if(!player.capabilities.isCreativeMode)
            {
                is.shrink(1);
                if(is.isEmpty())
                {
                    player.inventory.mainInventory.set(player.inventory.currentItem, ItemStack.EMPTY);
                }
            }
            player.swingArm(hand);
            return true;
        }
    }
    if(world.isRemote && (player.getHeldItem(hand).getItem() == Item.getItemFromBlock(Blocks.TORCH) || player.getHeldItem(hand).getItem() == Items.GUNPOWDER || player.getHeldItem(hand).getItem() == Items.FLINT_AND_STEEL || player.getHeldItem(hand).getItem() == Items.GOLD_NUGGET))
    {
        player.swingArm(hand);
        return true;
    }
    return false;
}