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-185838 The command was executed correctly but output is a failure Resolved MCPE-189499 hasitem refuses to acknowledge shulkers with added data via /give Resolved MCPE-152220 data values aren't supported fully by hasitem Resolved MCPE-177231 data selector for hasitem target selector doesn't work Resolved MCPE-173736 The selector argument hasitem cannot detect acacia planks etc. Resolved

Attachments

Comments 24

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

14 more comments

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.

Per the reproduction steps this appears to be fixed (since at least 26.0).

Too bad since damage values are evil 😕

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