Class ChunkStore

java.lang.Object
com.sk89q.worldedit.world.storage.ChunkStore
All Implemented Interfaces:
Closeable, AutoCloseable
Direct Known Subclasses:
LegacyChunkStore, McRegionChunkStore

public abstract class ChunkStore extends Object implements Closeable
Represents chunk storage mechanisms.
  • Field Details

    • CHUNK_SHIFTS

      public static final int CHUNK_SHIFTS
      The shift for converting to/from a chunk position.

      >> - to chunk << - from chunk

      See Also:
    • CHUNK_SHIFTS_Y

      public static final int CHUNK_SHIFTS_Y
      The shift for converting to/from a 3D chunk position.

      >> - to Y of 3D-chunk << - from Y of 3D-chunk

      See Also:
  • Constructor Details

    • ChunkStore

      public ChunkStore()
  • Method Details

    • toChunk3d

      public static BlockVector3 toChunk3d(BlockVector3 position)
      Convert a position to a 3D-chunk. Y is counted in steps of 256.
      Parameters:
      position - the position
      Returns:
      chunk coordinates
    • toChunk

      public static BlockVector2 toChunk(BlockVector3 position)
      Convert a position to a chunk.
      Parameters:
      position - the position
      Returns:
      chunk coordinates
    • getChunkTag

      public abstract CompoundTag getChunkTag(BlockVector2 position, World world) throws DataException, IOException
      Get the tag for a chunk.
      Parameters:
      position - the position of the chunk
      Returns:
      tag
      Throws:
      DataException - thrown on data error
      IOException - thrown on I/O error
    • getEntitiesTag

      @Nullable public CompoundTag getEntitiesTag(BlockVector2 position, World world)
      Get the tag for the entities stored in a chunk from the entities folder. 1.17+ use only. If an error occurs, returns null.
      Parameters:
      position - the position of the chunk
      Returns:
      tag
    • getChunk

      public Chunk getChunk(BlockVector2 position, World world) throws DataException, IOException
      Get a chunk at a location.
      Parameters:
      position - the position of the chunk
      Returns:
      a chunk
      Throws:
      ChunkStoreException - thrown if there is an error from the chunk store
      DataException - thrown on data error
      IOException - thrown on I/O error
    • close

      public void close() throws IOException
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Throws:
      IOException
    • isValid

      public abstract boolean isValid()
      Returns whether the chunk store is of this type.
      Returns:
      true if valid