Coordinates
Overview
All coordinates classes in Minestom are immutables (like a lot of others), Point
being the common interface, and the implementations Pos
and Vec
.
Vec
is a containing for the x, y & z coordinates, adding a few vector methods. Pos
contains the 3 coordinates + yaw/pitch for the view. Point
should be used when the type does not matter.
Immutability performance
Some may express concern about the performance penalty of using immutable classes for math. Here is our reasoning:
Immutability give us the guarantee that coordinate objects can be reused, reducing allocation
Scalar replacement may happen in some specific situation (builder mode)
Primitive objects will ultimately arrive, removing the concern altogether and improving performance compared to the mutable equivalent
API
Initialization
All coordinates can be created using their respective constructors
Vec
Pos
Very similar to Vec
.
Block coordinates
Last updated