Skip to content

Conversation

@sweetniamhy
Copy link
Contributor

@sweetniamhy sweetniamhy commented Sep 23, 2025

Description

  • Added AABBUtils for working with AABB, taking inspiration from Vector3Utils.
  • Added test suite for AABBUtils with mocked BlockVolume.
  • Added Vector3Utils.ceil with tests to match the Vector3Utils.floor (used by AABBUtils).
  • Fixed math libraries api-extractor.json and just.config.cts since they pointed to incorrect paths.
  • Updated the package-lock.json using npm update @minecraft/server from v2.0.0 to v2.4.0 to get access to the AABB interface.

Reviewing

  • getBlockVolume uses an epsilon so AABBs min/max are rounded within a tolerance (see the 'AABB BlockVolume operations') tests.
  • Typescript doesn't treat +0 and -0 the same, I could have used Vector3Utils.equal and Vector3Utils.toString to construct the 'expect' tests but I chose to use -0 so that I can use 'toEqual' on the expected vectors.
  • The BlockVolume mock floors it's from/to coordinates since internally it uses BlockPos that converts floating point numbers to integer using floor.
BlockPos::BlockPos(float x, float y, float z)
	: x(static_cast<int>(floorf(x)))
	, y(static_cast<int>(floorf(y)))
	, z(static_cast<int>(floorf(z))) {
}

@sweetniamhy sweetniamhy changed the title AABBUtils AABBUtils and Vector3Utils.ceil Sep 24, 2025
@sweetniamhy sweetniamhy force-pushed the niamh.cuileann/aabbutils branch from ae95cbe to ddf9033 Compare September 24, 2025 18:14
@sweetniamhy sweetniamhy force-pushed the niamh.cuileann/aabbutils branch from ddf9033 to a26c746 Compare September 25, 2025 19:22
@sweetniamhy sweetniamhy marked this pull request as ready for review December 15, 2025 18:46
Copy link
Contributor

@AlexDenfordSkyboxLabs AlexDenfordSkyboxLabs left a comment

Choose a reason for hiding this comment

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

Awesome great work! Test coverage looks good, implementations make sense to me, happy to see thorough docs/comments etc. Thanks!

Copy link
Collaborator

@rlandav rlandav left a comment

Choose a reason for hiding this comment

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

Version fix is the only true blocking change. The rest are mock suggestions, and elevating some repeated logic you had to a genneral purpose Vector3 helper.

Also, do you think there is value in an a builder style variant of AABB utils akin to the Vector3Builder, or is the functional pattern the only one you see as necessary?

@sweetniamhy
Copy link
Contributor Author

Version fix is the only true blocking change. The rest are mock suggestions, and elevating some repeated logic you had to a genneral purpose Vector3 helper.

Also, do you think there is value in an a builder style variant of AABB utils akin to the Vector3Builder, or is the functional pattern the only one you see as necessary?

The Vector3Builder is likely to be more widely used - though AABBBuilder could be worth visiting in a second PR. Some ideas for how that would be useful maybe AABBBuilder.createFromPoints(..).dilate(..).translate(..) to make a box that is scaled and translated, seems useful though so worth adding.

…t-scripting-libraries into niamh.cuileann/aabbutils
…eil core helpers and builder. Updated to use min/max in AABBUtils.
@sweetniamhy sweetniamhy requested a review from rlandav January 6, 2026 17:37
@sweetniamhy
Copy link
Contributor Author

@rlandav Updated to add min/max to Vector3Utils, also added ceil/min/max to Vector3Builder since I missed that previously with tests for all of those additions. Changed everything internally to use Vector3Utils.min/max as well since there were a few spots that did that manually. Updated the beachball changelog.

@sweetniamhy sweetniamhy merged commit 47e7ab2 into main Jan 6, 2026
3 checks passed
@sweetniamhy sweetniamhy deleted the niamh.cuileann/aabbutils branch January 6, 2026 18:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants