improvements

This commit is contained in:
2026-09-28 23:22:53 +02:00
parent 3206b1b3f1
commit 2bae0c3946
4 changed files with 196 additions and 45 deletions
+10 -1
View File
@@ -30,6 +30,7 @@ function harness(capture = false) {
add(undo) { assert.equal(undo, false); Texture.all.push(this); }
}
const context = {
Buffer, Timeline: { animation: null },
Project: { uuid: 'original' }, Group, Cube: { all: [] }, Texture, Outliner: { elements: [] },
Plugin: { register() {} }, requireNativeModule: require,
localStorage: { getItem: (key) => storage.get(key), setItem: (key, value) => storage.set(key, value) },
@@ -234,7 +235,8 @@ test('short clip names are inferred only for unambiguous actors; repeated entiti
test('complete import prepares all stages, actor models, local textures and definition fields without touching the current project', async (t) => {
const f = fixtures(t), h = harness(true), source = f.makePack('source');
const def = { actors: [{ label: 'wolf', entity_types: ['minecraft:wolf', 'minecraft:fox'], actor_tags: ['gender.male'] }],
const def = { actors: [{ label: 'wolf', entity_types: ['minecraft:wolf', 'minecraft:fox'], actor_tags: ['gender.male'],
prop_right: 'minecraft:carrot' }],
animators: ['Creator'], content_tags: ['example'], stages: [{ stage: 1, non_peak: true }, { stage: 2 }] };
const defFile = f.write(path.join(source.root, 'data/test/afw_animdefs/example.json'), def);
f.write(path.join(source.root, 'assets/test/geckolib/animations/afw/example.animation.json'), { animations: {
@@ -243,6 +245,10 @@ test('complete import prepares all stages, actor models, local textures and defi
} });
f.model(source, 'test:source/entity/wolf.m', { afw_texture: 'test:textures/wolf.png' });
f.write(path.join(source.root, 'assets/test/textures/wolf.png'), 'local image');
f.write(path.join(source.root, 'assets/minecraft/items/carrot.json'), { model: { type: 'minecraft:model', model: 'minecraft:item/carrot' } });
f.write(path.join(source.root, 'assets/minecraft/models/item/carrot.json'), {
parent: 'minecraft:builtin/generated', textures: { layer0: 'minecraft:item/carrot' } });
f.write(path.join(source.root, 'assets/minecraft/textures/item/carrot.png'), 'image');
h.context.selectedFile = { path: defFile };
h.context.requireNativeModule = (name) => name === 'fs' ? scopedFilesystem() : path;
await h.automaticallyImportAnimation();
@@ -260,6 +266,7 @@ test('complete import prepares all stages, actor models, local textures and defi
assert.deepEqual(Array.from(plan.imported.stageNames), ['example.p1', 'example.p2']);
assert.ok(plan.imported.fileObj.animations['example.p2'].bones.actor1_body);
assert.equal(plan.definition.actors[0].label, 'wolf');
assert.equal(Object.values(plan.propEntries)[0].item, 'minecraft:carrot');
assert.equal(plan.definition.stages[1].non_peak, undefined);
assert.equal(h.undo.length, 0);
assert.ok(h.storage.get('animationdirector_pack_folders').includes(source.root.replace(/\\/g, '\\\\')));
@@ -380,6 +387,7 @@ test('missing models can be supplied manually, and their locally supplied textur
test('batch import uses a new project, one undo entry, actor prefixes and texture override bindings', () => {
const h = harness();
const plan = { parsed: { animationId: 'example' }, blockEntry: null,
propEntries: { '["example","wolf","right",0]': { animation: 'example', item: 'minecraft:carrot', mode: 'item' } },
definition: { actors: [{ label: 'wolf', entity_types: ['minecraft:wolf'] }], animators: ['Creator'], stages: [{ stage: 1 }] },
imported: { stageNames: ['example.p1'], fileObj: { animations: { 'example.p1': { bones: { actor1_body: { rotation: [1, 2, 3] } } } } } },
rows: [{ label: 'wolf', json: { afw_bone_textures: { body: 'test:textures/wolf.png' } },
@@ -394,6 +402,7 @@ test('batch import uses a new project, one undo entry, actor prefixes and textur
const override = JSON.parse(h.context.Project.multiactor_bone_texture_overrides);
assert.equal(override[h.context.Group.all[0].uuid].texture, 'test:textures/wolf.png');
assert.ok(JSON.parse(h.context.Project.animationdirector_animdef_definitions).example);
assert.equal(JSON.parse(h.context.Project.animationdirector_prop_previews)['["example","wolf","right",0]'].item,'minecraft:carrot');
});
test('unexpected animation-load failures cancel the batch rather than keeping a partial import', () => {