mojira.dev
MC-311725

The `match_block` loot predicate always requires a block entity

When using predicates, the game now checks if all loot context used by that predicate is provided. If a loot context is missing, the entire data pack would fail, even if the context missing is optional for the predicate.

For example: accroding to minercraft changelog 26.3-snapshot 4, the match_block predicate can optionally take in a block_entity context and check its conponents or nbt. If this context is not provided but the match_block predicate defined these fields then the predicate would return false. However when used in an enchantment, it always requires any match_block predicate to receive a block_entity context, even if it only checks for block and block state.

How To Reproduce:

Create a data pack with the following enchantment definition. Such a data pack can be found in attachments.

{
  "anvil_cost": 1,
  "description": {"translate": ""},
  "effects": {
    "minecraft:hit_block": [
      {
        "requirements": {
          "type": "minecraft:match_block",
          "blocks": "minecraft:tnt"
        },
        "effect": {
          "type": "all_of",
          "effects": [
            {
              "type": "play_sound",
              "sound": "intentionally_empty",
              "pitch": 1,
              "volume": 1
            }
          ]
        }
      }
    ]
  },
  "max_cost": {"base": 1,"per_level_above_first": 1},
  "max_level": 1,
  "min_cost": {"base": 2,"per_level_above_first": 2},
  "slots": ["mainhand"],
  "supported_items": "barrier",
  "weight": 2
}

Now quit and re join the world where the data pack is loaded in. It would fail and suggest open in safe mode.

Check lastest.log and see the following error:

Validation error:  at [0].requirements: Parameters [<parameter minecraft:block_entity>] are not provided in this context missed input: {"minecraft:hit_block":[{"requirements":{"type":"minecraft:match_block","blocks":"minecraft:tnt"},"effect":{"type":"all_of","effects":[{"type":"play_sound","sound":"intentionally_empty","pitch":1,"volume":1}]}}]}

What is Expected

Missing optional loot contexts should not prevent the validation from passing.

Attachments

Comments 1

Thank you for helping us improve Minecraft! We saved your files:

[media]

Dahesor

boq

Confirmed

Platform HC

Important

Data Packs

26.3 Pre-Release 2, 26.3 Pre-Release 3

26.3 Release Candidate 1

Retrieved