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

Add methods, fix .equals #46

Merged
merged 3 commits into from
Dec 31, 2023
Merged

Add methods, fix .equals #46

merged 3 commits into from
Dec 31, 2023

Conversation

szdytom
Copy link
Contributor

@szdytom szdytom commented Oct 30, 2023

Added methods:

  • .xz(), .xy(), .yz() for accessing interested parts only
  • .xzy() for a vector with y and z swapped.
  • .at(index) a shortcut for .toArray()[index]
  • isZero() checks for zero vector

Changed methods:

  • .equals(): Usually we can't use === for comparing two floats, which leads to 0.1 + 0.2 !== 0.3.
  • .set(): Now we can pass null to those component we don't want to change. not a good design.

Signed-off-by: szdytom <szdytom@qq.com>
index.d.ts Outdated Show resolved Hide resolved
/**
* Returns an array component x, z
*/
xz(): [number, number];
Copy link
Member

Choose a reason for hiding this comment

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

Is that useful?

[p.x, p.z] seems clearer to use

Copy link
Contributor Author

@szdytom szdytom Oct 30, 2023

Choose a reason for hiding this comment

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

I think it can be useful, please consider a longer name like bot.entity.position.

Signed-off-by: szdytom <szdytom@qq.com>
@szdytom szdytom changed the title Add methods, fix .equals, improve .set Add methods, fix .equals Oct 30, 2023
index.js Outdated Show resolved Hide resolved
Signed-off-by: szdytom <szdytom@qq.com>
@szdytom szdytom requested a review from rom1504 December 17, 2023 23:47
@rom1504 rom1504 merged commit c6b94c4 into PrismarineJS:master Dec 31, 2023
3 checks passed
@rom1504
Copy link
Member

rom1504 commented Dec 31, 2023

/makerelease

@rom1504bot rom1504bot mentioned this pull request Dec 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Closed
Development

Successfully merging this pull request may close these issues.

2 participants