Mojira Archive
MC-4923

Flint and steel and fire charges can place fire at invalid positions

The bug

Flint and steel places fire at invalid positions, for example on the side of non-inflammable blocks like stone which causes the fire block to disappear the next time it is updated.

How to reproduce

  1. Right click with a flint and steel on a side of block that can't normally catch on fire (Stone for example).
  2. The fire block will appear for a tick.

Note: The fire does not set any entities at the position on fire.

Code analysis

The following is based on decompiled version of Minecraft 1.8 using MCP. All method and class names are the names used in the decompiled version.

The reason for this is that the fire block is actually created. However, the public void onBlockAdded(World worldIn, BlockPos pos, IBlockState state) method of the net.minecraft.block.BlockFire class is called right after it was placed and removes the block as it is at an invalid position.
This could / should be fixed by having the public boolean onItemUse(ItemStack stack, EntityPlayer playerIn, World worldIn, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ) method of the net.minecraft.item.ItemFlintAndSteel class only place a fire block is the position is valid. Other items like the bucket might be affected as well, however currently you can place water and lava on every block so it causes no problems.

/**
 * Called when a Block is right-clicked with this Item
 *  
 * @param pos The block being right-clicked
 * @param side The side being right-clicked
 */
public boolean onItemUse(ItemStack stack, EntityPlayer playerIn, World worldIn, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ)
{
    pos = pos.offset(side);

    if (!playerIn.func_175151_a(pos, side, stack))
    {
        return false;
    }
    else
    {
        // Changed this
        //if (worldIn.getBlockState(pos).getBlock().getMaterial() == Material.air)
        if (worldIn.getBlockState(pos).getBlock().getMaterial() == Material.air && Blocks.fire.canPlaceBlockAt(worldIn, pos))
        {
            worldIn.playSoundEffect((double)pos.getX() + 0.5D, (double)pos.getY() + 0.5D, (double)pos.getZ() + 0.5D, "fire.ignite", 1.0F, itemRand.nextFloat() * 0.4F + 0.8F);
            worldIn.setBlockState(pos, Blocks.fire.getDefaultState());
        }

        stack.damageItem(1, playerIn);
        return true;
    }
}
Notes
  • A similar fix would be needed for the fire_charge item and also for the net.minecraft.init.Bootstrap.registerDispenserBehaviors for these items.
  • This fix does not include the use of these items at invalid locations to activate a Nether portal, which could then be moved from net.minecraft.block.BlockFire.onBlockAdded(World, BlockPos, IBlockState) to the respective methods when using an item to create a fire block.