Uploaded image for project: 'Minecraft: Java Edition'
  1. Minecraft: Java Edition
  2. MC-4923

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

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Minecraft 1.4.6, Minecraft 1.4.7, Snapshot 13w02a, Snapshot 13w04a, Minecraft 1.5, Snapshot 13w11a, Minecraft 1.5.2, Minecraft 1.6.2, Minecraft 1.6.4, Minecraft 13w36b, Minecraft 13w37b, Minecraft 1.7.4, Minecraft 14w11b, Minecraft 14w27b, Minecraft 14w28a, Minecraft 1.8-pre2, Minecraft 1.8, Minecraft 1.8.1, Minecraft 1.8.2-pre1, Minecraft 1.8.4, Minecraft 1.8.7, Minecraft 1.8.9, Minecraft 16w05b, Minecraft 1.9 Pre-Release 1, Minecraft 1.9, Minecraft 1.9.1 Pre-Release 3, Minecraft 1.9.1, Minecraft 1.9.2, Minecraft 16w15b, Minecraft 1.10.2, Minecraft 16w32a, Minecraft 16w32b, Minecraft 16w33a, Minecraft 16w36a, Minecraft 16w38a, Minecraft 16w39b, Minecraft 16w39c, Minecraft 16w40a, Minecraft 16w41a, Minecraft 16w42a, Minecraft 16w43a, Minecraft 1.11 Pre-Release 1, Minecraft 1.11, Minecraft 16w50a, Minecraft 1.11.1, Minecraft 1.11.2, Minecraft 17w06a, Minecraft 17w13b, Minecraft 17w15a, Minecraft 17w16b, Minecraft 17w17b, Minecraft 17w18b, Minecraft 1.12 Pre-Release 2, Minecraft 1.12 Pre-Release 6, Minecraft 1.12.1, Minecraft 1.12.2, Minecraft 17w45b, Minecraft 17w46a, Minecraft 17w47a, Minecraft 17w47b, Minecraft 17w48a, Minecraft 18w02a
    • Confirmed

      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.

            Excited Maria Lemón
            firehunterx FireHunterX
            Votes:
            17 Vote for this issue
            Watchers:
            18 Start watching this issue

              Created:
              Updated:
              Resolved:
              CHK: