Uploaded image for project: 'Minecraft: Java Edition'
  1. Minecraft: Java Edition
  2. MC-184263

item_used_on_block trigger has no way to check the original block

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Invalid
    • None
    • 20w20b, 20w21a
    • None
    • Confirmed
    • (Unassigned)

      The bug

      Unlike what the trigger name suggest, you can't detect what the original block was for the item_used_on_block trigger. The location condition is evaluated after the block change was made. This makes it impossible to detect some actions.

      How to reproduce

      1. Create the following advancement.
        {
          "criteria": {
            "place": {
              "trigger": "minecraft:item_used_on_block",
              "conditions": {
                "location": {
                  "block": {
                    "block": "minecraft:dirt"
                  }
                }
              }
            }
          },
          "rewards": {
            "function": "test:tilled_dirt"
          }
        }
      2. Create the following function
        advancement revoke @s only test:tilled_dirt
        say used item on dirt
      3. Use a hoe on dirt
        Notice that the advancement is not granted
      4. This advancement will be granted correctly when placing block on dirt, because the dirt itself does not change
      5. This can also be verified by checking the state of button presses.

      Fix

      An easy way to fix this is by adding a "block" predicate to this trigger. Triggers like bee_nest_destroyed can already check the original block.

            Unassigned Unassigned
            Misoloo [Helper] Misode
            Votes:
            14 Vote for this issue
            Watchers:
            10 Start watching this issue

              Created:
              Updated:
              Resolved:
              CHK: