-
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
Doesn't seem to get the item.durabilityUsed correctly since 1.20.5 #121
Comments
Yes, we don't yet support item components. You can read the component data yourself in meantime under the components array |
rom1504
added a commit
that referenced
this issue
Jan 11, 2025
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).
@rom1504 yes it does! Thank you |
rom1504
added a commit
that referenced
this issue
Jan 11, 2025
* Fix durabilityUsed for items with components 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). * Update `durabilityUsed` getter to check `components` array for `damage` 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 * Update test case for `durabilityUsed` with 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 * Check components is defined * Fix test
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
To recreate:
If you print the inventory it will return:
And item.durabilityUsed returns 0
The text was updated successfully, but these errors were encountered: