Skip to content

Fix false-positive geometry/material_instances pairing errors in block permutations#269

Merged
DaanV2 merged 2 commits into
mainfrom
copilot/fix-minecraft-geometry-requirements
Mar 8, 2026
Merged

Fix false-positive geometry/material_instances pairing errors in block permutations#269
DaanV2 merged 2 commits into
mainfrom
copilot/fix-minecraft-geometry-requirements

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 8, 2026

The minecraft:geometryminecraft:material_instances co-requirement (format version ≥ 1.21.80) was being enforced per-permutation, but it only applies at the top-level components block. A permutation may legitimately override just one of these components.

Changes

  • Context<T> interface (utility/components/components.ts): Added optional isPermutation?: boolean field.
  • diagnose_block_document (block/document.ts): Passes { ...context, isPermutation: true } when diagnosing permutation components, leaving top-level checks unaffected.
  • minecraft:geometry / minecraft:material_instances validators (block/components/diagnose.ts): Gate the pairing check on !context.isPermutation so it only fires for top-level components.

Example — previously produced a false error

{
  "permutations": [
    {
      "condition": "!q.block_state('ns:hanging')",
      "components": {
        "minecraft:geometry": { "identifier": "geometry.ns.block" }
      }
    },
    {
      "condition": "q.block_state('ns:lit')",
      "components": {
        "minecraft:material_instances": { "*": { "texture": "ns_block_on" } }
      }
    }
  ]
}

Previously this would error on the permutation containing only minecraft:geometry. Both components are still required together at the top level.

Original prompt

This section details on the original issue you should resolve

<issue_title>"minecraft:geometry" requires "minecraft:material_instances" in format versions >= 1.21.80' when having minecraft:geometry or minecraft:material_instances overrides in a permutation without overriding both.</issue_title>
<issue_description>Describe the bug
minecraft:geometry and minecraft:material_instances are required to be together, but only at the top level. It is acceptable to have a single one of those components in a permutation condition, as long as both are defined in the end.

Expected behavior
No error would be produced in this specific scenario.

Desktop:

  • OS: Windows 11
  • Browser: N/A (VSCode)
  • Version: 8.0.46
    </issue_description>

<agent_instructions>Here is the contents of the file shared:

{
	"format_version": "1.21.120",
	"minecraft:block": {
		"description": {
			"identifier": "ic_rt:redstone_lantern",
			"menu_category": {
				"category": "items"
			},
			"states": {
				"ic_rt:hanging": [
					false,
					true
				],
				"ic_rt:lit": [
					true,
					false
				]
			}
		},
		"components": {
			"ic_rt:redstone_lantern": {},
			"minecraft:connection_rule": {
				"accepts_connections_from": "none"
			},
			"minecraft:destructible_by_explosion": {
				"explosion_resistance": 3.5
			},
			"minecraft:destructible_by_mining": {
				"seconds_to_destroy": 3.5
			},
			"minecraft:light_dampening": 0,
			"minecraft:liquid_detection": {
				"detection_rules": [
					{
						"can_contain_liquid": true,
						"on_liquid_touches": "blocking"
					}
				]
			},
			"minecraft:map_color": "#A7A7A7",
			"minecraft:precipitation_interactions": {
				"precipitation_behavior": "none"
			},
			"minecraft:placement_filter": {
				"conditions": [
					{
						"allowed_faces": [
							"down",
							"up"
						],
						"block_filter": [
							{
								"tags": "!q.any_tag('ic_rt:redstone_lanterns')"
							}
						]
					}
				]
			},
			"minecraft:redstone_conductivity": {
				"allows_wire_to_step_down": false,
				"redstone_conductor": false
			},
			"minecraft:support": {
				"shape": "stair"
			},
			"minecraft:tick": {
				"interval_range": [
					1,
					1
				],
				"looping": true
			},
			"tag:ic_rt:redstone_lanterns": {},
			"tag:minecraft:is_pickaxe_item_destructible": {}
		},
		"permutations": [
			{
				"condition": "!q.block_state('ic_rt:hanging')",
				"components": {
					"minecraft:collision_box": {
						"origin": [
							-3,
							0,
							-3
						],
						"size": [
							6,
							8,
							6
						]
					},
					"minecraft:geometry": {
						"culling": "ic_rt:redstone_lantern",
						"identifier": "geometry.ic_rt.redstone_lantern"
					},
					"minecraft:selection_box": {
						"origin": [
							-3,
							0,
							-3
						],
						"size": [
							6,
							8,
							6
						]
					}
				}
			},
			{
				"condition": "!q.block_state('ic_rt:lit')",
				"components": {
					"minecraft:destruction_particles": {
						"particle_count": 50,
						"texture": "ic_rt_redstone_lantern_off"
					},
					"minecraft:light_emission": 0,
					"minecraft:material_instances": {
						"*": {
							"ambient_occlusion": false,
							"face_dimming": false,
							"render_method": "alpha_test_single_sided",
							"texture": "ic_rt_redstone_lantern_off"
						}
					}
				}
			},
			{
				"condition": "!q.block_state('ic_rt:hanging') && !q.block_state('ic_rt:lit')",
				"components": {
					"minecraft:redstone_producer": {
						"connected_faces": [
							"east",
							"north",
							"south",
							"up",
							"west"
						],
						"power": 0,
						"strongly_powered_face": "up"
					}
				}
			},
			{
				"condition": "!q.block_state('ic_rt:hanging') && q.block_state('ic_rt:lit')",
				"components": {
					"minecraft:redstone_producer": {
						"connected_faces": [
							"east",
							"north",
							"south",
							"up",
							"west"
						],
						"power": 15,
						"strongly_powered_face": "up"
					}
				}
			},
			{
				"condition": "q.block_state('ic_rt:hanging')",
				"components": {
					"minecraft:collision_box": {
						"origin": [
							-3,
							2,
							-3
						],
						"size": [
							6,
							8,
							6
						]
					},
					"minecraft:geometry": {
						"identifier": "geometry.ic_rt.hanging_redstone_lantern"
					},
					"minecraft:selection_box": {
						"origin": [
							-3,
							2,
							-3
						],
						"size": [
							6,
							8,
							6
						]
					}
				}
			},
			{
				"condition": "q.block_state('ic_rt:lit')",
				"components": {
					"minecraft:destruction_particles": {
						"particle_count": 50,
						"texture": "ic_rt_redstone_lantern_on"
					},
					"minecraft:light_emission": 7,
					"minecraft:material_instances": {
						"*": {
							"ambient_occlusion": false,
							"face_dimming": false,
							"render_method": "alpha_test_single_sided",
							"texture": "ic_rt_redstone_lantern_on"
						}
					}
				}
			},
			{
				"co...

</details>



<!-- START COPILOT CODING AGENT SUFFIX -->

- Fixes Blockception/minecraft-bedrock-language-server#51

<!-- START COPILOT CODING AGENT TIPS -->
---

✨ Let Copilot coding agent [set things up for you](https://github.com/Blockception/minecraft-bedrock-language-server/issues/new?title=✨+Set+up+Copilot+instructions&body=Configure%20instructions%20for%20this%20repository%20as%20documented%20in%20%5BBest%20practices%20for%20Copilot%20coding%20agent%20in%20your%20repository%5D%28https://gh.io/copilot-coding-agent-tips%29%2E%0A%0A%3COnboard%20this%20repo%3E&assignees=copilot) — coding agent works faster and does higher quality work when set up for your repo.

…ions

Co-authored-by: DaanV2 <2393905+DaanV2@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix geometry and material instances requirements for blocks Fix false-positive geometry/material_instances pairing errors in block permutations Mar 8, 2026
Copilot stopped work on behalf of DaanV2 due to an error March 8, 2026 10:24
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes a false-positive diagnostic error where the minecraft:geometryminecraft:material_instances co-requirement (format version ≥ 1.21.80) was incorrectly enforced within block permutations. The check should only apply at the top-level components block since permutations may legitimately override just one of these components.

Changes:

  • Added an isPermutation flag to the Context<T> interface and gated the geometry/material_instances pairing check on !context.isPermutation to suppress false-positive errors in permutations.
  • Passed { ...context, isPermutation: true } when diagnosing permutation components in diagnose_block_document.
  • Added comprehensive tests for the pairing check across different scenarios (top-level, permutation, format versions).

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
packages/bedrock-diagnoser/src/utility/components/components.ts Added optional isPermutation boolean to the Context<T> interface
packages/bedrock-diagnoser/src/diagnostics/behavior-pack/block/document.ts Passes isPermutation: true in context when diagnosing permutation components
packages/bedrock-diagnoser/src/diagnostics/behavior-pack/block/components/diagnose.ts Gates geometry/material_instances pairing checks on !context.isPermutation
packages/bedrock-diagnoser/test/lib/diagnostics/behavior-pack/block.test.ts New test file covering pairing check scenarios
ide/vscode/src/version.ts Version bump from 9.0.18 to 9.0.20

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +31 to +39
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,
);
Copy link

Copilot AI Mar 8, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TestDiagnoser.create() returns a TestDiagnoser which implements ManagedDiagnosticsBuilder but not DocumentDiagnosticsBuilder. The function behaviorpack_diagnose_block_components expects a DocumentDiagnosticsBuilder (which requires a document property). While this works at runtime because document is never accessed in this code path, it's a type mismatch that ts-jest may flag as a compilation error. Consider using TestDiagnoser.createDocument(undefined, doc) to create a TestDocumentDiagnoser (as done in block-properties.test.ts), or cast the diagnoser with as any.

Copilot uses AI. Check for mistakes.
Comment thread packages/bedrock-diagnoser/src/utility/components/components.ts
@DaanV2 DaanV2 merged commit 63c3122 into main Mar 8, 2026
8 of 9 checks passed
@DaanV2 DaanV2 deleted the copilot/fix-minecraft-geometry-requirements branch March 19, 2026 08:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants