Skip to content

Commit 63c71bd

Browse files
authored
🔀 Merge: #461 🔖 v1.8.0-beta.5
2 parents b28a461 + 384e8d7 commit 63c71bd

File tree

13 files changed

+84
-64
lines changed

13 files changed

+84
-64
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"title": "Animated Java",
55
"icon": "icon.svg",
66
"description": "Effortlessly craft complex animations for Minecraft: Java Edition",
7-
"version": "1.8.0-beta.4",
7+
"version": "1.8.0-beta.5",
88
"min_blockbench_version": "4.12.0",
99
"max_blockbench_version": "4.12.6",
1010
"variant": "desktop",

src/formats/blueprint/index.ts

Lines changed: 42 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,20 @@ 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) return
153+
// Use the rotation with the largest absolute value
154+
const rotation = Math.abs(maxRotation) >= Math.abs(minRotation) ? maxRotation : minRotation
155+
const axis = cube.rotation.indexOf(rotation)
156+
157+
const previousSelected = Project!.selected_elements
158+
Project!.selected_elements = [cube]
159+
rotateOnAxis(() => rotation, axis, true)
160+
Project!.selected_elements = previousSelected
161+
}
162+
149163
//region > Convert
150164
export function convertToBlueprint() {
151165
// Convert the current project to a Blueprint
@@ -156,13 +170,19 @@ export function convertToBlueprint() {
156170
group.createUniqueName(Group.all.filter(g => g !== group))
157171
group.sanitizeName()
158172
}
173+
159174
for (const animation of Blockbench.Animation.all) {
160175
animation.createUniqueName(Blockbench.Animation.all.filter(a => a !== animation))
161176
animation.name = sanitizeStorageKey(animation.name)
162177
}
178+
163179
for (const cube of Cube.all) {
164180
cube.setUVMode(false)
181+
182+
fixCubeRotation(cube)
165183
}
184+
185+
Canvas.updateAll()
166186
}
167187

168188
export function getDefaultProjectSettings() {
@@ -278,6 +298,13 @@ export const BLUEPRINT_FORMAT = registerModelFormat(
278298
component: ProjectTitleSvelte,
279299
props: { pluginMode: project.pluginMode },
280300
})
301+
302+
for (const cube of Cube.all) {
303+
cube.setUVMode(false)
304+
fixCubeRotation(cube)
305+
}
306+
307+
Canvas.updateAll()
281308
})
282309
},
283310

@@ -353,14 +380,8 @@ export function projectTargetVersionIsAtLeast(version: string): boolean {
353380
return !compareVersions(version, Project!.animated_java.target_minecraft_version)
354381
}
355382

