What is happening?
Probably Minecraft have bad days and don't want to load world/structures/structure.nbt/palette/(noname)/Properties/shape
String
.
Unexpected is that the shape String is loaded normally for stairs that have also this variable.
How to reproduce
Build some rail art as shown on
. You have to build it in the directions of the world shown in screenshot.
Save it as a new structure using a structure block
When you load this structure first time, you will see that it messed up the rail art as can be seen on
When you load it second time, it will load normally
Code analysis
Code analysis by @unknown can be found in this comment.
Related issues
is duplicated by
relates to
Attachments
Comments


Confirmed for 1.10-pre2, 1.10-pre1, 16w21b, 16w20a

Confirmed for 1.10.2

Still an issue in 16w33a.
Also probably won't be fixed for the same reason it wasn't in MC-42375 (because of Searge's comment on MC-31365)

Structure blocks have a bug rotating rails. The 90 and 270 degree rotation work fine but 180 degree have a bug where straight rails can rotate into a broken state when loading in a structure with straight rails. All other types of rails, curved or sloped rails can get into an odd state but when attempting to reload the structure a 2nd time the reload fixes the miss connected rails, all but the straight rails. Picture attached shows the bug were straight rails are saved into the structure and when the structure is rotated 180 degrees the rails don’t load correctly.
This is caused by rails having no set 180 degree rotation. The switch case lacks that rotation as it naturally doesn't have to rotate. But what happens is that the default rotation is chosen and the default rotation is the same rotation you place rails at. In some instances this angle is 90 degrees from the single placed rail causing the error. BlockRail.java, BlockRailDetector.java and BlockRailPowered.java all have the same exact method “withRotation”. This method lacks the 3 180 orentations that are related to straight rails. The switch statement fails and the rotation ends up setting the default rail orientation for the straight rails.
Code suggestion would be to move this method to the superclass and add the missing rotations to the 180 degree turn. Code suggestion for clarity.
public IBlockState withRotation(IBlockState state, Rotation rot)
{
switch (rot)
{
case CLOCKWISE_180:
switch ((BlockRailBase.EnumRailDirection)state.getValue(SHAPE))
{
// missing direction statement.
case NORTH_SOUTH:
return state.withProperty(SHAPE, BlockRailBase.EnumRailDirection.NORTH_SOUTH);
// and this one.
case EAST_WEST:
return state.withProperty(SHAPE, BlockRailBase.EnumRailDirection.EAST_WEST);
case ASCENDING_NORTH:
return state.withProperty(SHAPE, BlockRailBase.EnumRailDirection.ASCENDING_SOUTH);
case ASCENDING_SOUTH:
return state.withProperty(SHAPE, BlockRailBase.EnumRailDirection.ASCENDING_NORTH);
case SOUTH_EAST:
return state.withProperty(SHAPE, BlockRailBase.EnumRailDirection.NORTH_WEST);
case SOUTH_WEST:
return state.withProperty(SHAPE, BlockRailBase.EnumRailDirection.NORTH_EAST);
case NORTH_WEST:
return state.withProperty(SHAPE, BlockRailBase.EnumRailDirection.SOUTH_EAST);
case NORTH_EAST:
return state.withProperty(SHAPE, BlockRailBase.EnumRailDirection.SOUTH_WEST);
}
case COUNTERCLOCKWISE_90:
switch ((BlockRailBase.EnumRailDirection)state.getValue(SHAPE))
{
case ASCENDING_EAST:
return state.withProperty(SHAPE, BlockRailBase.EnumRailDirection.ASCENDING_NORTH);
case ASCENDING_WEST:
return state.withProperty(SHAPE, BlockRailBase.EnumRailDirection.ASCENDING_SOUTH);
case ASCENDING_NORTH:
return state.withProperty(SHAPE, BlockRailBase.EnumRailDirection.ASCENDING_WEST);
case ASCENDING_SOUTH:
return state.withProperty(SHAPE, BlockRailBase.EnumRailDirection.ASCENDING_EAST);
case SOUTH_EAST:
return state.withProperty(SHAPE, BlockRailBase.EnumRailDirection.NORTH_EAST);
case SOUTH_WEST:
return state.withProperty(SHAPE, BlockRailBase.EnumRailDirection.SOUTH_EAST);
case NORTH_WEST:
return state.withProperty(SHAPE, BlockRailBase.EnumRailDirection.SOUTH_WEST);
case NORTH_EAST:
return state.withProperty(SHAPE, BlockRailBase.EnumRailDirection.NORTH_WEST);
case NORTH_SOUTH:
return state.withProperty(SHAPE, BlockRailBase.EnumRailDirection.EAST_WEST);
case EAST_WEST:
return state.withProperty(SHAPE, BlockRailBase.EnumRailDirection.NORTH_SOUTH);
}
case CLOCKWISE_90:
switch ((BlockRailBase.EnumRailDirection)state.getValue(SHAPE))
{
case ASCENDING_EAST:
return state.withProperty(SHAPE, BlockRailBase.EnumRailDirection.ASCENDING_SOUTH);
case ASCENDING_WEST:
return state.withProperty(SHAPE, BlockRailBase.EnumRailDirection.ASCENDING_NORTH);
case ASCENDING_NORTH:
return state.withProperty(SHAPE, BlockRailBase.EnumRailDirection.ASCENDING_EAST);
case ASCENDING_SOUTH:
return state.withProperty(SHAPE, BlockRailBase.EnumRailDirection.ASCENDING_WEST);
case SOUTH_EAST:
return state.withProperty(SHAPE, BlockRailBase.EnumRailDirection.SOUTH_WEST);
case SOUTH_WEST:
return state.withProperty(SHAPE, BlockRailBase.EnumRailDirection.NORTH_WEST);
case NORTH_WEST:
return state.withProperty(SHAPE, BlockRailBase.EnumRailDirection.NORTH_EAST);
case NORTH_EAST:
return state.withProperty(SHAPE, BlockRailBase.EnumRailDirection.SOUTH_EAST);
case NORTH_SOUTH:
return state.withProperty(SHAPE, BlockRailBase.EnumRailDirection.EAST_WEST);
case EAST_WEST:
return state.withProperty(SHAPE, BlockRailBase.EnumRailDirection.NORTH_SOUTH);
}
default:
return state;
}
}

I get bugged rails even with no rotation applied.
By the way, confirmed for 1.13-pre3.
Hi there!
I can confirm this for 1.16.1 and 20w28a.

Can confirm for 1.17.1

Can confirm in 1.18-pre6

Can confirm in 1.18

can confirm in 1.19

Can confirm for 1.20.1.
This affects not just creative mode loading structure blocks, but also datapacks procedurally loading a structure during worldgen such as a village house or a street.

This isn't completely fixed in 23w40a, but is better. It seems rails for the most part do load properly, but in instances like Step1.png and Step2.png where multiple rails run near each other, they may connect incorrectly. However, issues as seen in 180 degree rotation rail bug.png seem resolved. So, improvements have been made but overall this issue is still somewhat present in 23w40a.