Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix durabilityUsed for items with components (#123)
* 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
- Loading branch information