From 2101612b72715a5da5449d78162d655045cb4874 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 8 Mar 2026 09:50:50 +0000 Subject: [PATCH 1/2] Initial plan From d403ea28595d387c4d3d459fcd66074b907acbf9 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 8 Mar 2026 10:01:02 +0000 Subject: [PATCH 2/2] fix: skip geometry/material_instances pairing check in block permutations Co-authored-by: DaanV2 <2393905+DaanV2@users.noreply.github.com> --- ide/vscode/src/version.ts | 2 +- .../block/components/diagnose.ts | 2 + .../behavior-pack/block/document.ts | 2 +- .../src/utility/components/components.ts | 2 + .../diagnostics/behavior-pack/block.test.ts | 120 ++++++++++++++++++ 5 files changed, 126 insertions(+), 2 deletions(-) create mode 100644 packages/bedrock-diagnoser/test/lib/diagnostics/behavior-pack/block.test.ts diff --git a/ide/vscode/src/version.ts b/ide/vscode/src/version.ts index d3df4039..c6b9b379 100644 --- a/ide/vscode/src/version.ts +++ b/ide/vscode/src/version.ts @@ -1 +1 @@ -export const Version = "9.0.18"; +export const Version = "9.0.20"; diff --git a/packages/bedrock-diagnoser/src/diagnostics/behavior-pack/block/components/diagnose.ts b/packages/bedrock-diagnoser/src/diagnostics/behavior-pack/block/components/diagnose.ts index 0315cc2f..9985d892 100644 --- a/packages/bedrock-diagnoser/src/diagnostics/behavior-pack/block/components/diagnose.ts +++ b/packages/bedrock-diagnoser/src/diagnostics/behavior-pack/block/components/diagnose.ts @@ -86,6 +86,7 @@ const component_test: Record 'minecraft:geometry': (name, component, context, diagnoser) => { try { if ( + !context.isPermutation && !context.components.includes('minecraft:material_instances') && FormatVersion.isGreaterOrEqualThan(context.source.format_version as FormatVersion, [1, 21, 80]) ) @@ -114,6 +115,7 @@ const component_test: Record 'minecraft:material_instances': (name, component, context, diagnoser) => { try { if ( + !context.isPermutation && !context.components.includes('minecraft:geometry') && FormatVersion.isGreaterOrEqualThan(context.source.format_version as FormatVersion, [1, 21, 80]) ) diff --git a/packages/bedrock-diagnoser/src/diagnostics/behavior-pack/block/document.ts b/packages/bedrock-diagnoser/src/diagnostics/behavior-pack/block/document.ts index 7ed302a0..5ea9df00 100644 --- a/packages/bedrock-diagnoser/src/diagnostics/behavior-pack/block/document.ts +++ b/packages/bedrock-diagnoser/src/diagnostics/behavior-pack/block/document.ts @@ -37,7 +37,7 @@ export function diagnose_block_document(diagnoser: DocumentDiagnosticsBuilder): //check components block['minecraft:block']?.permutations?.forEach((p) => { context.components.push(...getUsedComponents(p)); - behaviorpack_diagnose_block_components(p, context, diagnoser); + behaviorpack_diagnose_block_components(p, { ...context, isPermutation: true }, diagnoser); }); if (block['minecraft:block']['events']) { diff --git a/packages/bedrock-diagnoser/src/utility/components/components.ts b/packages/bedrock-diagnoser/src/utility/components/components.ts index 6a17829b..a2c656be 100644 --- a/packages/bedrock-diagnoser/src/utility/components/components.ts +++ b/packages/bedrock-diagnoser/src/utility/components/components.ts @@ -11,6 +11,8 @@ export interface Context { source: Readonly; /** The components used by the source collected from multiple sources */ components: string[]; + /** Whether the current components being checked belong to a permutation (not the top-level block) */ + isPermutation?: boolean; } /**Checks if components dependencies are present, a component might need others to be present diff --git a/packages/bedrock-diagnoser/test/lib/diagnostics/behavior-pack/block.test.ts b/packages/bedrock-diagnoser/test/lib/diagnostics/behavior-pack/block.test.ts new file mode 100644 index 00000000..c7805552 --- /dev/null +++ b/packages/bedrock-diagnoser/test/lib/diagnostics/behavior-pack/block.test.ts @@ -0,0 +1,120 @@ +import { Internal } from 'bc-minecraft-bedrock-project'; +import { TestDiagnoser } from '../../../diagnoser'; +import { behaviorpack_diagnose_block_components } from '../../../../src/diagnostics/behavior-pack/block/components/diagnose'; +import { Context } from '../../../../src/utility/components'; + +const FORMAT_VERSION_1_21_80 = '1.21.80'; +const FORMAT_VERSION_1_20_0 = '1.20.0'; + +function makeBlock(formatVersion: string): Internal.BehaviorPack.Block { + return { + format_version: formatVersion, + 'minecraft:block': { + description: { identifier: 'test:block' }, + components: {}, + }, + }; +} + +function makeContext( + block: Internal.BehaviorPack.Block, + components: string[], + isPermutation?: boolean, +): Context { + return { source: block, components, isPermutation }; +} + +describe('BehaviorPack', () => { + describe('Block', () => { + describe('minecraft:geometry / minecraft:material_instances pairing', () => { + it('errors when geometry is at top-level without material_instances (>= 1.21.80)', () => { + const diagnoser = TestDiagnoser.create(); + const block = makeBlock(FORMAT_VERSION_1_21_80); + const context = makeContext(block, ['minecraft:geometry']); + + behaviorpack_diagnose_block_components( + { components: { 'minecraft:geometry': 'geometry.example' } }, + context, + diagnoser, + ); + + expect(diagnoser.hasCode('behaviorpack.block.components.material_instances_x_geometry')).toBe(true); + }); + + it('errors when material_instances is at top-level without geometry (>= 1.21.80)', () => { + const diagnoser = TestDiagnoser.create(); + const block = makeBlock(FORMAT_VERSION_1_21_80); + const context = makeContext(block, ['minecraft:material_instances']); + + behaviorpack_diagnose_block_components( + { components: { 'minecraft:material_instances': { '*': { texture: 'test' } } } }, + context, + diagnoser, + ); + + expect(diagnoser.hasCode('behaviorpack.block.components.material_instances_x_geometry')).toBe(true); + }); + + it('does not error when geometry is in a permutation without material_instances (>= 1.21.80)', () => { + const diagnoser = TestDiagnoser.create(); + const block = makeBlock(FORMAT_VERSION_1_21_80); + const context = makeContext(block, ['minecraft:geometry'], true); + + behaviorpack_diagnose_block_components( + { components: { 'minecraft:geometry': 'geometry.example' } }, + context, + diagnoser, + ); + + expect(diagnoser.hasCode('behaviorpack.block.components.material_instances_x_geometry')).toBe(false); + }); + + it('does not error when material_instances is in a permutation without geometry (>= 1.21.80)', () => { + const diagnoser = TestDiagnoser.create(); + const block = makeBlock(FORMAT_VERSION_1_21_80); + const context = makeContext(block, ['minecraft:material_instances'], true); + + behaviorpack_diagnose_block_components( + { components: { 'minecraft:material_instances': { '*': { texture: 'test' } } } }, + context, + diagnoser, + ); + + expect(diagnoser.hasCode('behaviorpack.block.components.material_instances_x_geometry')).toBe(false); + }); + + it('does not error when both geometry and material_instances are present at top-level (>= 1.21.80)', () => { + const diagnoser = TestDiagnoser.create(); + const block = makeBlock(FORMAT_VERSION_1_21_80); + const context = makeContext(block, ['minecraft:geometry', 'minecraft:material_instances']); + + behaviorpack_diagnose_block_components( + { + components: { + 'minecraft:geometry': 'geometry.example', + 'minecraft:material_instances': { '*': { texture: 'test' } }, + }, + }, + context, + diagnoser, + ); + + expect(diagnoser.hasCode('behaviorpack.block.components.material_instances_x_geometry')).toBe(false); + }); + + it('does not error when geometry is used without material_instances in format versions < 1.21.80', () => { + const diagnoser = TestDiagnoser.create(); + const block = makeBlock(FORMAT_VERSION_1_20_0); + const context = makeContext(block, ['minecraft:geometry']); + + behaviorpack_diagnose_block_components( + { components: { 'minecraft:geometry': 'geometry.example' } }, + context, + diagnoser, + ); + + expect(diagnoser.hasCode('behaviorpack.block.components.material_instances_x_geometry')).toBe(false); + }); + }); + }); +});