File tree Expand file tree Collapse file tree 3 files changed +31
-3
lines changed Expand file tree Collapse file tree 3 files changed +31
-3
lines changed Original file line number Diff line number Diff line change @@ -146,6 +146,23 @@ export interface IBlueprintFormatJSON {
146146 collections ?: ICollectionJSON [ ]
147147}
148148
149+ export function fixCubeRotation ( cube : Cube ) {
150+ const maxRotation = Math . max ( ...cube . rotation )
151+ const minRotation = Math . min ( ...cube . rotation )
152+ if ( maxRotation <= 45 && minRotation >= - 45 ) {
153+ console . log ( 'Cube rotation is fine, no need to fix' , cube . rotation )
154+ return
155+ }
156+ // Use the rotation with the largest absolute value
157+ const rotation = Math . abs ( maxRotation ) >= Math . abs ( minRotation ) ? maxRotation : minRotation
158+ const axis = cube . rotation . indexOf ( rotation )
159+
160+ const previousSelected = Project ! . selected_elements
161+ Project ! . selected_elements = [ cube ]
162+ rotateOnAxis ( ( ) => rotation , axis , true )
163+ Project ! . selected_elements = previousSelected
164+ }
165+
149166//region > Convert
150167export function convertToBlueprint ( ) {
151168 // Convert the current project to a Blueprint
@@ -278,6 +295,13 @@ export const BLUEPRINT_FORMAT = registerModelFormat(
278295 component : ProjectTitleSvelte ,
279296 props : { pluginMode : project . pluginMode } ,
280297 } )
298+
299+ for ( const cube of Cube . all ) {
300+ cube . setUVMode ( false )
301+ fixCubeRotation ( cube )
302+ }
303+
304+ Canvas . updateAll ( )
281305 } )
282306 } ,
283307
Original file line number Diff line number Diff line change @@ -3,7 +3,7 @@ import { updateAllCubeOutlines } from 'src/mods/cube'
33import { SUPPORTED_MINECRAFT_VERSIONS } from 'src/systems/global'
44import BlueprintSettingsDialogSvelteComponent from '../../components/blueprintSettingsDialog.svelte'
55import { PACKAGE } from '../../constants'
6- import { updateRotationLock } from '../../formats/blueprint'
6+ import { updateRotationConstraints } from '../../formats/blueprint'
77import { defaultValues , type ExportMode } from '../../formats/blueprint/settings'
88import { sanitizeStorageKey } from '../../util/minecraftUtil'
99import { Valuable } from '../../util/stores'
@@ -134,7 +134,7 @@ export function openBlueprintSettingsDialog() {
134134 preventKeybinds : true ,
135135 onConfirm ( ) {
136136 setSettings ( settings )
137- updateRotationLock ( )
137+ updateRotationConstraints ( )
138138 updateAllCubeOutlines ( )
139139 Canvas . updateAll ( )
140140 } ,
Original file line number Diff line number Diff line change @@ -102,7 +102,11 @@ export function isCubeValid(cube: Cube): '1.21.6+' | 'valid' | 'invalid' {
102102 totalRotation === cube . rotation [ 1 ] ||
103103 totalRotation === cube . rotation [ 2 ]
104104
105- if ( isSingleAxisRotation && projectTargetVersionIsAtLeast ( '1.21.6' ) ) return '1.21.6+'
105+ if ( isSingleAxisRotation && projectTargetVersionIsAtLeast ( '1.21.6' ) ) {
106+ // Rotation values still need to be within -45 and 45 degrees
107+ if ( totalRotation <= 45 && totalRotation >= - 45 ) return '1.21.6+'
108+ else return 'invalid'
109+ }
106110
107111 const isRotationInAllowedSteps =
108112 totalRotation === - 45 ||
You canβt perform that action at this time.
0 commit comments