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
Place TNT
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
discovered while testing 1
Attachments
Comments 17
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 for 1.16.4 and 20w49a, this also affects fire charges.