-
Notifications
You must be signed in to change notification settings - Fork 12
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
Fix durabilityUsed for items with components #123
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Fixes #121 Update `durabilityUsed` getter to support items with components. * Modify `durabilityUsed` getter in `index.js` to check the `components` array for the `damage` component. * Use the `damage` component value for `durabilityUsed` if found. * Fall back to checking the `Damage` field in `nbt` or `metadata` if the `damage` component is not found. * Add test cases in `test/basic.test.js` to verify `durabilityUsed` returns the correct value for items with and without the `damage` component. --- For more details, open the [Copilot Workspace session](https://copilot-workspace.githubnext.com/PrismarineJS/prismarine-item/issues/121?shareId=XXXX-XXXX-XXXX-XXXX).
Can you review it too @extremeheat ? The issue author says it fixes. I think it looks correct |
extremeheat
approved these changes
Jan 11, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There could be a component map so no need to constantly search but otherwise LGTM
…e` component * Add a component map to avoid constantly searching the `components` array * Use the `damage` component value for `durabilityUsed` if found * Fall back to checking the `Damage` field in `nbt` or `metadata` if `damage` component is not found * Add test cases to verify `durabilityUsed` returns correct value for items with and without the `damage` component
* Use `fromNotch` method to create the item * Add `components` array with `damage` component to the item * Verify `durabilityUsed` returns correct value for items with and without `damage` component
oh well it broke it, will fix later |
ah no got it, there is no nbt |
/makerelease |
Merged
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #121
Update
durabilityUsed
getter to support items with components.durabilityUsed
getter inindex.js
to check thecomponents
array for thedamage
component.damage
component value fordurabilityUsed
if found.Damage
field innbt
ormetadata
if thedamage
component is not found.test/basic.test.js
to verifydurabilityUsed
returns the correct value for items with and without thedamage
component.For more details, open the Copilot Workspace session.