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
is duplicated by 6
relates to 3
Attachments
Comments 22
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.
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.
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.