In Minecraft Bedrock edition, “Hasitem” is a target selector that selects players with certain amounts of an item in their inventory. This is incredibly useful for many things, like item shops and adventure maps. “Hasitem” allows detection of specific ranges of items as well. For example, you could select all players with fewer than 5 diamonds.
Unfortunately, this is not in Java edition. While there are workarounds, there is no intuitive way to detect players with a range of items. The “NBT” selector can detect if the player has a specific item with specific data, but it cannot select a range of items. It can only detect if the player has a specific amount of an item in one stack. This does not work in most cases. For example, if the player had two stacks of 8 diamonds, and they were supposed to get selected for having more than 9, they would not get selected because they did not have a single stack with 9 items in it. Even in Bedrock, “Hasitem” does not allow selection based upon data components that an item has, limiting customizability.
My suggestion is to add “Hasitem” to Java as a target selector, and allow it to detect items with specific components within both versions. The format would follow a simple structure. Within square brackets, the first term is the string of the item being detected, with components given at the end the same way they are with the “/give” command. The second is a range of potential values. The two of these terms would be separated by a comma.
Please sign in to leave a comment.
3 Comments