Skip to content

Cancel painting teleports to the same block - #724

Open
roccodev wants to merge 1 commit into
ViaVersion:masterfrom
roccodev:fix/painting-teleport
Open

Cancel painting teleports to the same block#724
roccodev wants to merge 1 commit into
ViaVersion:masterfrom
roccodev:fix/painting-teleport

Conversation

@roccodev

@roccodev roccodev commented Sep 3, 2026

Copy link
Copy Markdown

In 1.8 (and presumably below?), teleporting a painting to the same block, or too close to its current entity coordinates causes it to calculate the wrong block coordinates and move a block out.

This issue can be reproduced in a Paper 26.2 server. Since this commit, entities will broadcast a teleport packet every time a new player is tracked. I don't think teleport is normally sent for paintings otherwise (unless you /tp them far enough away)

Note: This depends on ViaVersion/ViaBackwards#1313 to get accurate entity coordinates from the upstream protocols.

For reference, in EntityPainting:

@SideOnly(Side.CLIENT)
public void setPositionAndRotation2(double x, double y, double z, float yaw, float pitch, int posRotationIncrements, boolean p_180426_10_) {
    BlockPos blockpos = this.hangingPosition.add(x - this.posX, y - this.posY, z - this.posZ);
    this.setPosition((double)blockpos.getX(), (double)blockpos.getY(), (double)blockpos.getZ());
}

However, setPosition immediately overwrites the entity coordinates, and only performs the painting recalculation if the attached block is different:

public void setPosition(double x, double y, double z) {
    this.posX = x;
    this.posY = y;
    this.posZ = z;
    // ^ The entity coordinates aren't supposed to be the block coordinates (in 1.8)
    
    BlockPos blockpos = this.hangingPosition;
    this.hangingPosition = new BlockPos(x, y, z);

    if (!this.hangingPosition.equals(blockpos))
    {
        // This recalculates the entity coordinates
        // ...but only if the painting moved to a different block
        this.updateBoundingBox();
        // ...
    }
}

I couldn't reproduce the issue in 1.9, which makes me think it's a 1.8 issue, though I haven't looked at its code.

Here is the bug in action, by the way:

out.mp4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant