Package com.jtprince.coordinateoffset
Record Class FixedOffset
java.lang.Object
java.lang.Record
com.jtprince.coordinateoffset.FixedOffset
- Record Components:
x- X offset value in blocks. Will be subtracted from the player's real X coordinate.z- Z offset value in blocks. Will be subtracted from the player's real Z coordinate.
- All Implemented Interfaces:
Offset
Amount by which a player's clientside X and Z coordinates will appear shifted compared to their real position in a
world.
Fixed offsets are absolute in any coordinate space. For example, a fixed offset of (800, 800)
will always subtract 800 from the player's coordinates. This may break coordinate-based alignment between
nether portals and make it possible to reverse-engineer offsets through clever use of nether portals.
A fixed offset is fully resolved and may be applied to coordinates directly.
-
Field Summary
Fields inherited from interface com.jtprince.coordinateoffset.Offset
ALIGN_DEFAULT_OVERWORLD, ZERO -
Constructor Summary
ConstructorsConstructorDescriptionFixedOffset(int x, int z) Creates an instance of aFixedOffsetrecord class. -
Method Summary
Modifier and TypeMethodDescription<T> Tapply(T location) Apply this offset to a location.intchunkX()intchunkZ()final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.booleanisZero()Check if both components of this offset are zero, resulting in no coordinate offset.negate()Get a new Offset with the inverse components as this one (x -> -x, z -> -z).toString()Returns a string representation of this record class.<T> Tunapply(T location) Unapply this offset from a location.intx()Returns the value of thexrecord component.intz()Returns the value of thezrecord component.
-
Constructor Details
-
Method Details
-
toString
Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components. -
negate
Description copied from interface:OffsetGet a new Offset with the inverse components as this one (x -> -x, z -> -z). -
isZero
public boolean isZero()Description copied from interface:OffsetCheck if both components of this offset are zero, resulting in no coordinate offset. -
chunkX
public int chunkX() -
chunkZ
public int chunkZ() -
apply
Description copied from interface:OffsetApply this offset to a location.- Specified by:
applyin interfaceOffset- Type Parameters:
T- EitherOffsetLocationor a platform-specific location object.- Parameters:
location- Location to apply the offset to. This may either be aOffsetLocationor a platform-specific location object, such as a Bukkit Location.- Returns:
- A new Location object with the offset applied and all other data (including type) matching the original.
- Throws:
ClassCastException- if the provided object is not of an acceptable type for the running platform.
-
unapply
Description copied from interface:OffsetUnapply this offset from a location.- Specified by:
unapplyin interfaceOffset- Type Parameters:
T- EitherOffsetLocationor a platform-specific location object.- Parameters:
location- Location to unapply the offset from. This may either be aOffsetLocationor a platform-specific location object, such as a Bukkit Location.- Returns:
- A new Location object with the offset unapplied and all other data (including type) matching the original.
- Throws:
ClassCastException- if the provided object is not of an acceptable type for the running platform.
-
hashCode
public final int hashCode()Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with '=='. -
x
public int x()Returns the value of thexrecord component.- Returns:
- the value of the
xrecord component
-
z
public int z()Returns the value of thezrecord component.- Returns:
- the value of the
zrecord component
-