356-
export function shouldEnableRotationLock(): boolean {
357-
if (!activeProjectIsBlueprintFormat()) return false
358-
359-
if (projectTargetVersionIsAtLeast('1.21.6')) {
360-
return false
361-
}
362-
363-
return !(
383+
export function hasNonElementSelection(): boolean {
384+
return (
364385
!!Group.first_selected ||
365386
!!AnimatedJava.TextDisplay.selected.length ||
366387
!!AnimatedJava.VanillaItemDisplay.selected.length ||
@@ -376,20 +397,20 @@ export function shouldEnableRotationLock(): boolean {
376397
)
377398
}
378399

379-
export function updateRotationLock() {
380-
if (!activeProjectIsBlueprintFormat()) return
381-
const format = BLUEPRINT_FORMAT.get()!
382-
// If any of these node types are selected, we disable rotation lock.
383-
format.rotation_limit = shouldEnableRotationLock()
384-
format.rotation_snap = format.rotation_limit
385-
}
386-
387-
export function disableRotationLock() {
400+
export function updateRotationConstraints() {
388401
if (!activeProjectIsBlueprintFormat()) return
389402
const format = BLUEPRINT_FORMAT.get()!
403+
if (!format) {
404+
console.error('Animated Java Blueprint format is not registered!')
405+
return
406+
}
390407

391-
format.rotation_limit = false
392-
format.rotation_snap = false
408+
// Rotation is always limited when selecting an element
409+
format.rotation_limit = !hasNonElementSelection()
410+
if (!projectTargetVersionIsAtLeast('1.21.6') /* < 1.21.6 */) {
411+
// But only snaps to 22.5 degree increments on versions before 1.21.6
412+
format.rotation_snap = format.rotation_limit
413+
}
393414
}
394415

395416
EVENTS.SELECT_PROJECT.subscribe(project => {
@@ -402,13 +423,12 @@ EVENTS.UNSELECT_PROJECT.subscribe(project => {
402423
EVENTS.UNSELECT_AJ_PROJECT.publish(project)
403424
}
404425
})
405-
EVENTS.UPDATE_SELECTION.subscribe(updateRotationLock)
426+
EVENTS.UPDATE_SELECTION.subscribe(updateRotationConstraints)
406427
EVENTS.SELECT_AJ_PROJECT.subscribe(() => {
407428
requestAnimationFrame(() => {
408-
updateRotationLock()
429+
updateRotationConstraints()
409430
})
410431
})
411432
EVENTS.UNSELECT_AJ_PROJECT.subscribe(project => {
412433
if (project.visualBoundingBox) scene.remove(project.visualBoundingBox)
413-
disableRotationLock()
414434
})

src/interface/dialog/blueprintSettings.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { updateAllCubeOutlines } from 'src/mods/cube'
33
import { SUPPORTED_MINECRAFT_VERSIONS } from 'src/systems/global'
44
import BlueprintSettingsDialogSvelteComponent from '../../components/blueprintSettingsDialog.svelte'
55
import { PACKAGE } from '../../constants'
6-
import { updateRotationLock } from '../../formats/blueprint'
6+
import { updateRotationConstraints } from '../../formats/blueprint'
77
import { defaultValues, type ExportMode } from '../../formats/blueprint/settings'
88
import { sanitizeStorageKey } from '../../util/minecraftUtil'
99
import { 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
},

src/mods/eventHooks.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,3 +46,16 @@ registerPropertyOverrideMod({
4646
}
4747
},
4848
})
49+
50+
registerPropertyOverrideMod({
51+
id: `animated-java:event-hook/pre-select-project-event`,
52+
object: ModelProject.prototype,
53+
key: 'select',
54+
55+
get: original => {
56+
return function (this: ModelProject) {
57+
EVENTS.PRE_SELECT_PROJECT.publish(this)
58+
return original.call(this)
59+
}
60+
},
61+
})

src/mods/modelFormatSelectMod.ts

Lines changed: 0 additions & 21 deletions
This file was deleted.

src/pluginPackage/changelog.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -404,5 +404,21 @@
404404
]
405405
}
406406
]
407+
},
408+
"1.8.0-beta.5": {
409+
"title": "v1.8.0-beta.5",
410+
"author": "Titus Evans (SnaveSutit)",
411+
"date": "2025-10-19",
412+
"categories": [
413+
{
414+
"title": "Fixes",
415+
"list": [
416+
"Fixed cube rotations in 1.21.6+ allowing rotation values outside the -45..45 degree range",
417+
"Fixed rotation limits not being enforced when converting to a Blueprint.",
418+
"Fixed rotation limit not being enforced when rotating cubes.",
419+
"Fixed export crash due to invalid tag reference."
420+
]
421+
}
422+
]
407423
}
408424
}

src/systems/datapackCompiler/1.20.4/global.mcb

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,9 +117,6 @@ dir global {
117117

118118
# Removes locators and cameras owned by the rig, even if they're not included in the currently loaded export.
119119
function outdated_rig {
120-
# Assert that the function is being executed as a root entity.
121-
debug assert executed_as_root_entity <%TAGS.GLOBAL_ROOT()%>
122-
123120
execute on passengers if entity @s[tag=<%TAGS.GLOBAL_DATA()%>] run block as_data {
124121
data remove storage <%temp_storage%> args
125122
data remove storage <%temp_storage%> uuids
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
template debug {
2-
with assert:literal executed_as_root_entity:literal root_tag:literal {
2+
with assert:literal executed_as_root_entity:literal root_tag:js {
33
IF (debug_mode) {
44
execute unless entity @s[type=minecraft:item_display,tag=<%root_tag%>] run return run \
5-
tellraw @a <%TELLRAW.FUNCTION_NOT_EXECUTED_AS_ROOT_ERROR(context.functions.at(-1))%>
5+
tellraw @a <%TELLRAW.FUNCTION_NOT_EXECUTED_AS_ROOT_ERROR(context.functions.at(-1), root_tag)%>
66
}
77
}
88
}

src/systems/datapackCompiler/1.21.2/global.mcb

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,9 +117,6 @@ dir global {
117117

118118
# Removes locators and cameras owned by the rig, even if they're not included in the currently loaded export.
119119
function outdated_rig {
120-
# Assert that the function is being executed as a root entity.
121-
debug assert executed_as_root_entity <%TAGS.GLOBAL_ROOT()%>
122-
123120
execute on passengers if entity @s[tag=<%TAGS.GLOBAL_DATA()%>] run block as_data {
124121
data remove storage <%temp_storage%> args
125122
data remove storage <%temp_storage%> uuids

src/systems/datapackCompiler/1.21.5/global.mcb

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,9 +117,6 @@ dir global {
117117

118118
# Removes locators and cameras owned by the rig, even if they're not included in the currently loaded export.
119119
function outdated_rig {
120-
# Assert that the function is being executed as a root entity.
121-
debug assert executed_as_root_entity <%TAGS.GLOBAL_ROOT()%>
122-
123120
execute on passengers if entity @s[tag=<%TAGS.GLOBAL_DATA()%>] run block as_data {
124121
data remove storage <%temp_storage%> args
125122
data remove storage <%temp_storage%> uuids

0 commit comments

Comments
 (0)