mojira.dev
MC-206711

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

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;
    }

 

 

Comments 0

No comments.

ISRosillo14

Panda4994

Plausible

Important

Entities

20w48a

20w49a

Retrieved