-
Bug
-
Resolution: Unresolved
-
None
-
Minecraft 1.9.3 Pre-Release 1, Minecraft 1.10.2, Minecraft 16w43a, Minecraft 1.12, Minecraft 1.12.1, Minecraft 1.12.2, Minecraft 17w45b, Minecraft 17w46a, Minecraft 18w07c, Minecraft 1.13, Minecraft 1.13.1-pre2, Minecraft 1.13.1, Minecraft 1.13.2-pre1, Minecraft 1.13.2, Minecraft 18w48a, Minecraft 18w48b, Minecraft 18w49a, 1.15.2, 20w15a, 20w49a, 21w05b, 1.21.1
-
Confirmed
-
Statistics
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 bemoty:
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); } }
- relates to
-
MC-122116 "minecraft.custom:minecraft.walk_under_water_one_cm" doesn't increase when walking through lava
- Open