From 3206b1b3f1b2f93e583121178bda76df6c215eed Mon Sep 17 00:00:00 2001 From: L1Z0 <2grif484d@mozmail.com> Date: Mon, 28 Sep 2026 23:01:07 +0200 Subject: [PATCH] improvements --- AnimationDirector.js | 9 +++++++-- test/item-props.test.js | 12 +++++++++++- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/AnimationDirector.js b/AnimationDirector.js index 5b9a673..18efb31 100644 --- a/AnimationDirector.js +++ b/AnimationDirector.js @@ -3951,6 +3951,12 @@ return results; } + function propItemOptions(items, search) { + const query = String(search || '').trim().toLowerCase(); + return { '': 'Select a matching item...', ...Object.fromEntries(items + .filter((id) => id.toLowerCase().includes(query)).map((id) => [id, id])) }; + } + function propJson(source, path) { const content = source.read(path); return content ? JSON.parse(content.toString('utf8').replace(/^\uFEFF/, '')) : null; @@ -4388,8 +4394,7 @@ item_search: { label: 'Search available items', type: 'text', value: '', placeholder: 'Search by item ID', condition: (result) => result.mode === 'item' && !!state.items.length }, item_choice: { label: 'Choose item', type: 'select', value: '', - options: () => ({ '': 'Select a matching item...', ...Object.fromEntries(state.items - .filter((id) => id.includes(state.search.toLowerCase())).slice(0, 100).map((id) => [id, id])) }), + options: () => propItemOptions(state.items, state.search), condition: (result) => result.mode === 'item' && !!state.items.length }, _manual: { type: 'info', text: '### Manual texture fallback\nFor items with a special renderer, choose a PNG to preview an extruded sprite. This does not change the in-game model.', condition: (result) => result.mode === 'item' }, diff --git a/test/item-props.test.js b/test/item-props.test.js index e1976cb..1d75b3a 100644 --- a/test/item-props.test.js +++ b/test/item-props.test.js @@ -11,7 +11,7 @@ function harness() { ' Plugin.register(PLUGIN_ID, {', `globalThis.props = { indexPropZip, propResourcePath, openPropSource, loadPropAsset, resolvePropModel, propTextureId, propDisplayTransform, manualPropModel, writePropDefinition, effectivePropEntry, effectivePropItem, propEntryKey, extrudePropPixels, discoverPropSources, - buildPropMesh, refreshPropPreviews, clearPropMeshes, propFaceVertices, propDefaultUv, + buildPropMesh, refreshPropPreviews, clearPropMeshes, propFaceVertices, propDefaultUv, propItemOptions, applyPropPreview, createPropDialog, showPropDialog, readPropPreviews }; Plugin.register(PLUGIN_ID, {`); const context = { Buffer, requireNativeModule: require, console, Plugin: { register() {} }, @@ -161,6 +161,16 @@ test('asset discovery reuses Asset Browser cache without requiring the plugin', assert.equal(sources[0].label,'Asset Browser: 1.21.11'); }); +test('item picker includes entries after the first hundred and filters the full source list', () => { + const h = harness(); + const items = Array.from({ length: 1505 }, (_, index) => `minecraft:item_${String(index).padStart(4, '0')}`); + const all = h.propItemOptions(items, ''); + assert.equal(Object.keys(all).length, 1506); + assert.equal(all['minecraft:item_1504'], 'minecraft:item_1504'); + const searched = h.propItemOptions(items, ' ITEM_1504 '); + assert.deepEqual(Object.keys(searched), ['', 'minecraft:item_1504']); +}); + test('Item Props uses native dialog form fields and Apply/Cancel actions', () => { const h = harness(); let configuration;