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

Enhance Value#of Method for Improved Item Data Retrieval (Components compatibility) #1996

Open
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

Gnottero
Copy link
Contributor

@Gnottero Gnottero commented Sep 12, 2024

Overview:

This pull request introduces a new function, item_components, which accepts an item tuple as an argument and returns a list of all components within the tuple, including default components that are typically hidden.

Reason:

The primary purpose of this function is to provide access to default components, enabling users to leverage them for internal calculations, such as determining custom block breaking speeds based on the tool component.

};
}));

MapValue mapValue = MapValue.wrap(Map.of(StringValue.of("components"), MapValue.wrap(lst), StringValue.of("id"), StringValue.of(stack.getItem().toString()), StringValue.of("count"), NumericValue.of(stack.getCount())));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if you pack all of those k-v pairs to a NBT tag again, why you left the switch there?
you can let Number&Boolean use the default case too.

and you no longer need to use a NBTSerializableValue to warp the res tag.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've changed that to your implementation, removing the part that took the item from the main hand in case of no values passed to the function. I also removed unedited files. It should be fine now, I guess

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

then you please edit your Overview, Reason and Request for Review......

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants