Skip to content

Commit

Permalink
Fix toBlockLocation when provided negative block location
Browse files Browse the repository at this point in the history
  • Loading branch information
stirante committed May 23, 2024
1 parent 074d457 commit a17b62c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@bedrock-oss/bedrock-boost",
"version": "0.0.17",
"version": "0.0.18",
"description": "A utility package with helper functions for developing add-ons with Script API in Minecraft Bedrock Edition",
"keywords": [
"minecraft",
Expand Down
7 changes: 4 additions & 3 deletions src/Vec3.ts
Original file line number Diff line number Diff line change
Expand Up @@ -646,10 +646,11 @@ export default class Vec3 implements Vector3 {
* Returns a new vector with the X, Y, and Z components rounded to the nearest block location.
*/
toBlockLocation(): Vec3 {
// At this point I'm not sure if it wouldn't be better to use Math.floor instead
return Vec3.from(
(this.x << 0) - (this.x < 0 ? 1 : 0),
(this.y << 0) - (this.y < 0 ? 1 : 0),
(this.z << 0) - (this.z < 0 ? 1 : 0)
(this.x << 0) - (this.x < 0 && this.x !== (this.x << 0) ? 1 : 0),
(this.y << 0) - (this.y < 0 && this.y !== (this.y << 0) ? 1 : 0),
(this.z << 0) - (this.z < 0 && this.z !== (this.z << 0) ? 1 : 0)
);
}
/**
Expand Down

0 comments on commit a17b62c

Please sign in to comment.