Class BlockPos

java.lang.Object
journeymap.api.v2.common.util.BlockPos

public final class BlockPos extends Object
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 Details

    • BlockPos

      public BlockPos(int x, int y, int z)
      Constructor.
      Parameters:
      x - block x coordinate
      y - block y coordinate
      z - 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 coordinate
      y - y coordinate
      z - 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 single long, matching the format used by net.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 coordinate
      y - block y coordinate
      z - block z coordinate
      Returns:
      the packed value
    • toLong

      public long toLong()
      Packs this position via asLong(int, int, int).
      Returns:
      the packed value
    • fromLong

      public static BlockPos fromLong(long packed)
      Unpacks a value produced by asLong(int, int, int). Each component is sign-extended from its field width, so negative coordinates round-trip.
      Parameters:
      packed - a value produced by asLong(int, int, int)
      Returns:
      the unpacked position
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object