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

Coding error at net.minecraft.world.entity.Entity.resetPos()

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Resolution: Fixed
    • Affects Version/s: 20w48a
    • Fix Version/s: 20w49a
    • Labels:
      None
    • Confirmation Status:
      Plausible
    • Category:
      Entities
    • Mojang Priority:
      Important

      Description

      Code analysis:

      Since the minecraft team is adding support for changing the world height there are more methods calling for the minimum (and maximum) world height. At net.minecraft.world.entity.Entity.resetPos(), a 'for' is asking if a number 'y' is lower and higher than the minimum world height, that number increases:

       

          protected void resetPos() {
              if (this.level == null) {
                  return;
              }
              for (double y = this.getY(); y > (double)this.level.getMinBuildHeight() && y < (double)this.level.getMinBuildHeight(); y += 1.0) {
                  this.setPos(this.getX(), y, this.getZ());
                  if (this.level.noCollision(this)) {
                      break;
                  }
              }
              this.setDeltaMovement(Vec3.ZERO);
              this.xRot = 0.0f;
          }
      

      >This causes client-side bugs at the player's Y when logging in or respawning.

      The solution is easy, just change the 'less than' conditional to 'y < (double)this.level.getMaxBuildHeight()'

       

      After fixing, it would look like this:

       

           protected void resetPos() {
              if (this.level == null) {
                  return;
              }
              for (double y = this.getY(); y > (double)this.level.getMinBuildHeight() && y < (double)this.level.getMaxBuildHeight(); y += 1.0) {
                  this.setPos(this.getX(), y, this.getZ());
                  if (this.level.noCollision(this)) {
                      break;
                  }
              }
              this.setDeltaMovement(Vec3.ZERO);
              this.xRot = 0.0f;
          }
      

       

       

        Attachments

          Activity

            People

            Assignee:
            panda4994 [Mojang] Panda
            Reporter:
            ISRosillo14 Ismael Rosillo
            Votes:
            1 Vote for this issue
            Watchers:
            4 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              CHK: