Package journeymap.api.v2.common.util
Class BlockPos
java.lang.Object
journeymap.api.v2.common.util.BlockPos
Immutable integer block-coordinate value type.
1.7.10 has no net.minecraft.util.math.BlockPos class (that type was introduced in a
later Minecraft version). This class replaces it so the JourneyMap API surface - and downstream
addon source - stays the same shape across Minecraft versions.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic longasLong(int x, int y, int z) Packs a block coordinate into a singlelong, matching the format used bynet.minecraft.util.math.BlockPos#toLong()on the Minecraft versions that have it: x in the upper 26 bits, y in the middle 12 bits, z in the lower 26 bits.booleanstatic BlockPosfromLong(long packed) Unpacks a value produced byasLong(int, int, int).intgetX()intgetY()intgetZ()inthashCode()longtoLong()Packs this position viaasLong(int, int, int).toString()
-
Constructor Details
-
BlockPos
public BlockPos(int x, int y, int z) Constructor.- Parameters:
x- block x coordinatey- block y coordinatez- block z coordinate
-
BlockPos
public BlockPos(double x, double y, double z) Constructor. Each component is floored to the containing block coordinate (MC parity).- Parameters:
x- x coordinatey- y coordinatez- z coordinate
-
-
Method Details
-
getX
public int getX() -
getY
public int getY() -
getZ
public int getZ() -
asLong
public static long asLong(int x, int y, int z) Packs a block coordinate into a singlelong, matching the format used bynet.minecraft.util.math.BlockPos#toLong()on the Minecraft versions that have it: x in the upper 26 bits, y in the middle 12 bits, z in the lower 26 bits.This is the wire format documented by
journeymap.api.v2.server.overlay.OverlayPoints, so the packed value is identical regardless of which Minecraft version an addon is built against.- Parameters:
x- block x coordinatey- block y coordinatez- block z coordinate- Returns:
- the packed value
-
toLong
public long toLong()Packs this position viaasLong(int, int, int).- Returns:
- the packed value
-
fromLong
Unpacks a value produced byasLong(int, int, int). Each component is sign-extended from its field width, so negative coordinates round-trip.- Parameters:
packed- a value produced byasLong(int, int, int)- Returns:
- the unpacked position
-
equals
-
hashCode
public int hashCode() -
toString
-