mojira.dev
MC-102223

Paintings in structure blocks not loading in same place

The bug

When you place a painting in a Structure and save it using the Save Structure Block, and then Load the structure, the painting will sometimes load one block off.

  • All paintings with even height are loaded off in +Y axis

  • A painting with even width is off if

    • it looks towards +Z when loaded, then it's loaded off in +X

    • it looks towards -X when loaded, then it's loaded off in +Z

Affects rotating/mirroring

Cause

The problem seems to be that the Pos tag of hanging entities refers to the center of the entity, however when it is created the passed position is the position of its corner. This could probably be solved by using the TileX, TileY and TileZ values for hanging entities.

Linked issues

Attachments

Comments 22

Possibly related to this, Item Frames have a similar issue.

When the structure is rotated when loading, the item frame (with item in it) will be floating in front of the wall.

This happens at the 90 and 270 degree rotations.

I added additional screenshots showing the floating item frames.

Testing with Mirrors:

Using the Z-axis mirror (< >), you get the same results for paintings and items frames that you get without mirrors. Painting misplaced at 0 rotation and 270 rotation. Item Frames misplaced at 90 and 270 rotations.

Using the X-axis mirror (^ v), the paintings are all correctly placed at every rotation. However, the Item Frames are misplaced at the 90 and 270 rotations again.

Possibly fixed in 1.10-pre1, but difficult to verify with MC-102894.

The problem seems to be that the Pos tag of hanging entities refers to the center of the entity, however when it is created the passed position is the position of its corner. This could probably be solved by using the TileX, TileY and TileZ values for hanging entities.

12 more comments
image-20250324-202129.png

From reproducing this issue in 1.21.5-rc2

I can’t replicate the issue with paintings moving in 1.21.9, but I could replicate the rotation issue if:

  • Mirror was left-right or front-back

  • Rotation was 90 degrees clockwise or counterclockwise

I was able to fix this by switching the order of the Entity#rotate and Entity#mirror calls in StructureTemplate#placeEntities.

Reproduced in 26.1-snapshot-9.

The issue seems to be with how paintings determine a direction for their offset.

In Painting#calculateBoundingBox, I replaced

Direction left = direction.getCounterClockWise();
Vec3 position = attachedToWall.relative(left, horizontalOffset).relative(Direction.UP, verticalOffset);

with

Direction horizontalDirection = direction.getCounterClockWise().getAxisDirection() == Direction.AxisDirection.NEGATIVE ? direction.getCounterClockWise() : direction.getClockWise();
Vec3 position = attachedToWall.relative(horizontalDirection, horizontalOffset).relative(Direction.DOWN, verticalOffset);

with a mixin, and I seems to fix the issue.

Direction horizontalDirection = direction.getCounterClockWise().getAxisDirection() == Direction.AxisDirection.NEGATIVE
  ? direction.getCounterClockWise() : direction.getClockWise();
Vec3 position = attachedToWall.relative(horizontalDirection, horizontalOffset).relative(Direction.DOWN, verticalOffset);

Posted again because line was too long.

Aniline Selenic

(Unassigned)

Confirmed

Platform

Normal

Structures

painting, structure_block

Minecraft 16w20a, Minecraft 1.10 Pre-Release 2, Minecraft 1.10.2, Minecraft 16w32a, Minecraft 16w32b, , 1.20.6, 1.21 Pre-Release 4, 25w04a, 1.21.5 Release Candidate 2, 26.1 Snapshot 9

Retrieved