@@ -211,38 +211,69 @@ public static <B extends BlockStateHolder<B>> B transform(B block, Transform tra
211211 result = result .with (enumProp , newValue );
212212 }
213213 }
214- } else if (property .getName ().equals ("orientation" ) && transform instanceof AffineTransform affineTransform ) {
215- // crafters
216- if (affineTransform .isHorizontalFlip ()) {
217- String value = (String ) result .getState (property );
218- String newValue = switch (value ) {
219- case "north_up" -> "south_up" ;
220- case "south_up" -> "north_up" ;
221- case "east_up" -> "west_up" ;
222- case "west_up" -> "east_up" ;
223- default -> null ;
224- };
225- if (newValue != null && enumProp .getValues ().contains (newValue )) {
226- result = result .with (enumProp , newValue );
227- }
228- }
214+
215+ // rails
229216 if (affineTransform .isVerticalFlip ()) {
230217 String value = (String ) result .getState (property );
231218 String newValue = switch (value ) {
232- case "down_east" -> "up_east" ;
233- case "down_north" -> "up_north" ;
234- case "down_south" -> "up_south" ;
235- case "down_west" -> "up_west" ;
236- case "up_east" -> "down_east" ;
237- case "up_north" -> "down_north" ;
238- case "up_south" -> "down_south" ;
239- case "up_west" -> "down_west" ;
219+ case "ascending_east" -> "ascending_west" ;
220+ case "ascending_west" -> "ascending_east" ;
221+ case "ascending_north" -> "ascending_south" ;
222+ case "ascending_south" -> "ascending_north" ;
240223 default -> null ;
241224 };
242225 if (newValue != null && enumProp .getValues ().contains (newValue )) {
243226 result = result .with (enumProp , newValue );
244227 }
245228 }
229+
230+ String value = (String ) result .getState (property );
231+
232+ String [] parts = value .split ("_" );
233+ String newStartString = parts [0 ];
234+ if (!newStartString .equals ("ascending" )) {
235+ Direction start = Direction .valueOf (parts [0 ].toUpperCase (Locale .ROOT ));
236+ Vector3 newStartVec = transform .apply (start .toVector ());
237+ Direction newStart = Direction .findClosest (newStartVec , Direction .Flag .CARDINAL );
238+ newStartString = newStart .toString ().toLowerCase (Locale .ROOT );
239+ }
240+
241+ Direction end = Direction .valueOf (parts [1 ].toUpperCase (Locale .ROOT ));
242+ Vector3 newEndVec = transform .apply (end .toVector ());
243+ Direction newEnd = Direction .findClosest (newEndVec , Direction .Flag .CARDINAL );
244+ String newEndString = newEnd .toString ().toLowerCase (Locale .ROOT );
245+
246+ String newShape = newStartString + "_" + newEndString ;
247+ String newShapeSwapped = newEndString + "_" + newStartString ;
248+ if (enumProp .getValues ().contains (newShape )) {
249+ result = result .with (enumProp , newShape );
250+ } else if (enumProp .getValues ().contains (newShapeSwapped )) {
251+ result = result .with (enumProp , newShapeSwapped );
252+ }
253+ } else if (property .getName ().equals ("orientation" ) && transform instanceof AffineTransform affineTransform ) {
254+ // crafters
255+ String current = (String ) result .getState (property );
256+
257+ String [] parts = current .split ("_" );
258+ Direction facing = Direction .valueOf (parts [0 ].toUpperCase (Locale .ROOT ));
259+ Direction top = Direction .valueOf (parts [1 ].toUpperCase (Locale .ROOT ));
260+
261+ Vector3 newFacingVec = transform .apply (facing .toVector ());
262+ Vector3 newTopVec = transform .apply (top .toVector ());
263+
264+ Direction newFacing = Direction .findClosest (newFacingVec , Direction .Flag .CARDINAL | Direction .Flag .UPRIGHT );
265+ Direction newTop = Direction .findClosest (newTopVec , Direction .Flag .CARDINAL | Direction .Flag .UPRIGHT );
266+ if (newTop .toString ().equals (Direction .DOWN .toString ())) {
267+ newTop = Direction .UP ;
268+ }
269+
270+ String newOrientation = newFacing .toString ().toLowerCase (Locale .ROOT )
271+ + "_" + newTop .toString ().toLowerCase (Locale .ROOT );
272+
273+ if (enumProp .getValues ().contains (newOrientation )) {
274+ result = result .with (enumProp , newOrientation );
275+ }
276+
246277 }
247278 } else if (property instanceof IntegerProperty intProp ) {
248279 if (property .getName ().equals ("rotation" )) {
0 commit comments