Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Any Item Literal #7593

Draft
wants to merge 1 commit into
base: dev/feature
Choose a base branch
from
Draft

Conversation

sovdeeth
Copy link
Member

@sovdeeth sovdeeth commented Feb 7, 2025

Description

Adds a literal for itemtypes representing any item, all items, and any item in a tag.
The literal uses simplify() on ExprTag to allow tag expressions with literal strings to be interpreted as literals. This allows the use in events, like:

on right click with any item tagged as tag "pig_food":
    broadcast "test"

This literal also allows things like if player's tool is any item named "test" with lore "hello world", which makes item comparisons easier.

In the process of implementing this, I discovered that the parser doesn't attempt to parse Literals that are registered as expressions when only the PARSE_LITERALS flag is active. I've included a basic fix in this draft but will be improving it (so as to not duplicate code)

I also have concerns about evaluating the tag contents at parse time, since the tag contents may change after that. This may require storing the key to the tag instead and evaluating it when the itemtype itself is evaluated. This isn't ideal but may be necessary.

TODO:

  • Fix the any item return value so it doesn't show as simply air?
    • Allow give any item to me to work properly.
  • Fix the any item itemtype so it compares against any amount of item if not specified.
  • Clean up parser literals fix

Target Minecraft Versions: any
Requirements: none
Related Issues: none

@sovdeeth sovdeeth added the feature Pull request adding a new feature. label Feb 7, 2025
@sovdeeth sovdeeth changed the base branch from master to dev/feature February 7, 2025 17:15
@sovdeeth
Copy link
Member Author

sovdeeth commented Feb 8, 2025

Further testing and experiments have unveiled issues with this implementation. I think to get the proper behavior, I'll have to completely rework the ItemData class to allow more generic types, rather than being locked to a specific ItemStack.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature Pull request adding a new feature.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant