Uploaded image for project: 'Minecraft: Java Edition'
  1. Minecraft: Java Edition
  2. MC-101297

Distance swum statistic doesn't increment in lava

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Open
    • Resolution: Unresolved
    • Affects Version/s: 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
    • Fix Version/s: None
    • Confirmation Status:
      Confirmed
    • Category:
      (Unassigned)

      Description

      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 [Mod] 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);
          }
      }
      

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                KingSupernova KingSupernova
              • Votes:
                6 Vote for this issue
                Watchers:
                5 Start watching this issue

                Dates

                • Created:
                  Updated:
                  CHK: