-
Notifications
You must be signed in to change notification settings - Fork 11
Fix false-positive geometry/material_instances pairing errors in block permutations #269
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1 @@ | ||
| export const Version = "9.0.18"; | ||
| export const Version = "9.0.20"; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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<Internal.BehaviorPack.Block> { | ||
| 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, | ||
| ); | ||
|
Comment on lines
+31
to
+39
|
||
|
|
||
| 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); | ||
| }); | ||
| }); | ||
| }); | ||
| }); | ||
Uh oh!
There was an error while loading. Please reload this page.