mojira.dev
MCPE-135292

get_equipped_item_name doesn't distinguish between namespaces

The bug

The molang query.get_equipped_item_name conflates items in separate namespaces that happen to have the same name. The entire point of namespaces is to allow different items to share a name but still be distinguishable, but this query makes that impossible.

How to reproduce

1. Download the attached world

2. Select the vanilla apple
3. Deselect it
4. Select the custom apple (which looks like a heart of the sea)

Observed results
Both cause "UNKNOWN APPLE" to be printed to chat

Expected results
The vanilla apple should cause "VANILLA APPLE" to be printed; the custom apple should cause "CUSTOM APPLE" to be printed. Here is the animation controller file:

{
   "format_version": "1.10.0",
   "animation_controllers": {
      "controller.animation.apple": {
         "states": {
            "default": {
               "transitions": [
                  {
                     "vanilla_apple": "query.get_equipped_item_name=='minecraft:apple'"
                  },
                  {
                     "custom_apple": "query.get_equipped_item_name=='custom:apple'"
                  },
                  {
                     "unknown_apple": "query.get_equipped_item_name=='apple'"
                  }
               ]
            },
            "vanilla_apple": {
               "on_entry": ["/say VANILLA APPLE"],
               "transitions": [
                  {
                     "default": "query.get_equipped_item_name!='minecraft:apple'"
                  }
               ]
            },
            "custom_apple": {
               "on_entry": ["/say CUSTOM APPLE"],
               "transitions": [
                  {
                     "default": "query.get_equipped_item_name!='custom:apple'"
                  }
               ]
            },
            "unknown_apple": {
               "on_entry": ["/say UNKNOWN APPLE"],
               "transitions": [
                  {
                     "default": "query.get_equipped_item_name!='apple'"
                  }
               ]
            }
         }
      }
   }
}

Attachments

Comments 1

query.get_equipped_item_name is deprived. Use query.is_item_name_any instead. The new animation controller should look like this:

{
   "format_version": "1.10.0",
   "animation_controllers": {
      "controller.animation.apple": {
         "states": {
            "default": {
               "transitions": [
                  {
                     "vanilla_apple": "query.is_item_name_any('slot.weapon.mainhand','minecraft:apple')"
                  },
                  {
                     "custom_apple": "query.is_item_name_any('slot.weapon.mainhand','custom:apple')"
                  }
               ]
            },
            "vanilla_apple": {
               "on_entry": ["/say VANILLA APPLE"],
               "transitions": [
                  {
                     "default": "!query.is_item_name_any('slot.weapon.mainhand','minecraft:apple')"
                  }
               ]
            },
            "custom_apple": {
               "on_entry": ["/say CUSTOM APPLE"],
               "transitions": [
                  {
                     "default": "!query.is_item_name_any('slot.weapon.mainhand','custom:apple')"
                  }
               ]
            }
         }
      }
   }
}

tryashtar

(Unassigned)

578006

Confirmed

Windows

1.19.10.20 Preview, 1.17.20.22 Beta, 1.17.10, 1.18.31

Retrieved