Skip to content

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

Open
Gnottero wants to merge 8 commits into
gnembon:masterfrom
Gnottero:components
Open

Enhance Value#of Method for Improved Item Data Retrieval (Components compatibility)#1996
Gnottero wants to merge 8 commits into
gnembon:masterfrom
Gnottero:components

Conversation

@Gnottero
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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......

Comment thread src/main/java/carpet/script/api/Inventories.java
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.

4 participants