The bug
The swimming statistic only counts swimming in water, not lava. This is annoying for adventure maps, and also means that hunger will never decrease while the player is swimming or walking in lava.
Code analysis
Code analysis by @unknown:
The following is based on a decompiled version of MC 1.12 using MCP 9.40pre-1.
The issue is that in the method net.minecraft.entity.player.EntityPlayer.addMovementStat()
the if-statement for incrementing the SWIM_ONE_CM
stat only checks if the player is in water and therefore doesn't increment the stat when the player is in lava. Thus a very, very simple fix is to add a check if the player is in lava (EntityPlayer.isInLava()) to the if-statement using the OR operator (||).
else if (this.isInWater() || this.isInLava())
{
int j = Math.round(MathHelper.sqrt(p_71000_1_ * p_71000_1_ + p_71000_5_ * p_71000_5_) * 100.0F);
if (j > 0)
{
this.addStat(StatList.SWIM_ONE_CM, j);
this.addExhaustion(0.01F * (float)j * 0.01F);
}
}
Linked issues
relates to 1
Attachments
Comments 10
This is also the case for stat.diveOneCm. Should we add that to this bug report instead of making a new one?
Confirmed for Minecraft 1.12.2 and 17w46a.
This report should be changed to talk about minecraft.custom:minecraft.walkon_water_one_cm
instead of minecraft.custom:minecraft.swim_one_cm
, the swimming stat only increases in the "new" 1.14 swimming mechanic; distance swum became distance walked in/under water instead.
Can confirm for MC 1.12.1.