mojira.dev
MC-207916

Flint and steel and fire charges do not make a sound when igniting TNT

The bug

When lighting TNT using flint and steel or with a fire charge, the minecraft:item.flintandsteel.use or minecraft:item.firecharge.use sound is not played. This is inconsistent with all other uses of flint and steel and all other uses of fire charges, which all play the sound.

How to reproduce

  1. Place TNT

  2. Ignite the TNT using flint and steel
    ❌ No click sound is heard from the flint and steel

Expected behavior

The minecraft:item.flintandsteel.use or the minecraft:item.firecharge.use sound would be played when igniting TNT with flint and steel or with a fire charge.

Code analysis

Code analysis by @unknown can be found in this comment.

Linked issues

Attachments

Comments 17

Can confirm for 1.16.4 and 20w49a, this also affects fire charges.

Can confirm in 21w03a.

Can confirm in 21w05b.

Can confirm in 21w06a.

Can confirm 1.16.5 and 21w07a.

7 more comments

Can confirm in 1.18.1.

It's important to note that this same concept can also be seen with fire charges as well. In other words, when a fire change is used to ignite TNT, the minecraft:item.firecharge.use sound isn't played.

Here's a code analysis along with a potential fix regarding this issue.

Code Analysis:

The following is based on a decompiled version of Minecraft 1.18.1 using MCP-Reborn.

net.minecraft.world.level.block.TntBlock.java

public class TntBlock extends Block {
   ...
   public InteractionResult use(BlockState $bs, Level $l, BlockPos $bp, Player $p, InteractionHand $ih, BlockHitResult $bhr) {
      ItemStack itemstack = $p.getItemInHand($ih);
      if (!itemstack.is(Items.FLINT_AND_STEEL) && !itemstack.is(Items.FIRE_CHARGE)) {
         return super.use($bs, $l, $bp, $p, $ih, $bhr);
      } else {
         explode($l, $bp, $p);
         $l.setBlock($bp, Blocks.AIR.defaultBlockState(), 11);
         Item item = itemstack.getItem();
         if (!$p.isCreative()) {
            if (itemstack.is(Items.FLINT_AND_STEEL)) {
               itemstack.hurtAndBreak(1, $p, (p_57425_) -> {
                  p_57425_.broadcastBreakEvent($ih);
               });
            } else {
               itemstack.shrink(1);
            }
         }

         $p.awardStat(Stats.ITEM_USED.get(item));
         return InteractionResult.sidedSuccess($l.isClientSide);
      }
   }
   ...

If we look at the above class, we can see that the minecraft:item.flintandsteel.use and minecraft:item.firecharge.use sounds aren't played when igniting TNT through using some flint and steel or a fire charge.

Potential Fix:

Simply adding some lines of code that play the appropriate sound when using some flint and steel or a fire charge to ignite TNT, should resolve this problem. The following line of codes could be used in order to fix this:

$l.playSound((Player)null, $bp, SoundEvents.FLINTANDSTEEL_USE, SoundSource.BLOCKS, 1.0F, 1.0F);
$l.playSound((Player)null, $bp, SoundEvents.FIRECHARGE_USE, SoundSource.BLOCKS, 1.0F, 1.0F);

The correct pieces of code within its class should look something like the following:

net.minecraft.world.level.block.TntBlock.java

public class TntBlock extends Block {
   ...
   public InteractionResult use(BlockState $bs, Level $l, BlockPos $bp, Player $p, InteractionHand $ih, BlockHitResult $bhr) {
      ItemStack itemstack = $p.getItemInHand($ih);
      if (!itemstack.is(Items.FLINT_AND_STEEL) && !itemstack.is(Items.FIRE_CHARGE)) {
         return super.use($bs, $l, $bp, $p, $ih, $bhr);
      } else {
         explode($l, $bp, $p);
         $l.setBlock($bp, Blocks.AIR.defaultBlockState(), 11);
         Item item = itemstack.getItem();
         if (!$p.isCreative()) {
            if (itemstack.is(Items.FLINT_AND_STEEL)) {
               $l.playSound((Player)null, $bp, SoundEvents.FLINTANDSTEEL_USE, SoundSource.BLOCKS, 1.0F, 1.0F);
               itemstack.hurtAndBreak(1, $p, (p_57425_) -> {
                  p_57425_.broadcastBreakEvent($ih);
               });
            } else {
               $l.playSound((Player)null, $bp, SoundEvents.FIRECHARGE_USE, SoundSource.BLOCKS, 1.0F, 1.0F);
               itemstack.shrink(1);
            }
         }

         $p.awardStat(Stats.ITEM_USED.get(item));
         return InteractionResult.sidedSuccess($l.isClientSide);
      }
   }
   ...

Can confirm in 1.18.2 and 22w14a.

Can confirm in 1.19.

Can confirm in 1.19.2.

muzikbike

bl4ckscor3

Confirmed

Sound

missing-sound

1.16.4, 20w49a, 20w51a, 21w03a, 1.16.5, , 1.19, 1.19.2, 1.19.4, 23w14a, 1.20.4

26.4 Snapshot 4

Retrieved