diff --git a/src/components/keyframePanels/variantKeyframePanel.svelte b/src/components/keyframePanels/variantKeyframePanel.svelte index 193a3cdc..ab3e6e00 100644 --- a/src/components/keyframePanels/variantKeyframePanel.svelte +++ b/src/components/keyframePanels/variantKeyframePanel.svelte @@ -7,6 +7,13 @@ const keyframeValue = new Valuable(getKeyframeVariant(selectedKeyframe) as string) let selectContainer: HTMLDivElement + if (!Variant.all.find(v => v.uuid === keyframeValue.get())) { + console.warn('Keyframe variant not found. Resetting to default.') + const uuid = Variant.getDefault().uuid + setKeyframeVariant(selectedKeyframe, uuid) + keyframeValue.set(uuid) + } + keyframeValue.subscribe(value => { setKeyframeVariant(selectedKeyframe, value) }) diff --git a/src/systems/datapackCompiler/1.21.5/animation.mcb b/src/systems/datapackCompiler/1.21.5/animation.mcb index a58f981d..237b9e88 100644 --- a/src/systems/datapackCompiler/1.21.5/animation.mcb +++ b/src/systems/datapackCompiler/1.21.5/animation.mcb @@ -548,7 +548,7 @@ dir <%export_namespace%> { type=<%locator.config.entity_type%>, \ tag=<%TAGS.NEW()%>, \ tag=<%TAGS.PROJECT_LOCATOR_NAMED(export_namespace, locator.storage_name)%>, \ - distance=..<%locator.max_distance + 1%> \ + distance=..<%Math.ceil(locator.max_distance)%> \ ] \ run block as_locator/<%locator.path_name%> { # run block ../as_locator/<%locator.path_name%> { @@ -582,9 +582,10 @@ dir <%export_namespace%> { type=minecraft:item_display, \ tag=<%TAGS.NEW()%>, \ tag=<%TAGS.PROJECT_CAMERA_NAMED(export_namespace, camera.storage_name)%>, \ - distance=..<%camera.max_distance + 1%> \ + distance=..<%Math.ceil(camera.max_distance)%> \ ] \ - run block ../as_camera/<%camera.path_name%> { + run block as_camera/<%camera.path_name%> { + # run block ../as_camera/<%camera.path_name%> { tag @s remove <%TAGS.NEW()%> function *global/internal/gu/convert_uuid_array_to_string tp @s \ diff --git a/src/variants.ts b/src/variants.ts index 4352a971..97d3f28c 100644 --- a/src/variants.ts +++ b/src/variants.ts @@ -1,4 +1,5 @@ import { IBlueprintVariantJSON } from './blueprintFormat' +import { getKeyframeVariant, setKeyframeVariant } from './mods/customKeyframesMod' import { events } from './util/events' import { sanitizePathName } from './util/minecraftUtil' @@ -116,6 +117,17 @@ export class Variant { // Cannot delete default variant if (this.isDefault) return + for (const animation of Blockbench.Animation.all) { + for (const animator of Object.values(animation.animators)) { + for (const keyframe of animator.keyframes) { + const uuid = getKeyframeVariant(keyframe) + if (uuid != undefined && this.uuid === uuid) { + setKeyframeVariant(keyframe, Variant.getDefault().uuid) + } + } + } + } + const index = Variant.all.indexOf(this) if (index > -1) { Variant.all.splice(index, 1) diff --git a/test-packs/1.21.5/blueprints/armor_stand.ajblueprint b/test-packs/1.21.5/blueprints/armor_stand.ajblueprint index b2fce9be..aa74a774 100644 --- a/test-packs/1.21.5/blueprints/armor_stand.ajblueprint +++ b/test-packs/1.21.5/blueprints/armor_stand.ajblueprint @@ -1,7 +1,7 @@ { "meta": { "format": "animated_java_blueprint", - "format_version": "1.7.0", + "format_version": "1.7.2", "uuid": "167b27cd-b559-3f13-a97c-0841fe21f1d1", "save_location": "D:\\github-repos\\animated-java\\animated-java\\test-packs\\1.21.5\\blueprints\\armor_stand.ajblueprint", "last_used_export_namespace": "armor_stand" @@ -1183,7 +1183,7 @@ "locked": false, "visibility": true, "autouv": 0, - "selected": false, + "selected": true, "children": [ "55829f3d-26dc-8f49-39b8-5ba2c0159a24", "9d16df18-0574-58bb-e0f9-f799946257c9", @@ -1604,7 +1604,470 @@ } ] }, - "animations": [], + "animations": [ + { + "uuid": "baae8403-f2ab-6a7a-acb5-97d80bf8e31a", + "name": "wizard", + "loop": "loop", + "override": false, + "length": 2, + "snapping": 20, + "selected": false, + "saved": false, + "path": "", + "anim_time_update": "", + "blend_weight": "", + "start_delay": "", + "loop_delay": "0", + "excluded_nodes": [], + "animators": { + "b5b52d2c-097c-08df-6457-372fbae12445": { + "name": "left_arm", + "type": "bone", + "keyframes": [ + { + "channel": "rotation", + "data_points": [ + { + "x": "-90\n+ math.sin(q.life_time * 360) * 30", + "y": "-22.5\n+ math.cos(q.life_time * 360) * 30", + "z": "0" + } + ], + "uuid": "df1fbae1-9b41-d0f4-5f6c-473441c294ff", + "time": 0, + "color": -1, + "interpolation": "linear", + "easing": "linear", + "easingArgs": [] + } + ] + }, + "215d1b02-0e64-a794-1b88-a9c5a6d7541c": { + "name": "right_arm", + "type": "bone", + "keyframes": [ + { + "channel": "rotation", + "data_points": [ + { + "x": "-90\n+ math.sin(q.life_time * 360) * 30", + "y": "22.5\n- math.cos(q.life_time * 360) * 30", + "z": "0" + } + ], + "uuid": "53b169b5-69f4-45a9-288a-de94ad2b3b90", + "time": 0, + "color": -1, + "interpolation": "linear", + "easing": "linear", + "easingArgs": [] + } + ] + }, + "7de415a2-9fdd-e4b2-3455-c3bed72eb896": { + "name": "left_hand", + "type": "locator", + "keyframes": [ + { + "channel": "commands", + "data_points": [ + { + "x": "0", + "y": "0", + "z": "0", + "commands": "particle minecraft:flame ^ ^ ^", + "execute_condition": "", + "repeat": true, + "repeat_frequency": 5 + } + ], + "uuid": "923a41b4-3218-552c-06cb-582ead7ce8e8", + "time": 0, + "color": -1, + "interpolation": "linear", + "easing": "linear", + "easingArgs": [] + } + ] + }, + "7747736f-85e2-338f-207e-53f8d3d2fa39": { + "name": "right_hand", + "type": "locator", + "keyframes": [ + { + "channel": "commands", + "data_points": [ + { + "x": "0", + "y": "0", + "z": "0", + "commands": "particle minecraft:flame ^ ^ ^", + "execute_condition": "", + "repeat": true, + "repeat_frequency": 1 + } + ], + "uuid": "fe357d53-5802-876b-c5d0-9eb8a19f573b", + "time": 0, + "color": -1, + "interpolation": "linear", + "easing": "linear", + "easingArgs": [] + } + ] + }, + "3b35d1a9-befe-066e-60df-e1f3a5ec5a78": { + "name": "pig", + "type": "bone", + "keyframes": [ + { + "channel": "position", + "data_points": [ + { + "x": "16 - math.cos(q.life_time * 180) * 16", + "y": "16 + math.sin(q.life_time * 360) * 8", + "z": "-32" + } + ], + "uuid": "08083fab-35c8-d8f0-44b0-000f720cf533", + "time": 0, + "color": -1, + "interpolation": "linear", + "easing": "linear", + "easingArgs": [] + } + ] + }, + "effects": { + "name": "Effects", + "type": "effect", + "keyframes": [ + { + "channel": "commands", + "data_points": [ + { + "commands": "say hi", + "execute_condition": "", + "repeat": false, + "repeat_frequency": 1 + } + ], + "uuid": "e8054bec-122c-6f34-6781-a4a58d46a5a6", + "time": 0, + "color": -1, + "interpolation": "linear", + "easing": "linear", + "easingArgs": [] + }, + { + "channel": "commands", + "data_points": [ + { + "commands": "say bye", + "execute_condition": "", + "repeat": false, + "repeat_frequency": 1 + } + ], + "uuid": "523673ac-dff1-1729-8064-4d0258e2de2a", + "time": 2, + "color": -1, + "interpolation": "linear", + "easing": "linear", + "easingArgs": [] + } + ] + } + } + }, + { + "uuid": "bd510bbf-d10c-d05a-44cb-7f116627ad9f", + "name": "walk", + "loop": "loop", + "override": false, + "length": 1, + "snapping": 20, + "selected": true, + "saved": false, + "path": "", + "anim_time_update": "", + "blend_weight": "", + "start_delay": "", + "loop_delay": "0", + "excluded_nodes": [ + { + "name": "baseplate_pivot_a", + "value": "4f000ffc-11d6-3a4b-7c8d-6b5ba483228c" + } + ], + "animators": { + "5e08acae-d6ca-0dfd-9360-8cdb13c7a824": { + "name": "armor_stand_root", + "type": "bone", + "keyframes": [ + { + "channel": "position", + "data_points": [ + { + "x": "0", + "y": "-1", + "z": "0" + } + ], + "uuid": "fe4ec2e7-5246-ebf1-b38a-521a5f3d9907", + "time": 0, + "color": -1, + "interpolation": "linear", + "easing": "linear", + "easingArgs": [] + } + ] + }, + "6c53311f-ffc8-e567-ff1b-65840698e9ba": { + "name": "body", + "type": "bone", + "keyframes": [ + { + "channel": "rotation", + "data_points": [ + { + "x": "0", + "y": "1 - math.sin(q.life_time * v.walk_speed + 90) * 12.25\n", + "z": "0" + } + ], + "uuid": "6bbb9d3d-e9c7-4ee6-79fc-ca26899b722c", + "time": 0, + "color": -1, + "interpolation": "linear", + "easing": "linear", + "easingArgs": [] + }, + { + "channel": "position", + "data_points": [ + { + "x": "0", + "y": "1 + math.sin(q.life_time * v.walk_speed * 2) * 0.5", + "z": "0" + } + ], + "uuid": "15fe5d50-bd56-ade8-1de5-c1e234e7d019", + "time": 0, + "color": -1, + "interpolation": "linear", + "easing": "linear", + "easingArgs": [] + } + ] + }, + "808e3c26-7285-af3f-a079-d8b899176dd3": { + "name": "head", + "type": "bone", + "keyframes": [ + { + "channel": "rotation", + "data_points": [ + { + "x": "0", + "y": "1 + math.sin(q.life_time * v.walk_speed + 90) * 12.25", + "z": "0" + } + ], + "uuid": "f62415e9-43b1-de7f-8c6a-ab713dafa65e", + "time": 0, + "color": -1, + "interpolation": "linear", + "easing": "linear", + "easingArgs": [] + } + ] + }, + "b5b52d2c-097c-08df-6457-372fbae12445": { + "name": "left_arm", + "type": "bone", + "keyframes": [ + { + "channel": "rotation", + "data_points": [ + { + "x": "math.sin(q.life_time * v.walk_speed) * 8", + "y": "0", + "z": "22.5" + } + ], + "uuid": "20a2dfee-e0e7-87aa-13cb-27861c08b166", + "time": 0, + "color": -1, + "interpolation": "linear", + "easing": "linear", + "easingArgs": [] + }, + { + "channel": "position", + "data_points": [ + { + "x": "2", + "y": "0", + "z": "-math.sin(q.life_time * v.walk_speed) * 2" + } + ], + "uuid": "2e24c9ea-de91-bd22-2d7c-bb95813a0658", + "time": 0, + "color": -1, + "interpolation": "linear", + "easing": "linear", + "easingArgs": [] + } + ] + }, + "215d1b02-0e64-a794-1b88-a9c5a6d7541c": { + "name": "right_arm", + "type": "bone", + "keyframes": [ + { + "channel": "rotation", + "data_points": [ + { + "x": "math.sin(q.life_time * v.walk_speed) * 22.5", + "y": "math.sin(q.life_time * v.walk_speed) * 12.25", + "z": "math.cos(q.life_time * v.walk_speed * 2) * 6 + 6" + } + ], + "uuid": "8eaf4e97-7b14-ac66-b575-4cc50963c99d", + "time": 0, + "color": -1, + "interpolation": "linear", + "easing": "linear", + "easingArgs": [] + } + ] + }, + "55b812fe-7e4c-b2a5-da5b-3a8c82f9fc69": { + "name": "left_leg", + "type": "bone", + "keyframes": [ + { + "channel": "rotation", + "data_points": [ + { + "x": "-math.sin(q.life_time * v.walk_speed) * 22.5", + "y": "0", + "z": "0" + } + ], + "uuid": "32f56ab1-fa8f-fa32-0418-45fddbb261a1", + "time": 0, + "color": -1, + "interpolation": "linear", + "easing": "linear", + "easingArgs": [] + }, + { + "channel": "position", + "data_points": [ + { + "x": "0", + "y": "math.clamp(math.cos(q.life_time * v.walk_speed) * 2, 0, 10)", + "z": "-math.sin(q.life_time * v.walk_speed) * 1\n" + } + ], + "uuid": "95a4ed7e-6530-bf4a-398f-76fe64d52033", + "time": 0, + "color": -1, + "interpolation": "linear", + "easing": "linear", + "easingArgs": [] + } + ] + }, + "60d50d30-a018-429d-ba78-c5fb5804dd8a": { + "name": "right_leg", + "type": "bone", + "keyframes": [ + { + "channel": "rotation", + "data_points": [ + { + "x": "math.sin(q.life_time * v.walk_speed) * 22.5", + "y": "0", + "z": "0" + } + ], + "uuid": "151bdae6-6e4a-718c-3317-f5c8bf83d366", + "time": 0, + "color": -1, + "interpolation": "linear", + "easing": "linear", + "easingArgs": [] + }, + { + "channel": "position", + "data_points": [ + { + "x": "0", + "y": "math.clamp(-math.cos(q.life_time * v.walk_speed) * 2, 0, 10)", + "z": "math.sin(q.life_time * v.walk_speed) * 1\n" + } + ], + "uuid": "4de6bc86-4ddf-3253-9e00-3d6eb70e0e50", + "time": 0, + "color": -1, + "interpolation": "linear", + "easing": "linear", + "easingArgs": [] + } + ] + }, + "49e67c2a-3d1d-792d-9c75-72ecbc0f92e0": { + "name": "body_waist_pivot", + "type": "bone", + "keyframes": [ + { + "channel": "rotation", + "data_points": [ + { + "x": "0", + "y": "0", + "z": "1 - math.sin(q.life_time * v.walk_speed - 90) * 3" + } + ], + "uuid": "d3d81801-bcd6-8e3c-8c8c-1e62874345de", + "time": 0, + "color": -1, + "interpolation": "linear", + "easing": "linear", + "easingArgs": [] + } + ] + }, + "effects": { + "name": "Effects", + "type": "effect", + "keyframes": [ + { + "channel": "variant", + "data_points": [ + { + "variant": "5417306e-2c69-3f36-1e3c-edd904034a36", + "execute_condition": "", + "repeat": false, + "repeat_frequency": 1 + } + ], + "uuid": "1baa095b-e941-62df-a215-698b50c93524", + "time": 0, + "color": -1, + "interpolation": "linear", + "easing": "linear", + "easingArgs": [] + } + ] + } + } + } + ], "animation_controllers": [], "animation_variable_placeholders": "v.walk_speed = 360 * 1;\nv.run_speed = 360 * 1.5;\nv.stickbug_speed = 360 * 1.25;\n" } \ No newline at end of file