mojira.dev
MCPE-151920

The command does not evaluate the selector argument "hasitem" -> data.

The command does not evaluate the selector argument "hasitem" -> data.

Steps to Reproduce:

  1. Obtain blue concrete (data = 11)

  2. Type /testfor @s [hasitem={item=concrete, data=5}] in the chat

Observed Results:
The command successfully finds the player even though the player has concrete with a data value of 11.

Expected Results:
The command should not find the player.

See video below.

Linked issues

MCPE-152220 data values aren't supported fully by hasitem Resolved MCPE-152221 block item aren't fully supported by hasitem Resolved MCPE-154200 hasitem argument does not detect created maps Resolved MCPE-155406 hasitem target selector argument does not detect specific data values on items with durability. Resolved MCPE-156599 Target selector *hasitem* cannot detect durability item data Resolved

Attachments

Comments 23

Can confirm; affects 1.18.30.21 Preview

This also affect Minecraft 1.18.30 official

Also confirm 1.18.30 release. Also possible duplicate: MCPE-152220

Update: The main three issues still apply in 1.19.2 and 1.19.20.20 exactly as they were before. The crash doesn't occur on the release version but does still occur in the preview.

 

From my testing in 1.18.31, these are the issues with how data values interact with hasitem:

  • For blocks with multiple data values, hasitem will detect the blocks while completely ignoring the data field in the command, and will detect them regardless of the block's data value. (What this specific bug report currently describes.)

  • For most other items, omitting the data field from hasitem (or setting it to a negative value) will act as if it was set to 0, only detecting the 0 data value of the item instead of detecting all instances of that item type regardless of data value.

  • For items with durability, hasitem will always act as if the data value of the damaged items is 0, and so will only detect them if the data field in the command is set to 0. This also applies to custom items with durability added with behavior packs.

All of this also applies in Preview 1.19.0.31, but the game will now crash if attempting to test for a negative data value on item IDs with only one data value or items with durability.

Edit: Just discovered in Preview 1.19.20.20 that the game also seems to also crash if testing for a negative data value on potions, splash potions, lingering potions, and arrows. I don't know if this used to happen.

The hasitem can not detect lingering potions and splash potions

13 more comments

still not fully implemented? Lets get on this one... I've tested every potion(drinkable, splash and lingering) as well as every suspicious_stew, ...they work (except for filters in the API noted below).

all of the following FLOWERS resolve to "poppy" (data 0)?

to recreate: copy one of the following 'replaceitem' commands and paste in chat, and then place any 1 tall flower in the players (@s) inventory slot 0. no matter what the flower is, any command listed below will erase it.

// poppy (correct)
"/replaceitem entity @s[hasitem=[{item=red_flower,data=0,quantity=1,location=slot.inventory,slot=0}]] slot.inventory 0 destroy air 1",
//blue orchid <--poppy
"/replaceitem entity @s[hasitem=[{item=red_flower,data=1,quantity=1,location=slot.inventory,slot=0}]] slot.inventory 0 destroy air 1",
// allium <-- poppy
"/replaceitem entity @s[hasitem=[{item=red_flower,data=2,quantity=1,location=slot.inventory,slot=0}]] slot.inventory 0 destroy air 1",
// azure_bluet aka houstonia <-- poppy
"/replaceitem entity @s[hasitem=[{item=red_flower,data=3,quantity=1,location=slot.inventory,slot=0}]] slot.inventory 0 destroy air 1",
// red tulip <-- poppy
"/replaceitem entity @s[hasitem=[{item=red_flower,data=4,quantity=1,location=slot.inventory,slot=0}]] slot.inventory 0 destroy air 1",
// orange tulip <-- poppy
"/replaceitem entity @s[hasitem=[{item=red_flower,data=5,quantity=1,location=slot.inventory,slot=0}]] slot.inventory 0 destroy air 1",
// white tulip <-- poppy
"/replaceitem entity @s[hasitem=[{item=red_flower,data=6,quantity=1,location=slot.inventory,slot=0}]] slot.inventory 0 destroy air 1",
// pink tulip <-- poppy
"/replaceitem entity @s[hasitem=[{item=red_flower,data=7,quantity=1,location=slot.inventory,slot=0}]] slot.inventory 0 destroy air 1",
// oxeye daisy aka oxeye <--poppy
"/replaceitem entity @s[hasitem=[{item=red_flower,data=8,quantity=1,location=slot.inventory,slot=0}]] slot.inventory 0 destroy air 1",
// cornflower <-- poppy
"/replaceitem entity @s[hasitem=[{item=red_flower,data=9,quantity=1,location=slot.inventory,slot=0}]] slot.inventory 0 destroy air 1",
// lily of the valley <-- poppy
"/replaceitem entity @s[hasitem=[{item=red_flower,data=10,quantity=1,location=slot.inventory,slot=0}]] slot.inventory 0 destroy air 1"
// poppy (correct I guess)
"/replaceitem entity @s[hasitem=[{item=red_flower,data=11,quantity=1,location=slot.inventory,slot=0}]] slot.inventory 0 destroy air 1",
"/replaceitem entity @s[hasitem=[{item=red_flower,data=12,quantity=1,location=slot.inventory,slot=0}]] slot.inventory 0 destroy air 1",
"/replaceitem entity @s[hasitem=[{item=red_flower,data=13,quantity=1,location=slot.inventory,slot=0}]] slot.inventory 0 destroy air 1",
"/replaceitem entity @s[hasitem=[{item=red_flower,data=14,quantity=1,location=slot.inventory,slot=0}]] slot.inventory 0 destroy air 1",
"/replaceitem entity @s[hasitem=[{item=red_flower,data=15,quantity=1,location=slot.inventory,slot=0}]] slot.inventory 0 destroy air 1"

inconsistencies: recipes - "red_flower" works in an ingredient array using "data"

{
  "format_version": "1.12",
  "minecraft:recipe_shapeless": {
    "description": {
    "identifier": "minecraft:blue_dye_from_cornflower"
    },

    
    "tags": [ "crafting_table" ],
    "group": "blue_dye",
    "ingredients": [
      {
        "item": "minecraft:red_flower",
        "data": 9
      }
    ],
    "result": {
      "item": "minecraft:dye",
      "data": 18
    }
  }
}

inconsistencies: "red_flower:<int> works in loot table array using "item" (wandering_trader_trades.json)

// start snippet
            {
              "max_uses": 12,
              "wants": [
                {
                  "item": "minecraft:emerald",
                  "quantity": 1
                }
              ],
              "gives": [
                {
                  "item": "minecraft:red_flower:0"
                }
              ]
            },
            {
              "max_uses": 8,
              "wants": [
                {
                  "item": "minecraft:emerald",
                  "quantity": 1
                }
              ],
              "gives": [
                {
                  "item": "minecraft:red_flower:1"
                }
              ]
            },
            {
              "max_uses": 12,
              "wants": [
                {
                  "item": "minecraft:emerald",
                  "quantity": 1
                }
              ],
              "gives": [
                {
                  "item": "minecraft:red_flower:2"
                }
              ]
            },
            {
              "max_uses": 12,
              "wants": [
                {
                  "item": "minecraft:emerald",
                  "quantity": 1
                }
              ],
              "gives": [
                {
                  "item": "minecraft:red_flower:3"
                }
              ]
            },
            {
              "max_uses": 12,
              "wants": [
                {
                  "item": "minecraft:emerald",
                  "quantity": 1
                }
              ],
              "gives": [
                {
                  "item": "minecraft:red_flower:4"
                }
              ]
            },
            {
              "max_uses": 12,
              "wants": [
                {
                  "item": "minecraft:emerald",
                  "quantity": 1
                }
              ],
              "gives": [
                {
                  "item": "minecraft:red_flower:5"
                }
              ]
            },
            {
              "max_uses": 12,
              "wants": [
                {
                  "item": "minecraft:emerald",
                  "quantity": 1
                }
              ],
              "gives": [
                {
                  "item": "minecraft:red_flower:6"
                }
              ]
            },
            {
              "max_uses": 12,
              "wants": [
                {
                  "item": "minecraft:emerald",
                  "quantity": 1
                }
              ],
              "gives": [
                {
                  "item": "minecraft:red_flower:7"
                }
              ]
            },
            {
              "max_uses": 12,
              "wants": [
                {
                  "item": "minecraft:emerald",
                  "quantity": 1
                }
              ],
              "gives": [
                {
                  "item": "minecraft:red_flower:8"
                }
              ]
            },
            {
              "max_uses": 12,
              "wants": [
                {
                  "item": "minecraft:emerald",
                  "quantity": 1
                }
              ],
              "gives": [
                {
                  "item": "minecraft:red_flower:9"
                }
              ]
            },
            {
              "max_uses": 7,
              "wants": [
                {
                  "item": "minecraft:emerald",
                  "quantity": 1
                }
              ],
              "gives": [
                {
                  "item": "minecraft:red_flower:10"
                }
              ]
            },

inconsistancies:

there is currently no way to use either a command (shown above) or a filter (shown below) in add-on entity to identify alt states of items, or at least it isn't in any documentation publicly available.

UPDATE 6/1/24: there is a filters only solution I found, based on that all minecraft namespace items do not need the 'minecraft:' namespace

// start snippet
"filters":{
	"any_of":[
		// WORKS!
		{"test": "has_equipment","domain": "inventory","value": "red_flower:1"},
                 // FAILS
                {"test": "has_equipment","domain": "inventory","value": "minecraft:red_flower:1"},
		// may work after flattening
		{"test": "has_equipment","domain": "inventory","value": "minecraft:blue_orchid"},
	]
},
"add": {
	"component_groups": [
		"phantom:fx_saturation_cg"
	]
}

Bump - this really should be fixed by now. As outlined in my previous comment, it's seriously impacting community creations.

Data values virtually don't work at all in the latest version of bedrock(1.21.1)

 

Try running this

/give @s iron_nugget 1 55

 

If you change the 55 to a different number, it will stack with the first one. Same if you get on from the creative menu, container, etc. 

 

Data values are useless now

Many bugs of hasitem are linked as duplicates, but I think most of them have different causes. Issues should be separated.

ConMaster2112

(Unassigned)

770283

Confirmed

Multiple

Windows 11

1.19.80.23 Preview, 1.19.30.22 Preview, 1.19.20.20 Preview, 1.19.10.22 Preview, 1.19.10.21 Preview, ..., 1.20.1 Hotfix, 1.20.12 Hotfix, 1.20.41 Hotfix, 1.21.20, 1.21.51 Hotfix

Retrieved