Class BlockKey

java.lang.Object
de.eldoria.schematicbrush.rendering.BlockKey

public final class BlockKey extends Object
Packs block and section coordinates into a single long.

x and z use 26 bits each, y uses 12 bits, which covers the world border and every supported build height. The same layout is used for section keys, which hold the section coordinates (coordinate >> 4).

  • Method Summary

    Modifier and Type
    Method
    Description
    static long
    of(int x, int y, int z)
    Packs coordinates into a key.
    static long
    section(int x, int y, int z)
    Returns the key of the section that contains a block.
    static long
    section(long blockKey)
    Returns the key of the section that contains a block.
    static int
    x(long key)
    Unpacks the x coordinate.
    static int
    y(long key)
    Unpacks the y coordinate.
    static int
    z(long key)
    Unpacks the z coordinate.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • of

      public static long of(int x, int y, int z)
      Packs coordinates into a key.
      Parameters:
      x - x coordinate
      y - y coordinate
      z - z coordinate
      Returns:
      packed key
    • section

      public static long section(long blockKey)
      Returns the key of the section that contains a block.
      Parameters:
      blockKey - packed block key
      Returns:
      packed section key
    • section

      public static long section(int x, int y, int z)
      Returns the key of the section that contains a block.
      Parameters:
      x - block x coordinate
      y - block y coordinate
      z - block z coordinate
      Returns:
      packed section key
    • x

      public static int x(long key)
      Unpacks the x coordinate.
      Parameters:
      key - packed key
      Returns:
      x coordinate
    • y

      public static int y(long key)
      Unpacks the y coordinate.
      Parameters:
      key - packed key
      Returns:
      y coordinate
    • z

      public static int z(long key)
      Unpacks the z coordinate.
      Parameters:
      key - packed key
      Returns:
      z coordinate