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

java.lang.Object
net.paulem.arcana.regions.container.ChunkSectionBlockContainer<S,K>
Type Parameters:
S - The type of entities being tracked and 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 ChunkSectionBlockContainer<S extends Tracked<K>,K extends WorldKey> extends Object implements SubContainerHolderAccessor<S,K>
Represents a container for managing blocks within a specific vertical section of a chunk. Each ChunkSectionBlockContainer instance corresponds to a single section, providing management for tracked entities within that section. This container is optimized for organizing and accessing data based on three-dimensional coordinates (x, y, z) relative to the chunk section.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Removes every holder stored in this section.
     
    getHolder(int x, int y, int z)
    Retrieves the tracked object at the given coordinates, relative to this section.
    static <S extends Tracked<K>, K extends WorldKey>
    ChunkSectionBlockContainer<S,K>
    of(ChunkBlockContainer<S,K> parent, int sectionY)
    Creates a new, empty ChunkSectionBlockContainer for the given parent chunk container and section index.
    void
    removeHolder(int x, int y, int z)
    Removes the tracked object at the given coordinates, relative to this section, and notifies the parent chunk container to remove this section if it has become empty as a result.
    void
    setHolder(int x, int y, int z, S holder)
    Stores a tracked object at the given coordinates, relative to this section.

    Methods inherited from class java.lang.Object

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

    • of

      public static <S extends Tracked<K>, K extends WorldKey> ChunkSectionBlockContainer<S,K> of(ChunkBlockContainer<S,K> parent, int sectionY)
      Creates a new, empty ChunkSectionBlockContainer for the given parent chunk container and section index.
      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 chunk container this section belongs to
      sectionY - the vertical index of this section within the chunk
      Returns:
      a new ChunkSectionBlockContainer instance
    • getHolder

      public S getHolder(int x, int y, int z)
      Retrieves the tracked object at the given coordinates, relative to this section.
      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 none is stored there
    • setHolder

      public void setHolder(int x, int y, int z, S holder)
      Stores a tracked object at the given coordinates, relative to this section.
      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, relative to this section, and notifies the parent chunk container to remove this section if it has become empty as a result.
      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
    • clear

      public void clear()
      Removes every holder stored in this section.
    • 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 currently stored in this section