Class ChunkPosition

java.lang.Object
io.github.bakedlibs.dough.blocks.ChunkPosition

public final class ChunkPosition extends Object
This is a memory efficient version of a Chunk. It can be used to optimize Map usage or other storage means.
Author:
TheBusyBiscuit, Walshy
See Also:
  • Constructor Details

  • Method Details

    • getWorld

      public World getWorld()
      Gets the World this block is in. If this World has been unloaded it will throw an IllegalStateException. This should be getting handled properly by yourself!
      Note: This is held as a weak reference!
      Returns:
      The World for this block.
    • isLoaded

      public boolean isLoaded()
      This checks whether this Chunk is loaded. If the World is not loaded, this method will return false.
      Returns:
      Whether this Chunk is loaded
    • getPosition

      public long getPosition()
      Gets the long position of this block. This is constructed of the x and z.
      This is encoded as follows: (x << 32) | (z & 0xFFFFFFFFL)
      Returns:
      The position of this block.
    • getX

      public int getX()
      Gets the x for this Chunk.
      Returns:
      This chunks x coordinate.
    • getZ

      public int getZ()
      Gets the y for this Chunk.
      Returns:
      This chunks z coordinate.
    • getChunk

      public Chunk getChunk()
      Gets the Chunk where this block is located.
      Returns:
      This blocks Chunk.
    • getAsLong

      public static long getAsLong(int x, int z)
      This compacts the two provided integers into one Long. This allows us to save a lot memory-wise.
      Parameters:
      x - The x component
      z - The z component
      Returns:
      The compacted Long
    • 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