Class ChunkBlockContainer<S extends Tracked<K>,K extends WorldKey>

java.lang.Object
net.paulem.arcana.regions.container.ChunkBlockContainer<S,K>
Type Parameters:
S - The type of the tracked entities being managed, which extends Tracked.
K - The type of the key associated with the tracked entities, which extends WorldKey.
All Implemented Interfaces:
SubContainerHolderAccessor<S,K>

public class ChunkBlockContainer<S extends Tracked<K>,K extends WorldKey> extends Object implements SubContainerHolderAccessor<S,K>
Represents a container for managing and organizing data within a specific chunk of the world. This container divides the chunk into sections based on the vertical axis, allowing for more granular management of data associated with tracked entities.
  • Method Details

    • of

      public static <S extends Tracked<K>, K extends WorldKey> ChunkBlockContainer<S,K> of(WorldBlockContainer<S,K> parent, ChunkKey chunkKey)
      Creates a new, empty ChunkBlockContainer for the given parent world container and chunk.
      Type Parameters:
      S - the type of the tracked entities being managed
      K - the type of the key associated with the tracked entities
      Parameters:
      parent - the world container this chunk container belongs to
      chunkKey - the key identifying the chunk this container manages
      Returns:
      a new ChunkBlockContainer instance
    • getSection

      public ChunkSectionBlockContainer<S,K> getSection(int sectionY)
      Retrieves the vertical section at the given index, without creating it.
      Parameters:
      sectionY - the section index
      Returns:
      the section at the given index, or null if it hasn't been created yet
    • getOrCreateSection

      public ChunkSectionBlockContainer<S,K> getOrCreateSection(int sectionY)
      Retrieves the vertical section at the given index, creating it first if it doesn't exist yet.
      Parameters:
      sectionY - the section index
      Returns:
      the section at the given index, never null
    • removeSection

      public void removeSection(ChunkSectionBlockContainer<S,K> section)
      Removes the given section from this chunk container and notifies the parent world container to remove this chunk if it no longer has any sections left.
      Parameters:
      section - the section to remove
    • clear

      public void clear()
      Clears all holders from every section in this chunk container.
    • getHolder

      @Nullable public S getHolder(int x, int y, int z)
      Retrieves the tracked object at the given coordinates, using the vertical section that y falls into.
      Specified by:
      getHolder in interface SubContainerHolderAccessor<S extends Tracked<K>,K extends WorldKey>
      Parameters:
      x - the x coordinate
      y - the y coordinate
      z - the z coordinate
      Returns:
      the tracked object at the given coordinates, or null if y is outside this chunk's height range or no object is stored there
    • setHolder

      public void setHolder(int x, int y, int z, S holder)
      Stores a tracked object at the given coordinates, using the vertical section that y falls into. Does nothing if y is outside this chunk's height range.
      Specified by:
      setHolder in interface SubContainerHolderAccessor<S extends Tracked<K>,K extends WorldKey>
      Parameters:
      x - the x coordinate
      y - the y coordinate
      z - the z coordinate
      holder - the tracked object to store
    • removeHolder

      public void removeHolder(int x, int y, int z)
      Removes the tracked object at the given coordinates, using the vertical section that y falls into. Does nothing if y is outside this chunk's height range.
      Specified by:
      removeHolder in interface SubContainerHolderAccessor<S extends Tracked<K>,K extends WorldKey>
      Parameters:
      x - the x coordinate
      y - the y coordinate
      z - the z coordinate
    • getAllHolders

      public Collection<Holder<S,K>> getAllHolders()
      Specified by:
      getAllHolders in interface SubContainerHolderAccessor<S extends Tracked<K>,K extends WorldKey>
      Returns:
      a collection of all holders stored across every section of this chunk