Class ScreenVector.Immutable
java.lang.Object
com.pixelmonmod.api.client.screen.util.ScreenVector
com.pixelmonmod.api.client.screen.util.ScreenVector.Immutable
- All Implemented Interfaces:
net.minecraft.core.Position
- Enclosing class:
- ScreenVector
Immutable version of
ScreenVector
.
Any method which would mutate the vector now instead returns a new immutable vector containing the new values,
leaving the old vector as-is.-
Nested Class Summary
Nested classes/interfaces inherited from class com.pixelmonmod.api.client.screen.util.ScreenVector
ScreenVector.Immutable
-
Constructor Summary
ConstructorDescriptionImmutable
(double x, double y) Constructs a new immutable vector with the given values, and the z value set to 0.Immutable
(double x, double y, double z) Constructs a new immutable vector with the given values.Immutable
(net.minecraft.core.Position position) Constructs a new immutable vector with values copied from an existingPosition
. -
Method Summary
Modifier and TypeMethodDescriptionadd
(double x, double y, double z) Adds to the values of this vector.copy()
Copies the values of this vector into a new immutable vector.mul
(double mx, double my, double mz) Multiplies the values of this vector by the given values.Normalize this vector between 0 and 1 based on the givenBounds
.set
(double x, double y, double z) Sets the values of this vector to the given values.toString()
static ScreenVector.Immutable
zero()
Constructs a new zeroed immutable vector.Methods inherited from class com.pixelmonmod.api.client.screen.util.ScreenVector
add, add, axes, axis, chebyshev, chebyshev, delta, equals, euclidean, euclidean, hashCode, immutable, map, map, max, maximize, min, minimize, mul, mul, mul, mutable, set, square, take, take, take, taxicab, taxicab, translate, x, xF, xI, y, yF, yI, z, zF, zI
-
Constructor Details
-
Immutable
public Immutable(double x, double y) Constructs a new immutable vector with the given values, and the z value set to 0.- Parameters:
x
- X value of the new vector.y
- Y value of the new vector.
-
Immutable
public Immutable(net.minecraft.core.Position position) Constructs a new immutable vector with values copied from an existingPosition
.- Parameters:
position
- ThePosition
to copy values from for the new vector.
-
Immutable
public Immutable(double x, double y, double z) Constructs a new immutable vector with the given values.- Parameters:
x
- X value of the new vector.y
- Y value of the new vector.z
- Z value of the new vector.
-
-
Method Details
-
zero
Constructs a new zeroed immutable vector.- Returns:
- A new zeroed immutable vector.
-
copy
Copies the values of this vector into a new immutable vector.- Overrides:
copy
in classScreenVector
- Returns:
- A copy of this vector.
-
add
Adds to the values of this vector. This will not mutate this vector, and will return a new vector containing the updated values.- Overrides:
add
in classScreenVector
- Parameters:
x
- The amount to add to the x value.y
- The amount to add to the y value.z
- The amount to add to the z value.- Returns:
- The new vector.
-
mul
Multiplies the values of this vector by the given values. This will not mutate this vector, and will return a new vector containing the updated values.- Overrides:
mul
in classScreenVector
- Parameters:
mx
- The x value multiplier.my
- The y value multiplier.mz
- the z value multiplier.- Returns:
- The new vector.
-
set
Sets the values of this vector to the given values. This will not mutate this vector, and will return a new vector containing the updated values. As such, this is effectively a new vector constructor.- Overrides:
set
in classScreenVector
- Parameters:
x
- The new x value.y
- The new y value.z
- The new z value.- Returns:
- The new vector.
-
normalize
Normalize this vector between 0 and 1 based on the givenBounds
. This will not mutate this vector, and will return a new vector containing the updated values.- Overrides:
normalize
in classScreenVector
- Parameters:
bounds
- The bounds containing the min/max values to normalize on.- Returns:
- The new vector.
-
toString
- Overrides:
toString
in classScreenVector
-