The Bug:
Fire charges won't be consumed when igniting creepers with them in survival or adventure mode.
Differently, while igniting a TNT, the fire charge is consumed.
Steps to Reproduce:
Obtain a fire charge and switch into survival mode.
Summon a creeper and use the fire charge on it.
Take note as to whether or not fire charges are consumed when igniting creepers using them in survival or adventure mode.
Observed Behavior:
The fire charge is not consumed.
Expected Behavior:
The fire charge would be consumed.
Code Analysis:
Code analysis by @unknown can be found in this comment.
Here's a code analysis of this issue along with a fix. 😉
Code Analysis:
The following is based on a decompiled version of Minecraft 1.19.3 Release Candidate 3 using Mojang mappings.
net.minecraft.world.entity.monster.Creeper.java
If we look at the above class, we can see that when an item that's included within the
CREEPER_IGNITERS
item tag is used on a creeper, thehurtAndBreak()
method is called. This method is specifically and exclusively designed to decrease the durability of an item that can be damaged. Because fire charges don't have durability, this results in them not being consumed when using them on creepers, therefore resulting in this problem occurring.Fix:
Simply adding some lines of code to call a certain method based on what item players use to interact with creepers, will resolve this problem. When players interact with creepers using flint and steel, the
hurtAndBreak()
method should be called, and on the other hand, when players interact with creepers using fire charges, theshrink()
method should be called.