improvements
This commit is contained in:
@@ -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' },
|
||||
|
||||
+11
-1
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user